Skip to content

Convert simulation IR to frozen ccflow models - #52

Merged
timkpaine merged 1 commit into
mainfrom
tkp/ir-frozen-models
Aug 4, 2026
Merged

Convert simulation IR to frozen ccflow models#52
timkpaine merged 1 commit into
mainfrom
tkp/ir-frozen-models

Conversation

@timkpaine

Copy link
Copy Markdown
Member

The largest single cluster in the standards ledger: the IR's 32 node types (expr.py, stmt.py, module.py, validate.py) plus SimulationResult and VerilatorTestbenchResult were 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.

  • recursive Expr/Stmt/Module typing preserved, with polymorphic round-trip tests rather than loosening to Any
  • 642 positional construction sites across 16 files became keyword calls
  • mutable containers → tuples; ValidationResult now accumulates locally and constructs one frozen result
  • no per-cycle IR construction exists, so the conversion cost is bounded to attribute reads

Honest 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.

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>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Test Results

505 tests  ±0   502 ✅ ±0   24s ⏱️ +10s
  2 suites ±0     3 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit 3f5f874. ± Comparison against base commit 9b2aaee.

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.74172% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.54%. Comparing base (9b2aaee) to head (3f5f874).

Files with missing lines Patch % Lines
dau_sim/ir/validate.py 60.52% 15 Missing ⚠️
dau_sim/api.py 93.75% 1 Missing ⚠️
dau_sim/ir/printer.py 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timkpaine
timkpaine merged commit 84cb38c into main Aug 4, 2026
4 checks passed
@timkpaine
timkpaine deleted the tkp/ir-frozen-models branch August 4, 2026 13:57
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