circuit_unpacker: short-circuit fully-dummy subtrees#360
Conversation
PR SummaryMedium Risk Overview
Tests are updated for the API; Reviewed by Cursor Bugbot for commit bc08899. Bugbot is set up for automated code reviews on this repo. Configure here. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## anatg/unpacker_dummies #360 +/- ##
==========================================================
+ Coverage 59.56% 59.99% +0.43%
==========================================================
Files 36 36
Lines 5366 5417 +51
==========================================================
+ Hits 3196 3250 +54
+ Misses 2170 2167 -3
🚀 New features to boost your workflow:
|
72d9fee to
11cff94
Compare
c300255 to
0fe7c2e
Compare
11cff94 to
dc9e591
Compare
0fe7c2e to
311e9a2
Compare
dc9e591 to
df33de0
Compare
311e9a2 to
17063dd
Compare
…constants Replaces the "treat dummies as regular leaves" recursion with an off-circuit precompute of dummy_hash_at_depth(d) for every depth in 0..=tree_height, wired in-circuit as ctx.constants. The recursive compute_subtree_hash now takes (leaf_offset, n_real, depth, dummy_hash_vars) and returns the cached constant directly whenever a subtree's leaf range falls entirely in the dummy region -- no recursion or Blake gate on the dummy side. Mixed subtrees still recurse on the real side and combine with the cached dummy constant under a single Blake gate. Requires a small API change: preprocessed_root is now HashValue<QM31> (by value), since the off-circuit precompute needs the value, not just Vars. The unpacker wires it as ctx.constant internally; callers no longer have to pre-wire pp_root themselves. Existing tests adjusted. Adds unpacker_n5_dummies_short_circuit_at_two_depths, an N=5 case where both a depth-0 dummy (slot 5) and an all-dummy depth-1 subtree (slots 6,7) exercise the short-circuit at two distinct depths in the same circuit build. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
17063dd to
bc08899
Compare
df33de0 to
3ddf623
Compare
Summary
Replaces the "treat dummies as regular leaves" recursion with an off-circuit precompute of per-depth dummy-subtree hash constants, wired in-circuit as
ctx.constants. When a subtree falls entirely in the dummy region (its leaf range starts at or afterN), the recursion returns the cached constant directly — no Blake gate, no recursion, no guessedVars on the dummy side. Mixed subtrees recurse only on the real side and combine with the cached dummy constant under one Blake gate.API change
run_unpacker'spreprocessed_rootis nowHashValue<QM31>(by value) instead ofHashValue<Var>. The off-circuit precompute (precompute_dummy_hashes) needs the QM31 value; the unpacker wires it asctx.constantinternally, so callers no longer pre-wirepp_root. The existing tests are updated accordingly.New test
unpacker_n5_dummies_short_circuit_at_two_depths— N=5, N_total=8: slot 5 is a single dummy leaf (depth-0 short-circuit) and slots 6,7 form an all-dummy depth-1 subtree (depth-1 short-circuit). Exercises both layers in one build.This change is