Convert simulation IR to frozen ccflow models - #52
Merged
Conversation
The IR is this package's public API -- it crosses the builder, validator, lowering and simulation boundaries -- so its 32 node types are config/spec types under the standard, not internal value types. All convert to frozen ccflow BaseModels: recursive Expr/Stmt/Module typing preserved with polymorphic round-trips, mutable containers become tuples, and validation accumulates locally then constructs one frozen result. 642 positional construction sites across 16 files become keyword calls. Honest cost: simulation throughput drops 5.5% (337,843 -> 319,213 cycles/s) from pydantic attribute access in the interpreter walk. No per-cycle IR construction exists, so the cost is bounded to reads. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #52 +/- ##
==========================================
- Coverage 84.56% 84.54% -0.02%
==========================================
Files 60 60
Lines 9712 9702 -10
Branches 1240 1240
==========================================
- Hits 8213 8203 -10
Misses 1198 1198
Partials 301 301 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The largest single cluster in the standards ledger: the IR's 32 node types (
expr.py,stmt.py,module.py,validate.py) plusSimulationResultandVerilatorTestbenchResultwere standalone dataclasses. The IR is this package's public API — it crosses the builder, validator, lowering and simulation boundaries — so these are spec types under the standard.All convert to frozen ccflow BaseModels. Verified independently: 32 IR models, all frozen, zero dataclasses remaining, mutation raises.
Expr/Stmt/Moduletyping preserved, with polymorphic round-trip tests rather than loosening toAnyValidationResultnow accumulates locally and constructs one frozen resultHonest cost, measured: simulation throughput drops 5.5% (337,843 → 319,213 cycles/s); compile median 0.244 → 0.250 ms. That is pydantic attribute access in the interpreter walk. Reported rather than hidden — if it matters, the interpreter can snapshot hot fields into locals, but that is an optimization for its own change.
Suite: 504 passed. Clears ~35 of the 68 ledger violations.