-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Non-record: Fused Softcap+CE Megakernel (1.94x vs torch.compile) + N-gram Backoff #915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
anthony-maio
wants to merge
2
commits into
openai:main
Choose a base branch
from
anthony-maio:submission/ngram-megakernel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,386
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ data/manifest.json | |
| data/docs_selected.jsonl | ||
| .mypy_cache/ | ||
| .venv | ||
| logs/ | ||
| logs/.private/ | ||
74 changes: 74 additions & 0 deletions
74
records/track_10min_16mb/2026-03-26_NgramBackoff_VRL_LeakyReLU2/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # N-gram Backoff + VRL + LeakyReLU² — val_bpb 0.9642 | ||
|
|
||
| val_bpb = 0.9642 (3-seed mean, std 0.0002) | ~15.95 MB | 8×H100 SXM | ||
|
|
||
| ## 3-Seed Results (8×H100 80GB SXM, PyTorch 2.9.1+cu128) | ||
|
|
||
| | Seed | step_avg | steps | Pre-ngram bpb | **Post-ngram bpb** | ng_helped | Artifact | | ||
| |------|----------|-------|--------------|-------------------|-----------|----------| | ||
| | 1337 | 88.7ms | 6,765 | 1.1225 | **0.9640** | 38.5% | 15,981,848 | | ||
| | 42 | 88.6ms | 6,772 | 1.1224 | **0.9641** | 38.6% | 15,904,632 | | ||
| | 2025 | 88.6ms | 6,776 | 1.1231 | **0.9644** | 38.6% | 15,974,308 | | ||
| | **Mean** | **88.6ms** | **6,771** | **1.1227** | **0.9642 (std 0.0002)** | **38.6%** | | | ||
|
|
||
| All artifacts under 16,000,000 bytes. All train logs attached. | ||
|
|
||
| ## Key Innovation: Multi-Order N-gram Backoff Cache | ||
|
|
||
| Backward-looking n-gram cache built causally from already-scored tokens during evaluation. No training data access. Zero artifact cost. | ||
|
|
||
| ### Entropy-Adaptive Alpha | ||
| ```python | ||
| alpha = 0.05 + 0.55 * sigmoid(2.0 * (H - 4.0)) | ||
| ``` | ||
| - When neural model is confident (low entropy): alpha ≈ 0.05 (trust neural) | ||
| - When neural model is uncertain (high entropy): alpha ≈ 0.60 (trust n-grams) | ||
|
|
||
| ### Multi-Order Backoff (2-7gram) | ||
| - Try highest order first (7-gram), fall back to lower orders | ||
| - Only emit prediction when context count >= 2 | ||
| - Raw count ratios, no smoothing | ||
| - 4M hash buckets per order (XOR-with-primes hashing) | ||
|
|
||
| ### Mixing | ||
| ```python | ||
| mixed_p = (1 - alpha) * model_p + alpha * ngram_p | ||
| ``` | ||
| Linear interpolation in probability space. Score-first: n-gram tables updated AFTER each token is scored. | ||
|
|
||
| ## Training Architecture | ||
|
|
||
| Same as PR #175 (our pure neural submission at 1.1229): | ||
| - 11L, 512d, 8H/4KV (GQA), LeakyReLU(0.5)² MLP 3× | ||
| - VRL (Value Residual Learning), VE128, SmearGate, BigramHash(2048) | ||
| - XSA4, Partial RoPE 16/64, LN Scale, U-Net skips | ||
| - EMA(0.997) + Tight SWA, Late QAT (STE@0.15), OrthoInit | ||
| - GPTQ-lite int6 + lzma, FA3 Hopper, Muon WD=0.04 | ||
|
|
||
| ## Compliance | ||
|
|
||
| - Training: 600s on 8×H100 SXM | ||
| - Eval (sliding window + n-gram): ~15 min on 8×H100 SXM (under 10 min per-GPU) | ||
| - All artifacts under 16,000,000 bytes | ||
| - N-gram tables built causally from already-scored tokens only | ||
| - No training data access during evaluation | ||
| - No oracle/hindsight selection | ||
| - Score-first: every token scored before any table update using that token | ||
|
|
||
| ## Reproduction | ||
|
|
||
| ```bash | ||
| RUN_ID=seed1337 SEED=1337 NGRAM_ENABLED=1 NGRAM_ORDER=7 \ | ||
| DATA_PATH=./data/datasets/fineweb10B_sp1024/ \ | ||
| TOKENIZER_PATH=./data/tokenizers/fineweb_1024_bpe.model \ | ||
| VOCAB_SIZE=1024 VRL_ENABLED=1 \ | ||
| torchrun --standalone --nproc_per_node=8 train_gpt.py | ||
| ``` | ||
|
|
||
| ## Credits | ||
|
|
||
| - N-gram backoff approach: PR #727 by @Asukabot0 | ||
| - Neural base: PR #414 by @signalrush | ||
| - LeakyReLU²: PR #493 by @parinzee, PR #518 by @sofiabod | ||
| - VRL: ResFormer (arXiv:2410.17897), PR #569 by @gowtham0992 | ||
| - XSA: PR #287 by @jfprincz |
14 changes: 14 additions & 0 deletions
14
records/track_10min_16mb/2026-03-26_NgramBackoff_VRL_LeakyReLU2/submission.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "name": "NgramBackoff_VRL_LeakyReLU2", | ||
| "author": "Anthony Maio", | ||
| "github_id": "anthony-maio", | ||
| "track": "10min_16mb", | ||
| "num_gpus": 8, | ||
| "gpu_type": "H100 SXM", | ||
| "training_time_seconds": 600, | ||
| "val_bpb": 0.9642, | ||
| "val_loss": 1.6279, | ||
| "bytes_total": 15953596, | ||
| "bytes_code": 67048, | ||
| "blurb": "11L LeakyReLU(0.5)^2 + VRL + lzma + Multi-order N-gram Backoff (2-7gram, entropy-adaptive alpha, 4M hash buckets). 3-seed mean 0.9642, std 0.0002." | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes_totalappears inconsistent with the script’s own size accounting (it logs total = bytes_model + bytes_code). Given bytes_code=67048, bytes_total should match the generated artifact size from the run logs; please recompute/update this field so it reflects the actual submission size used for the 16MB cap checks.