Skip to content

Record: GDN-Hybrid + TMA Megakernel + Brotli-11 — val_bpb 1.01195 (3-seed mean) - #1672

Closed
andrewbaggio1 wants to merge 3 commits into
openai:mainfrom
andrewbaggio1:record/gdn-hybrid-megakernel-1576
Closed

andrewbaggio1 wants to merge 3 commits into
openai:mainfrom
andrewbaggio1:record/gdn-hybrid-megakernel-1576

Conversation

@andrewbaggio1

Copy link
Copy Markdown

Summary

val_bpb = 1.01195 (3-seed mean, std 0.00061) | 8xH100 SXM, 600s | GDN-Hybrid + Fused MLP Megakernel

This is the first GDN-Hybrid submission with a fused Triton megakernel. It combines the GDN recurrent architecture from PR #1576 with a Hopper TMA-accelerated fused relu_sq MLP kernel, brotli-11 model compression (everyone should use this!!), and GPTQ int6 quantization with eigendecomposition-based Hessian repair.

Seed Steps EMA BPB Quantized BPB Artifact bytes
42 2,212 1.000783 1.011245 15,765,907
1337 2,736 1.001806 1.012324 15,804,631
2024 2,758 1.000638 1.012281 15,802,165
Mean — 1.001076 1.011950 —

Architecture

GDN-Hybrid Model D: [GDN x5] -> [SWA] -> [GDN x5] -> [SWA_shared]

  • GatedDeltaNet recurrent layers from the FLA library (fla.layers.GatedDeltaNet), dim=512, 8 heads, head_dim=64, allow_neg_eigval=True
  • Sliding Window Attention with weight-sharing (Griffin/Zamba-style), window=512, QK-Gain 5.0
  • Fused relu_sq MLP megakernel: Hopper TMA persistent Triton kernel fusing FC projection + ReLU^2 activation + gradient caching in a single kernel launch per block. BLOCK_M=128, BLOCK_N=128, BLOCK_K=64
  • SP1024 tokenizer, 33.5M parameters, bigram path disabled (dead weights)
  • SmearGate, logit softcap 30.0, tied embeddings

Training

  • MuonEq-R optimizer (momentum=0.97) + AdamW for scalars/embeddings
  • EMA decay=0.997 + SWA (17-18 checkpoint average during warmdown)
  • Warmdown schedule: TOTAL_ITERATIONS=2100, WARMDOWN_ITERS=1000 (cosine from lr=1.0 to 0.0)
  • Wallclock budget: 590s on 8xH100 SXM

Quantization & Compression

  • GPTQ int6 with autoregressive self-generated calibration data (64 sequences)
  • Eigendecomposition-based Hessian repair for numerically degenerate matrices
  • Brotli quality 11 compression with size-descending tensor ordering (saves ~700KB vs zstd-22 on this model family)
  • All artifacts under 16,000,000 bytes (decimal)

Original Contributions

  1. Fused relu_sq MLP megakernel — Hopper TMA persistent Triton kernel. Fuses the entire MLP forward pass (matmul + activation + writeback) into one kernel launch per block. Fulfills the megakernel bounty board item 👀

  2. Brotli-11 model compression — First submission to use brotli for model artifact compression. Saves ~700KB over zstd-22 on GDN-family int6 weights due to brotli's superior static Huffman coding of the peaked int6 value distribution. Combined with size-descending tensor sort for improved LZ back-references.

  3. GPTQ eigendecomposition Hessian repair — When Cholesky decomposition fails on numerically degenerate Hessians (common with GDN recurrent projections), the quantizer floors negative eigenvalues via eigendecomposition and rebuilds a valid SPD matrix.

Compliance (Issue #1017)

  • Condition 1 (Causality): GDN is inherently causal (recurrent). SWA uses causal masking
  • Condition 2 (Normalized): Standard softmax over full vocabulary with logit softcap
  • Condition 3 (Score before update): Fixed predictor — no TTT, no eval-time adaptation
  • Condition 4 (Single pass): Each token scored exactly once
  • No SLOT, no pre-quant TTT, no n-gram cache, no Tap-In, no XSA
  • All artifacts < 16,000,000 bytes, train < 600s

Credits

Reproduction

pip install flash-linear-attention brotli zstandard sentencepiece
python3 data/cached_challenge_fineweb.py --variant sp1024

SEED=42 SCORE_MODE=1 ARCH_MODE=D \
TOTAL_ITERATIONS=2100 WARMDOWN_ITERS=1000 \
VAL_LOSS_EVERY=0 GPTQ_ENABLED=1 \
torchrun --standalone --nproc_per_node=8 train_gpt_gdn_mega.py

andrewbaggio1 and others added 3 commits April 8, 2026 13:29
8 Gated DeltaNet layers + 2 softmax attention layers. GDN is mathematically
equivalent to E2E TTT-Linear with MSE loss. First competitive GDN hybrid
in the 10-min budget. Targets bounty items: E2E TTT + State-space models.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ch=1 — val_bpb 1.07636 (3-seed mean)

3-seed mean 1.07636 BPB (std 0.0006), delta -0.00897 nats vs merged SOTA #1493.
Novel: TMA fused MLP kernel, Tap-In unigram matching (min_match=1, fires 21% of positions),
improved parallel residuals from #1529, parameter banking from #1523.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…seed mean)

GDN-Hybrid (GatedDeltaNet + SWA) with Hopper TMA fused relu_sq MLP megakernel,
brotli-11 compression, and GPTQ int6 with eigendecomposition Hessian repair.

3-seed mean: 1.01195 BPB (std 0.00061). All artifacts under 16MB.
@tejasnaladala

Copy link
Copy Markdown

Hey @andrewbaggio1, this submission inherits the same build_sentencepiece_luts byte-counting bug that closed PR #1545 and PR #1576, and that PR #1632 still has open. Flagging because the reported val_bpb 1.01195 comes from the same double-add path. The architecture work is not in question here, only the byte accounting.

The bug, in this PR

records/track_10min_16mb/2026-04-16_GDN_Hybrid_TMA_Megakernel_Brotli11/train_gpt_gdn_mega.py, lines 234 to 247:

def build_sentencepiece_luts(sp, vocab_size, device):
    base_bytes = torch.zeros(vocab_size, dtype=torch.float32, device=device)
    has_space = torch.zeros(vocab_size, dtype=torch.bool, device=device)
    is_boundary = torch.zeros(vocab_size, dtype=torch.bool, device=device)
    for i in range(vocab_size):
        piece = sp.id_to_piece(i)
        raw = piece.encode("utf-8")
        base_bytes[i] = len(raw)
        if piece.startswith("\u2581"):
            has_space[i] = True
            base_bytes[i] = len(piece[1:].encode("utf-8")) + 1   # +1 is the space byte
        if sp.is_control(i) or sp.is_unknown(i):
            is_boundary[i] = True
    return base_bytes, has_space, is_boundary

And the eval loop adds the same space byte again at line 666:

tb += (has_leading_space_lut[tgt] & ~is_boundary_token_lut[prev]).to(torch.float64)

For every (prev, tgt) pair where tgt begins with \u2581 and prev is not a boundary token, the byte count includes the leading-space byte twice. byte_count gets inflated and BPB = loss / byte_count ends up lower than what the reference path on main would return.

Why this is the same bug as #1545 / #1576

Direct line-for-line match against PR #1632, PR #1545, and PR #1576's pre-close LUT. Same + 1, same eval-loop addition, same SP-token construction. @joshkmartinez acknowledged the same issue on #1576 (Good catch, thanks! and the PR was closed). @Abhishek8108 reported the corrected number on #1545 landed near 1.18 rather than the originally claimed 1.028.

Expected corrected number

I cannot rescore your artifacts directly. Mechanically: at SP1024 with FineWeb the inflated denominator is roughly 14 to 18 percent higher than the reference, so a rescore using main's build_sentencepiece_luts would push 1.01195 into the same ~1.18 neighborhood that #1545's correction landed in. GDN-Hybrid + TMA Megakernel may genuinely sit lower than the closed predecessors after correction, but the +1 has to come out of the LUT before that number means anything.

Suggested fix

Replace build_sentencepiece_luts in train_gpt_gdn_mega.py with the one from train_gpt.py on main (around lines 180 to 202). The main version handles sp.is_byte, sp.is_control, sp.is_unknown, sp.is_unused, and strips \u2581 from the piece before measuring its length. No changes needed to the eval loop after that.

Concretely:

  1. Strip \u2581 before base_bytes[i] = len(piece.encode("utf-8")).
  2. Remove the + 1.
  3. Eval-loop add stays as the single conditional already present.

Request

Could you patch the LUT and rerun your reported seeds (or rescore the submitted artifacts with the corrected counter) and update the claimed BPB? Flagging in-context rather than as a separate issue so the PR-author can decide between patch and close, the way #1576 did. The Brotli-11 + TMA Megakernel work itself is real and worth keeping, just on top of a correct denominator.

Related context: #1545 (closed), #1576 (closed), #1632 (still open with the same bug, comment posted there as well), main branch train_gpt.py lines 180 to 202.

@andrewbaggio1

Copy link
Copy Markdown
Author

thank you for letting me know

@andrewbaggio1

Copy link
Copy Markdown
Author

closed due to invalid scorer

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.

2 participants