Skip to content

Record: TMA Megakernel + Triple Loop + Parallel Residuals — val_bpb 1.08480 - #1450

Closed
andrewbaggio1 wants to merge 1 commit into
openai:mainfrom
andrewbaggio1:record/tma-megakernel-triple-loop
Closed

andrewbaggio1 wants to merge 1 commit into
openai:mainfrom
andrewbaggio1:record/tma-megakernel-triple-loop

Conversation

@andrewbaggio1

Copy link
Copy Markdown

Record: TMA Megakernel + Triple Loop + Parallel Residuals — val_bpb 1.08480

val_bpb: 1.08480 (5-seed mean, std=0.0007)

Seed Steps Sliding BPB Artifact
1234 4624 1.08359 15,750,778
1 4613 1.08512 15,750,312
42 4612 1.08530 15,751,243
1337 4614 1.08448 15,747,957
2025 4614 1.08553 15,752,675
Mean 4615 1.08480 15,750,593

Summary

This submission combines frontier techniques with a custom Triton TMA megakernel for the MLP forward pass. The fused kernel avoids materializing the 2048-wide intermediate activation, yielding +10.5% training throughput (+127 extra steps in 600s). Together with triple depth recurrence and GPT-J parallel residuals, this achieves 1.08480 BPB.

What's new

  • Triton TMA Fused MLP Forward (megakernel): Fuses fc -> leaky_relu(0.5) -> square into a single Hopper TMA kernel. Uses TensorDescriptor for async global-to-shared transfers, persistent kernel scheduling (one program per SM), interleaved writes, and 128x256x64 block tiling. Avoids materializing ~384MB intermediate per forward pass. Measured +10.5% throughput across all training phases. Falls back to torch.compile for eval.

  • Triple depth recurrence: Layers 4-5 loop 4 times total (NUM_LOOPS=3, 17 virtual layers from 11 physical). Loop activation at frac=0.35. From #1420.

  • Parallel residuals (GPT-J, layers 7-10): Attention and MLP read from same pre-residual input. From #1420.

  • All other techniques from Record: SP8192 + GPTQ Embeddings + Depth Recurrence + MuonEq-R + SDClip — val_bpb 1.08563 (5 seed mean) #1394: SP8192 vocab, GPTQ embeddings (int8), SDClip (k=13.5), MuonEq-R, skip gates, ShuffledSequenceLoader, EMA, brotli.

Legality

No TTT, no SLOT, no n-gram caching, no multi-pass scoring. Full audit against #1017 conditions in the README.

Reproduction

rm -f data/manifest.json
MATCHED_FINEWEB_REPO_ID=kevclark/parameter-golf \
python3 data/cached_challenge_fineweb.py --variant sp8192 --train-shards 128

SEED=1234 VOCAB_SIZE=8192 \
torchrun --standalone --nproc_per_node=8 train_gpt.py

Credits

Builds on @clarkkev's #1394 and @abaybektursun's #1420. Full component lineage in the README.

….08480 (5-seed mean)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
taka6745 pushed a commit to taka6745/parameter-golf that referenced this pull request Apr 7, 2026
…-stack reference + Hymba/TMA deferred

At ~822 ms/step under new 65K batch + 1024 seq, the 300s wallclock only completes
~365 of 1500 target steps. Bumped to 900s for SP family + CHAMP_L4 + CS2/CS3
to get ~1095 steps per experiment (3x more learning).

Added SP6_max_stack_900s: full validated stack with 900s wallclock for the
canonical reference experiment under proper compute scale.

Subagent investigated Hymba (PR openai#852, LESSONS §28) and TMA Megakernel (PR openai#1450):
- Hymba DEFERRED: requires mamba-ssm + causal-conv1d external CUDA libraries,
  1551-line file replacement, 218 ms/step is unmeasured 7.5x scaling estimate.
- TMA Megakernel DEFERRED PERMANENTLY: H100-only via Hopper TensorDescriptor,
  would actually slow 3080 Ti to ~949 ms/step.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@mohosy

mohosy commented Apr 8, 2026

Copy link
Copy Markdown

tma megakernel is lowkey the most underrated thing in this competition rn, everyones focused on architecture but the speed gains from fused kernels mean more steps in 600s which is free bpb

resouer added a commit to resouer/parameter-golf that referenced this pull request Apr 8, 2026
resouer added a commit to resouer/parameter-golf that referenced this pull request Apr 9, 2026
@MatoTeziTanka

Copy link
Copy Markdown

Community Review — TMA Megakernel + Triple Loop + Parallel Residuals

BPB: 1.08480 (5-seed mean, std=0.0007) | Seeds: 5 | Artifact: 15,750,593 bytes mean (max 15,752,675) | Vocab: SP8192 | Compliance: PASS

What this does: Builds on @clarkkev's #1394 (SP8192, GPTQ embeddings, SDClip, MuonEq-R) and @abaybektursun's #1420 (triple depth recurrence at NUM_LOOPS=3 on layers 4-5, GPT-J style parallel residuals on layers 7-10). The headline contribution is a custom Triton Hopper TMA fused MLP forward kernel (fc -> leaky_relu(0.5) -> square) that avoids materializing the 2048-wide intermediate activation; the author measures +10.5% throughput and ~127 extra training steps in the 600s budget.

What I found in the code (static review at SHA b27fe936):

TTT compliance verdict: PASS — no TTT, no eval-time adaptation, no state mutation during eval, torch.inference_mode() throughout, single L→R sliding pass with causal context. Per Issue #402 and #677, no score-after-update ordering exists because there is no update at eval at all.

Gauntlet: Import OK, Hyperparameters OK (dim=512, layers=11, heads=8, vocab=8192), ngram_cache=false. Model-creation step skipped because the harness doesn't know how to pass the Hyperparameters arg to GPT.__init__(h) — same harness limitation seen on #1420, not a PR defect.

Questions/flags:

  • None that block merge. One cosmetic ask: reproduction command should be train_gpt.py, not train_gpt_mega.py.

Verdict: LOOKS CLEAN

Recommendation to @cocohearts @valerio-oai @0hq @yuzhougu-oai @notapplica: MERGE — beats the current merged SOTA (claimed 0.030 BPB improvement over the merged frontier), all 5 seeds under the 16MB cap, credit lineage is comprehensive and matches what the code actually borrows, eval loop is clearly legal under Issue #1017's four conditions, and the novel contribution (TMA fused MLP forward) is a hardware optimization of a permitted flavor per Issue #1409 (custom kernels allowed).


Reviewed by @MatoTeziTanka — The Agora. CPU gauntlet: import + hyperparam checks PASS, model-instantiation step skipped (harness doesn't pass the Hyperparameters positional arg that GPT.__init__ requires). AI tooling: review drafted with Claude Code (Sonnet/Opus) using an internal review template; all citations, file paths, and compliance audits were verified against the PR's actual code at SHA b27fe93647186e7c301928449f2a817d7888e8f3.

MatoTeziTanka pushed a commit to tartarus-archive/parameter-golf that referenced this pull request Apr 11, 2026
…cluster + CT2038 gauntlet provisioned

Reviewed all 20 highest-priority Tier 1 PRs from openai/parameter-golf.
Two cluster-level findings:

- N-gram family bug (10 PRs CLOSED + 1 already ruled): full_key = ((ctx_hash
  ^ (target * primes[k])) & mask) — target token hashed into the eval-cache
  lookup key, ruled illegal by valerio-oai on PR openai#779. Same verbatim pattern
  in openai#770/openai#798/openai#808/openai#825/openai#786/openai#797/openai#909/openai#940/openai#761 + openai#764 follow-up. Upstream
  parent: lukacf (openai#659/openai#702/openai#727 — task #5 audit queued).

- Standard SLOT cluster (4 HOLD pending openai#1336, 2 CLOSE): per-window
  delta+logit_bias optimized N steps against (per_token_nll * mask) where
  mask = scored positions [s:wlen]. PRs openai#1321/openai#1324/openai#1278/openai#1263 → HOLD;
  openai#1319/openai#1376 → CLOSE.

Clean MERGE-eligible: openai#1420 (token_hint-only post-fix) and openai#1450 (TMA
megakernel triple loop).

Eval-budget gate (openai#915/openai#889 anthony-maio pair): clean ngram code, ~14.9 min
ngram stage on 8xH100 SXM. One @0hq ruling on Issue openai#17 unblocks both PRs
plus ~30 ngram-cache PRs.

Infrastructure: provisioned CT2038 (proteus-engine, 128 GB RAM, 32 cores)
as the dedicated parameter-golf gauntlet host. Installed Triton 3.6.0,
deployed cpu_test.py + flash_attn_stub.py. Re-ran the 4 PRs originally
skipped due to FA3/Triton blockers — all PASS. Edited 4 GitHub comments
via gh api PATCH to add the rerun results. Coverage went from 9/20 to
14/20 fully gauntleted.

Side session handed off via SOW_HF_DATASET_REPUBLISH.md (Scylla 998→1254
fix + SP4096/SP8192/SP12288/SP16384 publish + Cloudflare R2 mirror).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@andrewbaggio1

Copy link
Copy Markdown
Author

thank you but when the reviewers built the merge chain on april 9 they likely skipped it because it didn't fit in the range

This was referenced Apr 11, 2026
This was referenced Apr 11, 2026
@MatoTeziTanka

Copy link
Copy Markdown

Makes sense — the April 9 merge chain was focused on a narrower range. The review and MERGE recommendation stand on their own regardless of where it lands in the merge queue. Good luck.

ChideraIbe123 pushed a commit to ChideraIbe123/parameter-golf that referenced this pull request Apr 16, 2026
Deep audit (via compare to PR openai#1450/openai#1555 + Triton tutorials + Liger-Kernel)
identified why v1-v3 couldn't beat eager. Three real bugs fixed:

1. EPILOGUE SCALE (was bug openai#2 = no-speedup cause)
   Old: row_scale applied to `a` INSIDE the K-loop. This serializes the
        TMA->wgmma software pipeline — every A tile needs elementwise
        modification after TMA arrives before wgmma can start, killing
        num_stages=4 pipelining.
   New: accumulator *= row_scale[:, None] in the epilogue, once per tile.
        Algebraically identical because row_scale depends only on rows.
        TMA pipelining preserved.

2. FP32 INV_RMS (was bug #1 = BPB regression cause)
   Old: inv_rms stored as bf16 (7-bit mantissa). Rounded scale propagated
        into pre-activation, discontinuous leaky_relu^2 amplified it,
        and it leaked into backward dw1 and dx.
   New: inv_rms is fp32 end-to-end.

3. L2 SWIZZLE (was bug openai#3 = 5-15% perf left on table)
   Old: row-major tile iteration thrashes L2 (every SM touches every N
        column of B in first few iterations).
   New: GROUP_SIZE_M=8 grouped scheduling reuses B tiles across 8
        consecutive m-tiles per SM -> better L2 hit rate.

Reference: PR openai#1450/openai#1555 architecture + Triton 09-persistent-matmul
tutorial. These are the known-good Hopper TMA fused MLP patterns.

Expected: v4 should beat v1 (1.1106) AND beat eager (1.1104) if the
audit's diagnosis is correct.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ChideraIbe123 pushed a commit to ChideraIbe123/parameter-golf that referenced this pull request Apr 16, 2026
…ing)

Kernel now writes act_grad = d/dh[leaky_relu(h)^2] = where(h>0, 2h, 0.5h)
to the aux buffer instead of post = leaky_relu(h)^2.

Forward output semantics:
  Old: c=pre (scaled pre-activation), aux=post
  New: c=post (used for dw2), aux=act_grad (used for dpre multiply)

Backward simplification:
  Old kernel loaded pre from aux, computed where(pre>0, 2*pre, 0.5*pre)
      per tile, multiplied by acc, stored result.
  New kernel loads act_grad directly, just multiplies by acc, stores.
  Saves: tl.where + fp32 multiply + fp32 cast per backward tile.

Matches PR openai#1450's "+10.5% throughput" design. The structural difference
is that forward now computes both post AND act_grad from the same acc
in fp32, making the backward kernel a pure elementwise multiply.

Keeps v4's audit fixes (epilogue scale, fp32 inv_rms, GROUP_SIZE_M=8).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
ChideraIbe123 pushed a commit to ChideraIbe123/parameter-golf that referenced this pull request Apr 16, 2026
5-variant systematic ablation of manual Triton MLP fusion at 27M x 600s
x H100. All 5 variants (including audit-guided best practices and
exact PR openai#1450 architecture that claims +10.5% throughput) land within
0.0008 BPB of each other, all worse than torch.compile eager.

Research finding: manual block-level MLP fusion cannot beat
torch.compile's automatic fusion ceiling at this model scale.
Implications for parameter-golf participants documented.

Best variant: v4 (audit fixes) at 1.1107 vs eager 1.1104.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@andrewbaggio1 andrewbaggio1 closed this by deleting the head repository Aug 26, 2026
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.

3 participants