Skip to content

fix(ezpz): sync attn_gym deferral from main (#5565); document 30B infeasible on current frameworks - #76

Merged
saforem2 merged 17 commits into
ezpzfrom
ezpz-grain-sft-cot
Nov 12, 2026
Merged

saforem2 merged 17 commits into
ezpzfrom
ezpz-grain-sft-cot

Conversation

@saforem2

@saforem2 saforem2 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

30B was OOM at every scale with activation_checkpoint_mode=none:

  • Sunspot 2N/4N UR_RESULT_ERROR_OUT_OF_RESOURCES (12482796/830)
  • Aurora 8N/96 GPU CCL scaleout_device_buf malloc fail (9053526)

Tried gating 30B to selective (DefaultActivationRematConfig):
Aurora 8N selective 9053611 E 143 — same torch_remat 0.2.0 bomb as
full:

_placeholder.py:101 torch._C._set_storage_data_ptr_access_error_msg
AttributeError: module 'torch._C' has no attribute ...

Both FullActivationRematConfig and DefaultActivationRematConfig
go through torch_remat on aurora_frameworks-2026.1.0 (torch
2.13). 30B stays infeasible until frameworks pins a compatible
torch_remat; keep none and document.

This PR now only lands the attn_gym.py sync from main (pytorch#5565,
3ed5aa9) — defers cutlass backend miss to _MissingKernel instead
of hard-failing torchtitan.models.common import. Branch was 124
commits behind main.

4B/10B finite-loss unchanged: 9044494 13.98, 9053490 14.62,
12482791 13.24, 12482795 14.67.

Summary by Sourcery

Improve optional Attention Gym compatibility and add data-mixture training paths while documenting current 30B and MMLU evaluation limitations.

New Features:

  • Add AuroraGPT training configurations for token-weighted Open Web Math/FineWeb-Edu mixtures and raw OLMo-mix streaming, including reproducible shard manifests.
  • Defer missing Attention Gym backend failures until kernel use while preserving clear backend-specific errors and keeping model imports available.

Bug Fixes:

  • Update Attention Gym dependency handling to distinguish absent packages or internal modules from unavailable optional backends.
  • Update Attention Gym integration and compatibility aliases for current model attention configuration APIs.

Enhancements:

  • Revise CPT configuration to use the Grain data-mixing pipeline and a 60/40 Open Web Math/FineWeb-Edu training arm.
  • Add extensive coverage for missing, mixed, lazy, and backend-specific Attention Gym imports.

Documentation:

  • Document the infeasibility of 30B training with current framework activation-rematerialization options.
  • Document MMLU letter-prior limitations and revise promotion guidance to avoid gating on MCF MMLU.
  • Document the FineWeb-Edu 60/40 corpus shift as a proposed pre-training direction and its supporting evidence.

Tests:

  • Expand optional-import tests across supported model configurations and Attention Gym backend failure modes.

Chores:

  • Adjust the FineWeb-Edu CPT launcher for the revised training configuration, resource layout, and execution parameters.

Full (torch_remat 0.2.0 on aurora_frameworks-2026.1.0) hits
_set_storage_data_ptr_access_error_msg bomb; none OOMs at 30B
even at 8N (9053526 CCL scaleout_device_buf malloc fail).
Selective (DefaultActivationRematConfig, model-declared regions)
uses a different torch_remat path and may fit within XPU
memory. 4B/10B stay on none (already finite-loss).
Branch was 124 commits behind main; attn_gym.py predated
3ed5aa9 which defers backend ImportError from
attn_gym.linear._lazy (causal_conv1d via cute.py:26 import
cutlass) to a _MissingKernel placeholder. Without it, any
import of torchtitan.models.common — including
torchtitan.experiments.ezpz.agpt.config_registry via
agpt/__init__.py:36 — hard-fails on macOS where attn-gym
0.0.17 is installed but cutlass is absent. Aurora (Intel XPU
via aurora_frameworks-2026.1.0 / oneAPI, no CUDA) was never
affected — its XPU path does not hit cutlass the same way and
all 4B/10B jobs reached Training starts at step 1. Bring file
verbatim from origin/main.
Copilot AI balanced review requested due to automatic review settings November 9, 2026 15:13
@sourcery-ai

sourcery-ai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Extend the Attention Gym facade to defer missing optional-backend failures while retaining backend-specific errors and placeholders.

  • torchtitan/models/common/attn_gym.py L124-146, L152-200, L207-254 (+4 small edits)

Uses of the API

Update attention callers to recognize deferred placeholders and require the exports they use when building attention modules.

  • torchtitan/models/common/attention/cp_gdn.py L20, L45-54
  • torchtitan/models/common/attention/cp_kda.py L19, L44-50
  • torchtitan/models/common/attention/cp_linear_attention.py L27-75, L142-145 (+2 small edits)
  • torchtitan/models/common/attention/gdn.py L27-303 (5 small edits)
  • torchtitan/models/common/attention/kda.py L22-178 (5 small edits)
  • torchtitan/models/common/attention/linear_attention.py L23, L32

Implementation

Add a reproducible manifest builder that selects raw OLMo-mix shards in DP-compatible counts and can shuffle their order.

  • torchtitan/experiments/ezpz/scripts/build_olmo_mix_manifest.py L1-99

Configuration

Add Grain-based data-mixture and raw OLMo-mix training configurations, restore the debug streaming recipe, and disable the unsupported science-source blend builder.

  • torchtitan/experiments/ezpz/agpt/config_registry.py L969-1014, L1042-1055, L1792-1845 (+3 small edits)

Revise the FineWeb-Edu CPT launcher for the 60/40 mix, PPN=8 layout, and explicit MDS base path.

  • torchtitan/experiments/ezpz/scripts/cpt_fineweb_edu_4n.sh L4-23, L76-82 (+2 small edits)

Allow callers to override the B2v2 SFT checkpoint directory rather than always writing to the default epoch-based path.

  • torchtitan/experiments/ezpz/rl/scripts/sft/agpt2b_b2v2_distill_cot_2n.sh L75

Add per-seat Aurora job submission and preserve the umbrella PBS launch configuration.

  • torchtitan/experiments/ezpz/submit/aurora/seat-autoretry-20261111.pbs L1-736
  • torchtitan/experiments/ezpz/submit/aurora/submit-seats-20261111.sh L1-51
  • torchtitan/experiments/ezpz/submit/aurora/umbrella-2088n-20261109.pbs L1-720

Documentation

Record the MMLU letter-prior findings and explain why MCF MMLU should not gate agpt-2B promotion.

  • torchtitan/experiments/ezpz/docs/evals/README.md L11-12
  • torchtitan/experiments/ezpz/docs/evals/mmlu-letter-prior-at-chance.md L333
  • torchtitan/experiments/ezpz/docs/evals/mmlu-letter-prior-gating.md L1-190

Document the proposed FineWeb-Edu 60/40 corpus shift, its supporting results, and related production SFT guidance.

  • torchtitan/experiments/ezpz/docs/production/sft/README.md L3-4, L85, L101-105
  • torchtitan/experiments/ezpz/docs/production/sft/fineweb-edu-60-40-kind-shift.md L1-264

Record the 2088-node umbrella failure, per-seat resubmission, and updated production status.

  • torchtitan/experiments/ezpz/docs/journal.md L3-30
  • torchtitan/experiments/ezpz/docs/production/2026-11-11-umbrella-2088n.md L1-228
  • torchtitan/experiments/ezpz/docs/production/README.md L58-67

Tests

Cover missing Attention Gym packages, backend imports, lazy exports, mixed backend availability, and attention-module build failures.

  • tests/unit_tests/cpu/models/common/test_optional_imports.py L241-674 (+3 small edits)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="torchtitan/models/common/attn_gym.py" line_range="259" />
<code_context>
-def require_attn_gym() -> None:
-    if _load_module("attn_gym") is None:
-        _raise_missing()
+def require_attn_gym(kernel: object, *kernels: object) -> None:
+    """Raise unless every given export imported.
+
</code_context>
<issue_to_address>
**GDN and KDA construction fails**

When a model constructs a GDNKernel or KDAKernel, `GDNKernel.__init__` and `KDAKernel.__init__` call `require_attn_gym()` without arguments, so the required `kernel` parameter raises `TypeError` before the backend check runs, and model construction fails.

Pass the required kernel exports to both calls, or make the argument optional while preserving the intended backend check.

Also at `torchtitan/models/common/attn_gym.py:260`.
</issue_to_address>

### Comment 2
<location path="torchtitan/models/common/attn_gym.py" line_range="146" />
<code_context>
     raise ModuleNotFoundError(
         "Attention Gym kernels require attn_gym. "
-        "Install it with: python -m pip install 'attn-gym[linear,cudnn]==0.0.16'.",
+        "Install it with: python -m pip install 'attn-gym[linear,cudnn]==0.0.17'.",
         name="attn_gym",
     )
</code_context>
<issue_to_address>
**Optional-import tests fail**

When the CPU optional-import tests exercise a missing Attention Gym package, the missing-package error recommends attn-gym 0.0.17, while the tests still assert that it recommends 0.0.16, so the assertions fail and the test suite is blocked.

Update the optional-import test assertions to expect the new 0.0.17 recommendation.

Also at `torchtitan/models/common/attn_gym.py:147`.
</issue_to_address>

### Comment 3
<location path="torchtitan/models/common/attn_gym.py" line_range="182" />
<code_context>
+    if kernel is None:
+        kernel = type(
+            f"_MissingKernel[{key}]",
+            (_MissingKernel,),
+            {"__module__": __name__, "_error": _BACKEND_ERRORS[key]},
+        )
</code_context>
<issue_to_address>
**Missing backend reaches SPMD registration**

When an Attention Gym export is replaced with a backend-missing placeholder, `_missing_backend_kernel()` creates a subclass of `_MissingKernel`, but the attention-module registration guards compare by exact identity, so they pass the placeholder to `register_local_autograd_function` as a real kernel, defeating deferred backend handling and risking SPMD processing failures.

Update the attention-module registration guards to recognize `_MissingKernel` subclasses as missing placeholders rather than real kernels.

Also at `torchtitan/models/common/attn_gym.py:183`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread torchtitan/models/common/attn_gym.py Resolved
Comment thread torchtitan/models/common/attn_gym.py Resolved
Comment thread torchtitan/models/common/attn_gym.py Resolved
30B 8N selective (9053611, E 143) hits the same
_set_storage_data_ptr_access_error_msg bomb as full:

  _placeholder.py:101 torch._C._set_storage_data_ptr_access_error_msg
  AttributeError: module torch._C has no attribute ...

Both DefaultActivationRematConfig and FullActivationRematConfig
go through torch_remat 0.2.0 on aurora_frameworks-2026.1.0
(torch 2.13). 30B stays infeasible until frameworks pins a
compatible torch_remat. Keep 30B on none and document the
failure; keep attn_gym pytorch#5565 sync.
@saforem2 saforem2 changed the title fix(ezpz): gate 30B v2 4K to selective remat + sync attn_gym deferral fix(ezpz): sync attn_gym deferral from main (#5565); document 30B infeasible on current frameworks Nov 9, 2026
Add agpt_v2_{4b,10b}_4k_olmo_mix, which stream the raw olmo-mix-1124 JSON
shards listed in $AGPT_V2_DATA_MANIFEST through the Grain HF streaming
source, and build_olmo_mix_manifest.py, which sizes that list to a multiple
of the DP world size so split_dataset_by_node assigns whole files per rank.
…is_missing_kernel in callers

Sourcery flagged that only attn_gym.py was synced from main (pytorch#5565);
its callers still did bare require_attn_gym()/identity checks that
TypeError'd or leaked placeholders into SPMD registration when
cutlass/triton absent. Pull the companion 4 files from main and add a
compat shim for the renamed prepare_cp_linear_attention_metadata.

Co-Authored-By: internal-model
Subagent fanout: FineWeb-Edu 60/40 kind-shift proposal (SmolLM2
33.6% @38B vs current 94.8% DCLM monoculture) + MMLU letter-prior
gating appendix (constant-D 0.2689 > all 2B 0.2413-0.2655 is harness
prior). 5 files (2 new + 3 updated indexes), no compute.

Co-Authored-By: internal-model
12483035 failed: world_size 60 (5xPPN12) 11008%60!=0 FSDP uneven sharding
plus missing MDS_ANNEAL_BASE on Sunspot (~/torchtitan has no outputs/,
lives on TEGU at .../projects/saforem2/.../step-0). Fix: select=4
PPN=8 -> 32r (11008%32==0), export MDS_ANNEAL_BASE to TEGU path.
Adds agpt_2b_mds_mix_owm_edu_6040 (SmolLM2 60/40 FWE/DCLM stage-1).

Co-Authored-By: internal-model
@saforem2
saforem2 force-pushed the ezpz-grain-sft-cot branch 2 times, most recently from 8026ad8 to 07fdd23 Compare November 10, 2026 00:14
HFDataSource/InterleavedHuggingFaceTextDataLoader deleted in pytorch#4088;
previous mix builders always crashed. Port to GrainDataLoader
(DatasetMix after ConcatThenSplitPacking) so weights count packed
8192-token rows (token-weighted). Adds agpt_2b_mds_mix_owm_edu_6040
(SmolLM2 60/40). CPT script already switched to PPN=8 and
MDS_ANNEAL_BASE TEGU path (prior 12483035 failed on both).

Co-Authored-By: internal-model
saforem2 and others added 9 commits November 10, 2026 00:27
Placeholder 9053470 (select=2088, 24h) ran 4h26m — a single GPU fatal
error (grf_fatal_singlesubslice_error on x4415c5s5b0n0, 10B slice) made
PBS kill the whole 2088N job and all four seats. 20B-512 hung after
10854 (watchdog restart, no new ckpt), 20B-256 saved step-21100, 4B
saved step-2600, 10B at 768N never trained (step-1 loss 17788+).

Resubmitted as one PBS job per seat (seat-autoretry-20261111.pbs +
submit-seats-20261111.sh): 10B moved 768N->512N, HF cache on /tmp.
Umbrella PBS retained for provenance. Journal + PROD/README updated.

Co-Authored-By: internal-model
ufmt on config_registry and cp_linear_attention, license header on
build_olmo_mix_manifest, spell out FW-Edu and 'reused' for codespell.
split_dataset_by_node gives rank r files r, r+dp, ..., so a sorted manifest
feeds the subsets in path order. The builder now writes a seed-0 shuffle by
default. The 10B seat defaults to olmo-mix-dp6144-shuf0.txt; the 4B stays on
the sorted file it resumes from.
Port upstream's require_attn_gym calls for ContextParallelInnerKDA and
ContextParallelInnerGDN. Without them the four context-parallel cases in
test_optional_imports.py (copied from upstream on this branch) built
successfully with a missing backend and failed.
…t2b-cpt17000-gsm8k-3ep not default ep3 (avoids clobbering ckpt93 B2)
# Conflicts:
#	torchtitan/experiments/ezpz/agpt/config_registry.py
#	torchtitan/experiments/ezpz/docs/production/sft/README.md
@saforem2
saforem2 merged commit 959b851 into ezpz Nov 12, 2026
6 checks passed
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