Skip to content

docs(audit): FORGE assessment + residency-aware epilogue-fusion track - #565

Merged
gstoner merged 1 commit into
mainfrom
agent/forge-epilogue-fusion-assessment
Aug 15, 2026
Merged

gstoner merged 1 commit into
mainfrom
agent/forge-epilogue-fusion-assessment

Conversation

@gstoner

@gstoner gstoner commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Assessment of FORGE (arXiv:2606.22932v2, dk4248/FORGE) — fusing the optimizer step into the weight-gradient GEMM epilogue at tile granularity, so grad_W never reaches HBM — and the generalization it opens for Tessera:

Fuse a consumer into its producer's tiled epilogue when the consumer's read-locality is no coarser than the producer's tile partition, and prove statically that the intermediate never materializes.

FORGE is one instance (optimizer ← weight-gradient GEMM). Eight workstreams W1–W8 generalize it to N consumers × M producers with declared legality, arbiter admission, and a compiler that reports when the win isn't there.

Files

File
docs/audit/compiler/FORGE_ASSESSMENT.md audit_role: plan, plan_state: open, 371 lines
tests/unit/test_fused_wgrad_optimizer_contract.py 14 tests, pure numpy, 0.5 s — declared oracle (Decision #31b) for the not-yet-landed pass
docs/audit/compiler/README.md routed twice: question table + scoped-plan catalog

Math verified, not asserted

Nine propositions are stated in the plan and shipped as an executable contract, so W3/W4 inherit a gate rather than an argument. Identifiers match §2 of the doc.

  • P1 — per-tile exactness is bitwise and partition-independent. The single-use ∧ consumer-is-optimizer guard subsumes FORGE Rem. 2 (tied weights) structurally: a tied weight's %g1 is consumed by an add, so the match cannot fire. Because our optimizer ops are value-semantic and Pure, FORGE's in-place ΔX-before-update hazard — which its repo guards with a comment and a correctness script — cannot occur at Graph IR.
  • P2 — exact global-norm clipping provably cannot be fused (m_t(c) − c·m_t(1) = (1−c)β₁m_{t−1} needs an O(P) tensor). Both candidate approximations fail: clip-the-update and delayed-norm each leave √v̄ inflated 3.18× ten steps after a spike — identical to no clipping at all. grad_clip_scope must fail closed (Decision #21a). FORGE ships with clipping switched off and says so only in two appendix protocol lines.
  • P3 — the affine reduce-into-state trick composes with Decision Phase 8.5 — apple_gpu story doc + CLAUDE.md update #16 (ZeRO-2); owner is unambiguous under reduce-scatter.
  • P5 — folding state decay into the GEMM's β breaks conditionally-routed weights: 2.24× error at 50% routing. A verifier condition, given tessera.moe_swiglu_block.
  • P6 — the fp32-accumulator precision benefit is worth ~900× with fp32 state and ~1× with bf16 state. The paper measures it inside a BF16-everywhere recipe that masks it and reports 4.4%; its own int8/fp8 rows are 4× and 44× worse than baseline. Whether the benefit is realizable is a numeric_policy question — the measured motivation for the Decision docs: scope GPU-resident activations / persistent device-handle model #32 carrier work.

What's already in tree and easy to miss

  • The weight-gradient GEMM reaches Graph IR via LinearTransposeInterface, not AdjointInterfaceMatmulOp doesn't implement the latter, so grepping only for adjoints yields a false "no compiled matmul VJP" conclusion. MatmulOp::buildLinearTranspose emits dRhs = matmul(lhs, dy, transposeA=true); fixture autodiff_paired_matmul.mlir.
  • TrainingStepFusionPass already implements the identical pattern one level down (loss_backward → adamw), with a negative fixture and a LOWER-COUNT-1: linalg.generic check that proves non-materialization in the IR rather than by peak-memory measurement. That makes this track gateable on any host — no 8B model or 141 GB card needed.
  • MatmulOp::getLoopIteratorTypes(){parallel, parallel} with K kept whole, stamped tessera.full_k — that is FORGE Prop. 1's legality condition, currently with no consumer (a live Decision Apple GPU MLA: native f16/bf16 for the absorbed decode kernel #29 gap this closes).
  • MatmulLowering already does "bf16 accumulate in f32 then truncf" — that truncf is exactly the rounding FORGE deletes, testable on CPU.

Claim hygiene on the source

The public repo ships AdamW and SGD only — no torch.distributed, no all_reduce, no bucket coordinator, and none of Muon/LAMB/Lion/Adafactor/SM3. §4 and Appendices I, K–N are not reproducible from the release. Recorded in §0; the single-GPU mechanism is an evidence row, the distributed and multi-optimizer results are not.

Scope

Direction only (Decision #26). INTEGRATED_COMPILER_PLAN.md keeps global order. MASTER_AUDIT.md / COMPILER_AUDIT.md deliberately untouched — nothing is built yet, so the all-up picture hasn't shifted.

Verification

  • test_audit_docs.py — caught two real routing obligations on first run; both fixed. 11 pass.
  • check_generated_docs.sh — 25 generated docs in sync (also passed the pre-push hook).
  • ruff clean.
  • Suite delta measured against a stashed tree: 37 failed, 1212 passed37 failed, 1226 passed — exactly the +14 new tests, same pre-existing failures (they need a built tessera-opt / fresh Apple dylib, absent on this Mac).

🤖 Generated with Claude Code

Assessment of FORGE (arXiv:2606.22932v2, fusing the optimizer step into the
weight-gradient GEMM epilogue at tile granularity) and the generalization it
opens for Tessera: fuse a consumer into its producer's tiled epilogue when the
consumer's read-locality is no coarser than the producer's tile partition, and
prove statically that the intermediate never materializes.

Math verified numerically, not asserted. Nine propositions (P1-P6) are stated
in the plan and shipped as an executable contract, so the pass that implements
W3/W4 inherits a gate rather than an argument:

* P1 per-tile exactness is bitwise and partition-independent; the single-use +
  consumer-is-optimizer guard subsumes FORGE Rem. 2 structurally, because our
  optimizer ops are value-semantic and Pure (FORGE's PyTorch in-place ordering
  hazard cannot occur at Graph IR).
* P2 exact global-norm clipping provably cannot be fused, and BOTH candidate
  approximations leave the second moment inflated 3.18x after a spike --
  identical to no clipping. grad_clip_scope must fail closed (Decision #21a).
  FORGE ships with clipping switched off and says so only in two appendix
  protocol lines.
* P5 folding state decay into the GEMM's beta breaks conditionally-routed
  weights (2.24x error at 50% routing); a verifier condition, given
  tessera.moe_swiglu_block.
* P6 the fp32-accumulator precision benefit is worth ~900x with fp32 state and
  ~1x with bf16 state. The paper measures it inside a recipe that masks it and
  reports 4.4%. Whether the benefit is realizable is a numeric_policy question,
  which is the measured motivation for the Decision #32 carrier work.

Also records what is already in tree and easy to miss: the weight-gradient GEMM
reaches Graph IR via LinearTransposeInterface, NOT AdjointInterface (MatmulOp
does not implement the latter), so grepping only for adjoints yields a false
"no compiled matmul VJP" conclusion; TrainingStepFusionPass already implements
the identical pattern one level down, with a negative fixture and a
LOWER-COUNT-1 check that proves non-materialization in the IR rather than by
peak-memory measurement -- which makes this track gateable on any host.

Direction only (Decision #26). INTEGRATED_COMPILER_PLAN.md keeps global order;
routed from the compiler README's question table and scoped-plan catalog.
MASTER_AUDIT/COMPILER_AUDIT deliberately untouched: nothing is built yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@gstoner
gstoner merged commit 162c49d into main Aug 15, 2026
14 checks passed
@gstoner
gstoner deleted the agent/forge-epilogue-fusion-assessment branch August 16, 2026 00:47
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