Skip to content

[graph_trainer] Enable GPT-OSS in GraphTrainer - #5832

Merged
SherlockNoMad merged 1 commit into
mainfrom
SherlockNoMad/gt_gpt_oss
Nov 5, 2026
Merged

SherlockNoMad merged 1 commit into
mainfrom
SherlockNoMad/gt_gpt_oss

Conversation

@SherlockNoMad

@SherlockNoMad SherlockNoMad commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

GPT-OSS (attention sinks, sliding-window attention, biased grouped experts)
has no GraphTrainer model class, so it cannot train through GraphTrainer's
whole-step trace.

Example.

from torchtitan.experiments.graph_trainer.gpt_oss import build_model_config

# Before: no GraphTrainer GPT-OSS model or flavor builder exists.
# After:
config.model = build_model_config("debugmodel", parallelism=config.parallelism)
# -> GraphTrainerGptOssModel.Config, trains with SimpleFSDP + TP + EP + PP

What changed

  • graph_trainer/gpt_oss/: GraphTrainerGptOssModel and its
    build_model_config. CP raises ValueError until its attention backends
    are validated under GraphTrainer.
  • Test recipes torchtitan_recipes/tests/graph_trainer/gpt_oss.py (Varlen
    and FlexAttention).
  • Bitwise harness classes for Varlen and FlexAttention; 4-GPU numerics configs.
  • README: a new "Supported Models" table listing the models GraphTrainer
    runs today, with GPT-OSS added.

Numerics

Eager FSDP2 vs GraphTrainer, seed 42, deterministic,
scripts/loss_compare.py --assert-equal, base d0ab95e46:

Config GPUs Result
debugmodel, FlexAttention, FSDP2 + TP2 + EP2, 20 steps 4x GB300 loss and grad_norm bitwise identical
debugmodel, FlexAttention, Interleaved1F1B PP2, 10 steps 2x GB300 loss and grad_norm bitwise identical

The 4-GPU comparison uses FlexAttention. On Blackwell, FA4's Varlen backward is
not deterministic for full causal attention (dQ differs run to run even with
deterministic=True; the sliding-window layers are deterministic), so an eager
Varlen run does not reproduce itself.

Testing

  • test_bitwise_deterministic.py::TestGptOssBitwiseDeterministic and
    TestGptOssFlexAttnBitwiseDeterministic (1 GPU): eager vs aot_fx_trace,
    trace vs precompile, and numerics_changing_optim run-to-run produce bitwise
    identical loss, model hash, and gradient hash.
  • test_numerics.py::test_moe_gpt_oss_aot_fx_trace_vs_eager (4 GPUs): the
    FSDP2 + TP2 + EP2 row above.
  • The PP row was run locally; it is not a CI test.

Known issues / follow-ups

  • CP raises ValueError.
  • The 20b and 120b flavors build through the same build_model_config,
    but only debugmodel is verified. A random-init 20b FSDP4 + EP4 run
    matches eager for 3 steps, then diverges slightly from step 4.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 4, 2026
Add GraphTrainerGptOssModel and its flavor builder so GPT-OSS (attention
sinks, sliding-window attention, biased grouped experts) trains through
GraphTrainer with SimpleFSDP, TP, EP, and PP. CP raises ValueError until its
attention backends are validated under GraphTrainer.

The GraphTrainer README gains a Supported Models table.

The multi-GPU numerics comparison uses FlexAttention: on Blackwell, FA4's
Varlen backward is not deterministic for full causal attention (dQ differs
run to run even with deterministic=True; sliding-window layers are
deterministic), so an eager Varlen run does not reproduce itself.

Testing:
- test_bitwise_deterministic.py::TestGptOss{,FlexAttn}BitwiseDeterministic:
  eager vs aot_fx_trace, trace vs precompile (Varlen), and
  numerics_changing_optim run-to-run are bitwise identical in loss, model
  hash, and gradient hash (GB300).
- test_numerics.py::test_moe_gpt_oss_aot_fx_trace_vs_eager: eager FSDP2 vs
  GraphTrainer with FSDP2+TP2+EP2 on 4 GPUs, loss and grad_norm bitwise
  identical for 20 steps.
- The Varlen GraphTrainer recipe trains 10 steps with FSDP2+TP2+EP2.
- Local: Interleaved1F1B PP2 eager vs GraphTrainer on 2 GPUs, loss and
  grad_norm bitwise identical for 10 steps.
@SherlockNoMad
SherlockNoMad force-pushed the SherlockNoMad/gt_gpt_oss branch from 259b540 to dbe4475 Compare November 4, 2026 23:30
@SherlockNoMad
SherlockNoMad changed the base branch from SherlockNoMad/gt_kimi_k3 to main November 4, 2026 23:30
@SherlockNoMad
SherlockNoMad marked this pull request as ready for review November 4, 2026 23:38
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 4, 2026
@SherlockNoMad
SherlockNoMad merged commit 9d2d9f3 into main Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants