Skip to content

Fold-step synthesis memo: built, correct, and does not pay (evidence, not for merge) - #489

Closed
johnml1135 wants to merge 2 commits into
feature/synthesis-fold-probesfrom
feature/synthesis-fold-sharing
Closed

Fold-step synthesis memo: built, correct, and does not pay (evidence, not for merge)#489
johnml1135 wants to merge 2 commits into
feature/synthesis-fold-probesfrom
feature/synthesis-fold-sharing

Conversation

@johnml1135

@johnml1135 johnml1135 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

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. SynthesisStateKey carries the ordered remaining trail plus shape, syntactic FS, realizational FS, MPR set, root allomorph, disjunctive allomorph indices, applied counts, IsPartial, IsLastAppliedRuleFinal and 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:

fixture predicted realised memo hits off-arm noise
deep-optional-affix-nesting 50.4%% (~2x) 0.96x (4.5%% slower) 0 38.6%%
suffixing-evidential-adjacency-chain 52.0%% (~2x) 1.06x 2,682 21.9%%

hits = 0 on 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:

measurement key apparent sound
synthesis-input dedupe order-insensitive 9,774x 15-40%%
fold-entry census trail position only 6,476x not established
fold-step sharing (here) trail position only 3.22x / 8.10x hits = 0

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 Reviewable

johnml1135 and others added 2 commits August 27, 2026 09:35
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>
@johnml1135

Copy link
Copy Markdown
Collaborator Author

Superseded by #490 (docs-only). The implementation is preserved on feature/synthesis-fold-sharing as reproducible evidence — parity-clean across all 33 conformance fixtures, hits = 0 on the best case — and is row 5 of the ledger. Not merging research scaffolding into product assemblies.

@johnml1135 johnml1135 closed this Aug 27, 2026
@johnml1135
johnml1135 deleted the feature/synthesis-fold-sharing branch August 27, 2026 20:09
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