Skip to content

Switch to new backend #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jul 16, 2025
Merged

Switch to new backend #291

merged 21 commits into from
Jul 16, 2025

Conversation

saulshanabrook
Copy link
Member

@saulshanabrook saulshanabrook commented Apr 17, 2025

Adds support for new backend in Egglog. A follow up PR can expose the new custom costs mechanism and extraction.

TODO:

* Changes PyObjectSort to use new interface
* Removes Rational since experimental not updated yet
@saulshanabrook saulshanabrook changed the title Switch to new backend branch Switch to new backend Jun 22, 2025
Copy link

codspeed-hq bot commented Jun 27, 2025

CodSpeed Instrumentation Performance Report

Merging #291 will not alter performance

Comparing new-backend (55f94bc) with main (b8be084)

Summary

✅ 7 untouched benchmarks

Copy link

codspeed-hq bot commented Jul 7, 2025

CodSpeed WallTime Performance Report

Merging #291 will degrade performances by 50.11%

Comparing new-backend (55f94bc) with main (b8be084)

Summary

❌ 3 regressions
✅ 4 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_jit[add] 366.3 ms 461.4 ms -20.61%
test_jit[lda] 8.4 s 16.8 s -50.11%
test_jit[tuple] 631.2 ms 1,003.7 ms -37.11%

@saulshanabrook
Copy link
Member Author

saulshanabrook commented Jul 7, 2025

Blocked on egraphs-good/egglog#627 EDIT: resolved

@saulshanabrook saulshanabrook requested a review from Copilot July 7, 2025 14:06
Copilot

This comment was marked as outdated.

@saulshanabrook saulshanabrook marked this pull request as ready for review July 16, 2025 18:33
@saulshanabrook saulshanabrook requested a review from Copilot July 16, 2025 18:33
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR switches the Egglog Python extension to the new backend architecture by migrating the Python object sort, adapting EGraph bindings for the new add_primitive! interface, wrapping e-graph execution in thread-safe GIL calls, and updating the Python DSL to use unbound/let-ref declarations.

  • Implements new PyObjectSort with BaseSort and add_primitive!
  • Replaces ArcPyObjectSort with PyObjectSort and registers it via add_leaf_sort
  • Migrates Python declaration types from VarDecl to UnboundVarDecl/LetRefDecl, removes simplify/QueryExtract APIs

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/py_object_sort.rs Redefines PyObjectSort, implements BaseSort, primitives, and term reconstruction
src/egraph.rs Uses add_leaf_sort, wraps run_program and serialize in allow_threads
src/lib.rs Binds new PyObjectSort into the Python module
src/conversions.rs Fixes conversion for AddRuleset and Extract commands with spans
rust-toolchain.toml Bumps toolchain channel to 1.87.0
Cargo.toml Upgrades to 2024 edition and switches to egglog-backend dependencies
python/tests/ Updates tests for the new Extract API, removes simplify usage
python/egglog/runtime.py Uses LetRefDecl for parameter defaults instead of VarDecl
python/egglog/pretty.py Replaces VarDecl with UnboundVarDecl/LetRefDecl in pretty printer
python/egglog/egraph_state.py Adds span() to AddRuleset/UnstableCombinedRuleset, uses unbound var types
python/egglog/egraph.py Removes global simplify, adapts let binding to LetRefDecl
python/egglog/declarations.py Introduces UnboundVarDecl and LetRefDecl types
python/egglog/bindings.pyi Updates stubs for new commands (Extract, UserDefined, spans)
docs/reference/egglog-translation.md Removes simplify example, updates code samples
docs/reference/contributing.md Adds debugging guide, moves "Making changes" under debugging section
docs/changelog.md Notes upgrade, breaking changes, removed simplify

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@saulshanabrook saulshanabrook enabled auto-merge July 16, 2025 18:45
@saulshanabrook saulshanabrook merged commit 3b41794 into main Jul 16, 2025
22 checks passed
@saulshanabrook saulshanabrook deleted the new-backend branch July 16, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant