Fold-step synthesis memo: built, correct, and does not pay (evidence, not for merge) - #489
Closed
johnml1135 wants to merge 2 commits into
Closed
Fold-step synthesis memo: built, correct, and does not pay (evidence, not for merge)#489johnml1135 wants to merge 2 commits into
johnml1135 wants to merge 2 commits into
Conversation
Adds SynthesisStateKey (a sound memo key -- unlike SynthesisProbe's P1c fingerprint, it includes ordered remaining-trail content, not just trail position) with a field-by-field completeness audit against SynthesisAffixProcessRule, SynthesisRealizationalAffixProcessRule, SynthesisStratumRule, SynthesisAffixTemplateRule/TemplatesRule, Allomorph.IsWordValid and Morpher.IsWordValid. Adds SynthesisFoldScope (per-parse, capped at 100k entries, same shape as AnalysisScope) and Word.ReanchorSynthesisStep to re-parent a stored fold-step output onto a different query candidate's own trail/non-head identity, including the CheckBlocking exception where a step's output is a wholly fresh Word unrelated to the input trail. Wires the memo into SynthesisAffixProcessRule.Apply and SynthesisRealizationalAffixProcessRule.Apply, gated on a new Morpher.UseSynthesisFoldMemo toggle (default false) and installed only in SynthesizeSequential (untraced, MaxDegreeOfParallelism == 1), matching AnalysisScope's own restrictions. Behaviour is unchanged with the toggle off. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds the A/B harness (warm-up discarded, min of 5 interleaved samples per arm, off-arm spread reported as a noise floor) and the finding. Parity: 0 divergences across all 33 conformance fixtures. The implementation is correct. Speed: deep-optional-affix-nesting -- predicted 50.4% ceiling, realised 0.96x with memo hits = 0. With a trail-complete key the memo never fires on the fixture with the largest reliable sample; the 4.5% regression is key-construction cost with no payoff. suffixing-evidential-adjacency-chain fires 2,682 times for 5.4% against 21.9% off-arm spread. This is the third independent route to the same result: F1's order-insensitive dedupe went 9,774x -> 15-40%, N1's fold-entry census showed 6,476x with a trail-incomplete key, and now P1c's 3.22x/8.10x goes to hits=0/1.06x once the key carries the ordered remaining trail. The redundancy is apparent, not real -- the trail is what makes each synthesis step distinct. That closes a family rather than a candidate: packed forests, fold sharing and synthesis-input dedupe all need distinct derivations to converge on an identical state, and in this engine they do not. Recommendation: do not merge as a performance feature; keep the branch as the evidence. The measurement infrastructure merges on its own. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
Author
|
Superseded by #490 (docs-only). The implementation is preserved on |
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.
Stacked on #488. This is the evidence that closes a family of optimizations. It is not proposed as a performance feature.
#488 measured 3.22x and 8.10x shareable synthesis fold steps, with ~50%% wall-clock ceilings on the two conformance fixtures large enough to time reliably, reproduced across two independent runs. This branch builds it.
It is correct.
SynthesisStateKeycarries the ordered remaining trail plus shape, syntactic FS, realizational FS, MPR set, root allomorph, disjunctive allomorph indices, applied counts,IsPartial,IsLastAppliedRuleFinaland stratum — each field justified in the doc comment against the code that reads it. Stored outputs are re-anchored rather than handed over with a foreign trail embedded. Steps are set-valued, because realizational rules are trail-exempt. Off by default. Parity: 0 divergences across all 33 conformance fixtures.It does not pay. Warm-up discarded, min of 5 interleaved samples per arm:
hits = 0on the fixture with the largest reliable sample and the highest ceiling. With a trail-complete key the memo never fires there; the regression is key-construction cost with no payoff.Why, and why it generalises. A sound key must carry the remaining trail, so two candidates have to agree on their entire future to share a step. That is the third independent route to the same result:
The redundancy is apparent, not real. The trail is what makes each step distinct, and every measurement showing large shareable work is measuring a key that omits it. Packed parse forests, fold-step sharing and synthesis-input dedupe all require distinct derivations to converge on a genuinely identical state. In this engine they do not converge — the same fact as the rules being non-order-invariant, seen from the other side.
Disposition. Recorded as row 5 in
docs/hermitcrab-optimization-ledger.md. Merge only if you want the implementation in tree as executable proof; otherwise close and keep the branch. Either way the ledger row is the durable artifact, and it lives in #488.This change is