Skip to content

Debug Numerics with DebugMode - #3323

Merged
yushangdi merged 5 commits into
mainfrom
sy_debug_mode
May 22, 2026
Merged

yushangdi merged 5 commits into
mainfrom
sy_debug_mode

Conversation

@yushangdi

@yushangdi yushangdi commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary: DebugMode-Based Numerics Debugger

Overview

Example output:

llama3: https://www.internalfb.com/intern/px/p/9N1sk/
qwen3: https://www.internalfb.com/intern/px/p/9N2ph/

Screenshot 2026-05-12 at 2 33 05 PM

This PR adds a DebugMode-backed numerics debugger for TorchTitan training runs. It introduces a --profiler.dump_numerics flag that captures per-op activation metadata during a selected training step and a torchtitan.tools.compare_numerics CLI that compares two capture logs and writes an interactive HTML diff.

It can be used to compare bit-wise equivalent numerics

  1. between different eager runs
  2. between different traced runs
  3. between eager and traced runs

under the same seed, deterministic settings, precision, and parallelism.

An alternative implementation that uses a standalone activation tracker is at #3190. However, it has some problem with eager code source line tracking. It also doesn't track input hashes and input sources (i.e. which op produced the input). As I add those features, I feel like I'm re-inventing DebugMode, so I just switched back to DebugMode implementation.

I do not expect the default and deterministic matching algorithm to perfectly match all the ops, especially when comparing eager vs traced runs. But agent should do a pretty good job and use manual override to update the visualization.

What Changed

Per-op numerics capture

  • Added torchtitan/tools/activation_tracer.py.
  • Captures per-op output stats:
    • shape and dtype
    • output DebugMode norm hash, L2 norm, min, max, mean
    • input DebugMode norm hashes
    • input producer attribution where available
    • module FQN, source location, and forward/backward phase
  • Uses torch.utils._debug_mode.DebugMode with:
    • record_nn_module=True for eager module attribution
    • record_stack_trace=True for source locations and autograd forward traces
    • record_ids=True for tensor ID based producer tracking
    • DebugMode.log_tensor_hashes(hash_fn="norm", hash_inputs=True) for output and pre-op input hashes
  • Computes tensor stats inline during dispatch instead of retaining tensor clones, keeping memory bounded during capture.
  • For tuple/list outputs, records all output tensor hashes from DebugMode; shape/dtype and secondary stats are taken from the first captureable tensor output.
  • Tracks skipped excluded ops and writes them into the log header so the HTML report can show what was intentionally filtered.

Profiler integration

  • Added Profiler.Config.dump_numerics, exposed as --profiler.dump_numerics.
  • The profiler now builds a NumericsDebugger when numerics dumping is enabled.
  • Capture is aligned with --profiler.profile_freq; for example, --training.steps 2 --profiler.profile_freq 2 captures step 2.
  • Trainer now passes model_parts[0] into the profiler so the debugger can install module hooks needed for FQN attribution.
  • Output path:
{dump_folder}/numerics/rank_{rank}_activations.log

Example log format:


For tuple/list outputs, `Output hash` is comma-separated and includes every
captureable tensor output.
[layers.0._checkpoint_wrapped_module.attention.qkv_linear.wq/op_0_mm]
  Shape: torch.Size([16384, 256]), Dtype: torch.bfloat16
  L2 norm:  6.348642e+02
  Min:      -1.140625e+00
  Max:      1.242188e+00
  Mean:     -2.894286e-03
  Output hash: 1.038582e+06
  Input hashes: 3.125000e+05, 8.441234e+04
  Input producers: layers.0.attention_norm/op_0__fused_rms_norm;
  Location: torchtitan/train.py:66

Graph trainer support

  • Added FQNInterpreter in torchtitan/experiments/graph_trainer/debug_utils.py.
  • GraphTrainer uses FQNInterpreter only while numerics capture is active.
  • Normal graph-trainer execution stays on the direct gm(*inputs) path when capture is not active.
  • During traced replay, FQNInterpreter restores per-node metadata into context vars so traced captures carry comparable module FQNs, stack locations, and forward/backward phase.

HTML comparison tool

  • Added torchtitan/tools/compare_numerics.py.
  • Parses two activation logs.
  • Matches ops across runs using:
    • manual overrides from --override
    • exact normalized op keys
    • fuzzy op keys with per-module counters stripped
    • stats-based fallback matching
  • Produces a self-contained HTML report with:
    • forward/backward sections
    • match, diff, run1-only, and run2-only filters
    • match-strategy chips
    • output and input hash comparison
    • per-cell relative-diff coloring
    • input-producer hover tooltips
    • skipped-op chips for excluded dispatched ops

Tests

  • Added tests/unit_tests/test_activation_tracer.py.
  • Added tests/unit_tests/test_compare_numerics.py.
  • Added torchtitan/experiments/graph_trainer/tests/test_numerics_debugger_e2e.py and wired it into the 8-GPU graph-trainer integration workflow.
  • Coverage includes capture filtering, FQN cleanup, stack parsing, DebugMode capture behavior, tuple-output hash capture, profiler-driven dumping, traced replay context propagation, log parsing, matching strategies, override handling, input producer rendering, skipped-op rendering, HTML escaping, and an eager-vs-aot_fx_trace Llama3 E2E check with minimum match-quality assertions.

How Phase, Stack Location, and Module FQN Are Determined

The capture path combines DebugMode metadata, graph-trainer FX metadata, and an autograd-node-to-module map. The source depends on whether the op runs in eager or traced replay, and whether it is a forward or backward op.

Mode Phase Phase source Stack location source Module FQN source
Eager Forward No active autograd node, so record_hook labels it forward. DebugMode live dispatch traceback from record_stack_trace=True, filtered to remove torch internals, DebugMode frames, checkpoint plumbing, and interpreter frames. DebugMode current_nn_module_stack from record_nn_module=True; the root model-class prefix is stripped so keys match named_modules() style.
Eager Backward torch._C._current_autograd_node() is non-null, so record_hook labels it backward. DebugMode autograd-saved forward traceback, parsed and filtered. This is available because stack recording enables anomaly metadata without enabling nan checking. _grad_fn_to_module[autograd_node], populated during forward by global module hooks and _record_grad_fn.
aot_fx_trace replay Forward or backward FQNInterpreter reads node.meta["autograd_backward"] and sets _current_phase_override. FQNInterpreter reads node.meta["stack_trace"], parses it, and sets _current_stack_frames. FQNInterpreter reads node.meta["custom"]["module_fqn"] and sets _current_module_name.

The priority order inside DebugModeTracer.record_hook is:

  1. Use context vars set by FQNInterpreter when replaying traced graphs.
  2. Fall back to DebugMode ModTracker for eager forward ops.
  3. Fall back to _grad_fn_to_module for eager backward ops.
  4. Use "<none>" only if no attribution source is available.

How Matching Works in compare_numerics

torchtitan.tools.compare_numerics parses both activation logs into ordered OpEntry lists, then match_entries aligns them with progressively more relaxed passes. Earlier passes claim entries first, and the final HTML keeps first-log order for paired and first-only rows.

  1. Manual overrides: if --override <csv> is provided, each <log1_key>, <log2_key> pair is forced before automatic matching. This handles known structural attribution differences such as activation-checkpoint recompute FQNs, FSDP collective renaming, and layer counter shifts.
  2. Exact key match: compares normalized module_fqn/op_N_opname keys. Normalization strips a leading root class segment like FSDPLlama3Model. so eager DebugMode keys match traced metadata keys.
  3. Fuzzy key match: strips the per-module op counter, so layers.0.feed_forward/op_7_mul can match another layers.0.feed_forward/mul when counters drift between modes.
  4. Stats match: falls back to (op_type, Shape, output_hash), which catches semantically identical ops whose FQN differs across backends.

Once a pair is found, _compute_match_status decides whether it is a match or diff using only shape, output hash, and input hashes. L2/min/max/mean are still shown and colored in the HTML, but they do not drive the match/diff classification because they are secondary summaries of the same tensor.

How _record_grad_fn Attributes Backward Ops to Modules

Backward ops run through the C++ autograd engine, so eager module forward stacks are no longer active when those ops dispatch. To recover module attribution, DebugModeTracer installs global module forward pre/post hooks while capture is armed.

The pre-hook records input grad_fns for the module. Those input nodes define the boundary to the caller or sibling modules.

The post-hook calls _record_grad_fn(output, module_fqn, input_grad_fns). _record_grad_fn walks backward from each output tensor's grad_fn through next_functions:

stack = [output.grad_fn]
visited = set()
while stack:
    fn = stack.pop()
    if fn in visited or fn in input_grad_fns:
        continue
    visited.add(fn)
    if fn not in _grad_fn_to_module:
        _grad_fn_to_module[fn] = module_fqn
    for parent, _ in fn.next_functions:
        if parent is not None and parent not in visited:
            stack.append(parent)

Two details matter:

  • It does not overwrite an existing mapping. Child modules finish their post-hooks before parent modules, so child-owned ops keep the more specific FQN.
  • It still walks through already-mapped nodes. This lets a parent module claim "glue" ops that happen between child modules, such as silu and mul inside a feed-forward block, without taking ownership of the child linear ops.

During backward capture, record_hook looks up the current autograd node in _grad_fn_to_module and uses the mapped FQN for the captured op.

Expected Workflow

+-------------------------------------------------------------+
| 1. Run two comparable training jobs                         |
|                                                             |
| - same seed                                                 |
| - deterministic debug mode                                  |
| - same precision and parallelism                            |
| - `--profiler.dump_numerics`                                |
| - same capture step via `--profiler.profile_freq`           |
+-------------------------------------------------------------+
                              |
                              v
+-------------------------------------------------------------+
| 2. Generate the comparison HTML                             |
|                                                             |
| - run `python -m torchtitan.tools.compare_numerics`          |
| - inspect matched rows, diffs, run-only rows, input hashes, |
|   and producer links                                        |
+-------------------------------------------------------------+
                              |
                              v
+-------------------------------------------------------------+
| 3. Triage the comparison                                    |
+-------------------------------------------------------------+
        |                         |                         |
        v                         v                         v
+----------------------+  +----------------------+  +----------------------+
| 3a. Real discrepancy |  | 3b. Bad match        |  | 3c. Numerics match   |
|                      |  |                      |  |                      |
| - fix implementation |  | - ask agent for      |  | - done              |
| - recapture runs     |  |   override pairs     |  |                      |
|                      |  | - regenerate HTML    |  |                      |
+----------------------+  +----------------------+  +----------------------+
        |                         |
        |                         |
        v                         v
   back to step 1            back to step 2

Manual overrides use this format:

# Format: <first_log_key>, <second_log_key>
feed_forward/op_0_silu, layers.5.feed_forward/op_2_silu
layers.0/op_1_add, layers.0/op_0_add
tok_embeddings/op_0__allgather_base_, tok_embeddings/op_1_all_gather_into_tensor_out
layers.0/op_1__allgather_base_, layers.0.attention_norm/op_1_wait_tensor

An example override CSV is available at P2321486470. It covers activation-checkpoint recompute pairings, layer-level counter shifts, and FSDP collective renaming/lowering, including traced wait_tensor rows for synchronized collective results.

This workflow is agent-friendly. In practice, asking an agent to explain discrepancies or batch-generate candidate manual overrides from the two logs usually works well; the reviewer still needs to sanity-check that each override pairs semantically equivalent ops before accepting the regenerated comparison.

Example Usage

The full example script is:

./agent_space/run_numerics_debug_mode.sh

It runs eager and aot_fx_trace captures with the same seed and deterministic settings, then generates an HTML diff.

Eager capture

NGPU=${NGPU:-2}
DP_SHARD=${DP_SHARD:-2}
SEED=42
DUMP_FOLDER=./outputs_numerics_debug_mode

NGPU=$NGPU MODULE=llama3 CONFIG=llama3_debugmodel \
    ./run_train.sh \
    --dump_folder $DUMP_FOLDER/eager \
    --training.steps 2 \
    --profiler.dump_numerics \
    --profiler.profile_freq 2 \
    --debug.seed $SEED \
    --debug.deterministic \
    --parallelism.data_parallel_shard_degree $DP_SHARD \
    --training.mixed_precision_param float32

aot_fx_trace capture

NGPU=$NGPU MODULE=graph_trainer.llama3 CONFIG=graph_trainer_llama3_debugmodel \
    ./run_train.sh \
    --dump_folder $DUMP_FOLDER/traced \
    --training.steps 2 \
    --profiler.dump_numerics \
    --profiler.profile_freq 2 \
    --compile.mode aot_fx_trace \
    --debug.seed $SEED \
    --debug.deterministic \
    --parallelism.data_parallel_shard_degree $DP_SHARD \
    --training.mixed_precision_param float32

For aot_fx_trace, step 1 traces and step 2 replays. Capturing step 2 makes the log represent replay execution, with FQNInterpreter restoring node-level metadata while the traced graph runs.

Generate the HTML diff

python3 -m torchtitan.tools.compare_numerics \
    $DUMP_FOLDER/eager/numerics/rank_0_activations.log \
    $DUMP_FOLDER/traced/numerics/rank_0_activations.log \
    --name1 eager_debug_mode \
    --name2 traced_debug_mode \
    --override agent_space/overrides.csv \
    --output $DUMP_FOLDER/diff.html

The override file is optional. It is useful when eager and traced runs produce semantically equivalent ops with different attribution, such as activation-checkpoint recompute FQNs, FSDP collective renaming, or layer-level op counter shifts.

Expected Outputs

After running the example script:

outputs_numerics_debug_mode/
  eager/numerics/rank_0_activations.log
  traced/numerics/rank_0_activations.log
  diff.html

Open diff.html in a browser to inspect matched ops, diffs, run-only ops, input hashes, and producer links.

Notes for Reviewers

  • The core training path is unchanged unless --profiler.dump_numerics is set.
  • Graph-trainer replay uses FQNInterpreter only while numerics capture is active.
  • The capture uses deterministic settings in the example script and avoids --debug.deterministic_warn_only.
  • The implementation intentionally keeps comparison tooling under torchtitan/tools/ and graph-trainer-specific replay metadata bridging under torchtitan/experiments/graph_trainer/.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 12, 2026
@yushangdi
yushangdi force-pushed the sy_debug_mode branch 2 times, most recently from ddbd5f9 to c092b7a Compare May 12, 2026 17:20
@yushangdi yushangdi changed the title [WIP] Debug Numerics with DebugMode Debug Numerics with DebugMode May 12, 2026
@yushangdi
yushangdi marked this pull request as ready for review May 12, 2026 17:50
@tianyu-l
tianyu-l requested a review from felipemello1 May 12, 2026 20:30
Comment thread torchtitan/trainer.py Outdated
with config.profiler.build(
global_step=self.step,
base_folder=config.dump_folder,
model=self.model_parts[0],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this mean that PP is not supported because there will be multiple model parts?

@yushangdi yushangdi May 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

for now yes. the PR is already kinda long, so I don't want to further complicate it. I can try to extend it to support PP in a follow up PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a TODO in code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you just want to get a union of module_to_fqns, then it's easy to do it here?

@yushangdi
yushangdi force-pushed the sy_debug_mode branch 3 times, most recently from 9f1dc27 to a44a046 Compare May 12, 2026 22:15
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""Compare two numerics activation logs and generate an interactive HTML diff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

didn't read.

this kinda of tool is clearly maintained by agent, and I think titan can have some convention about this.

cc @tianyu-l

@yushangdi yushangdi May 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

my 2 cents about this: indeed this is maintained by agent. But I think still we should commit this code, as it serves as a better starting point than letting the agent start from scratch.

Some features that I iterated on and resulted in this .py file:

  • a not-too-terrible matching algorithms that respects manual override and does some fuzzy matching
  • collapsable/expandable columns when some output tuples are too long
  • regrex search/filter by op name
  • show match method
  • show excluded ops

One proposal: we could create an agent_playground/ folder to put these things. files in this folder cannot be used by any other folder. They must be standalone.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can put it in scripts/ with a README.

Comment on lines +558 to +559
if interpreter_cls is not None:
flat_outputs = interpreter_cls(traced_result.gm).run(*flat_inputs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

interesting... I don't hate this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the interpreter you end up using?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The FQNInterpreter that I added to debug_utils.py.

Comment on lines +8 to +10
- 'torchtitan/tools/activation_tracer.py'
- 'torchtitan/tools/compare_numerics.py'
- 'torchtitan/tools/profiler.py'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to the experiments folder contract, let's not auto-trigger graph trainer CI. Instead, we recommend tagging ci/graph_trainer to jobs that might affect graph trainer.

Comment thread torchtitan/trainer.py Outdated
with config.profiler.build(
global_step=self.step,
base_folder=config.dump_folder,
model=self.model_parts[0],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a TODO in code

# forward post-hook and stash grad_fn -> fqn in _grad_fn_to_module.
# _maybe_record_module_fqn in record_hook reads it during backward.
_grad_fn_to_module.clear()
module_to_fqn = {id(m): name for name, m in self.model.named_modules()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see that you are sending model reference all the way here for getting this dict to insert hooks. Is there a nicer way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can certainly tell how useful it is, but it is certainly not torchtitan's interest to maintain this file.

  • How would you convince people that this shouldn't be in core pytorch or in annex?
  • How much of this file is for graph trainer specific? Maybe there's chance to abstract it out and put in graph_trainer/.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

none of the file is graph trainer specific (well, maybe one could argue that some of the override hooks are graph_trainer specific).

I'm ok with putting it in graph_trainer, but I still want eager to be able use these logging (e.g. so we can compare eager and traced runs). Then we'd need to import this file from graph_trainer folder. Is this ok?

Alternatively, maybe this can live in an annex repo or pytorch core, but it would be less hackable if someone wants to customize the activation tracer while debugging titan.

# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""Compare two numerics activation logs and generate an interactive HTML diff.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can put it in scripts/ with a README.

Comment thread torchtitan/trainer.py Outdated
with config.profiler.build(
global_step=self.step,
base_folder=config.dump_folder,
model=self.model_parts[0],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you just want to get a union of module_to_fqns, then it's easy to do it here?

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Inlined some conclusions we had during meeting. Overall the idea is to give it a try and see how it goes.

Comment thread torchtitan/tools/profiler.py Resolved
@yushangdi
yushangdi force-pushed the sy_debug_mode branch 2 times, most recently from ab93f45 to ac431fa Compare May 19, 2026 22:33
@yushangdi

Copy link
Copy Markdown
Contributor Author

producer_map[tid] = key


class NumericsDebugger:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: does it make sense to rename this to

Suggested change
class NumericsDebugger:
class ActivationTracer:
  • it only captures activation trace, but doesn't do any "debug" work
  • the file name is activation_tracer.py
  • (actually, I didn't review carefully, and didn't understand why there's two layer structure of this class and an attribute DebugModeTracer)

I don't have strong opinion though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to ActivationCaptureProfiler. It wraps DebugModeTracer to plug into torchtitan's Profiler; the split keeps the core tracer decoupled from the profiler integration.

and I also updated to move some .md files to the .claude/skills folder as @felipemello1 suggests.

@felipemello1

felipemello1 commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

sorry, i took a quick look at how the files are organized. Would it be better to organize it as a skill? take a look at how OpenEnv has it: https://github.com/meta-pytorch/OpenEnv/tree/main/.claude/skills/generate-openenv-env

  • The skill has a short description
  • The skill itself is short and points to a larger doc

This is how anthropic recommends building it: https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview#skill-structure

@yushangdi
yushangdi merged commit 19c567f into main May 22, 2026
22 of 23 checks passed
saforem2 added a commit to saforem2/torchtitan that referenced this pull request May 24, 2026
Merged 1 upstream commit (19c567f, PR pytorch#3323): pure tooling
addition under torchtitan/tools/numerics_debugging/ plus a
.claude/skills/numerics_debugging/ skill. No code path ezpz
exercises changed; no replay needed.

Also appends today's journal entry with the 39th-sync note and a
closing follow-up on PR #184767 (closed in favor of upstream
pytorch/pytorch#183625, per @frost-intel's review comment).
jialei777 pushed a commit to jialei777/torchtitan that referenced this pull request Oct 19, 2026
… commit `659a0d`).

This CL imports TorchTitan head and stabilizes the build. Supporting feature gaps to be done in follow-up CLs. **For a summary of major changes and disabled tests see [internal link]**

In this CL, we bypass the [ban](https://github.com/pytorch/torchtitan/blob/1c40dd26a91b0489249011a53d1da69061b03d38/torchtitan/models/common/config_utils.py#L85) of SDPA backend for language models in `models/common/config_utils.py` so our monkey patch to apply splash attention kernel works. Deprecation of sdpa backend on TPU and supporting document packing in the SplashAttention kernel is handled in child cl/954755047

In OSS, torch>=2.12 is **required**. After this update several files import `DataParallelMeshDims` from `torch.distributed.fsdp` which is only available in torch >=2.12

It disables the following tests:

b/540005818 Disabled for numerical divergences:
- test_train_minimal_distributed llama3_fsdp
- test_train_minimal_distributed llama3_simplefsdp
- test_train_minimal_distributed qwen3_simplefsdp
- test_flux_qkv_split TestFluxSingleStreamUnbind

Disabled for other reasons:
- b/540119277 test_fused_swiglu_override - circular import issue with spmd_type
- b/540048441 graph trainer tests (upstream refactored trace_train_step into minimal_fx_tracer API):
- b/540049946 deepseek_v3_tp_dtensor - Linear: output DTensor has placements (Shard(dim=1),), but out_src_shardings expects (Shard(dim=2),)

Tested on OSS with image built from torch 2.12:
- redacted SimpleFSDP Compiled: [10,925 TPS]([internal link]) (10,0922 at head)
- FLUX SimpleFSDP Compiled (F32 + BF16 MP): [3,737 TPS]([internal link]) (3652 at head)
- Llama3 SimpleFSDP Compiled: [5,444 TPS]([internal link]) (5384 at head)

See the list of commits: pytorch/torchtitan@627126f...659a0d2

#MIGRATION_3P_PY_TORCHTITAN__DEFAULT

  - 95ae6a0 ci: regenerate qwen3_moe_rocm_mi350x.txt baseline with ac... by Rishi Sinha <[email protected]>
  - db5da4b Refactor pipeline parallel helpers for graph PP reuse (#2... by sanketpurandare <[email protected]>
  - 6065055 Revert precompile PRs (pytorch#3107, pytorch#3178) to fix CI (pytorch#3212) by Bob Ren <[email protected]>
  - 179d9e1 CP AllGather on the wrong dimension (pytorch#3206) by francesco-bertolotti <[email protected]>
  - f522db0 Fix commands in DSV3 readme (pytorch#3116) by Daniel Vega-Myhre <[email protected]>
  - 0b148a2 [CI] Run integration tests in parallel (pytorch#3144) by Yuankai Chen <[email protected]>
  - 080c1d4 [GraphTrainer] Annotate loss region with module_fqn (pytorch#3207) by Sherlock Huang <[email protected]>
  - b2cd149 Observability: structured logging + training instrumentat... by Felipe Mello <[email protected]>
  - 706ed8d [GraphTrainer] Annotate generated FX code with user sourc... by Aditya Venkataraman <[email protected]>
  - af8d243 [GraphTrainer] Skip identity-slice rewrite when start/end... by Aditya Venkataraman <[email protected]>
  - d3c96e8 [mxfp8] Fix MXFP8GroupedExpertsConverter to actually swap... by Aditya Venkataraman <[email protected]>
  - d341407 [MoE] Pad token count to a multiple of sp_size in AllToAl... by Jiani Wang <[email protected]>
  - 2ae1340 [rl] add import torch to provisioner bootstrap to avoid c... by Shuhua Yu <[email protected]>
  - 0b6a29e [rl] Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True... by Felipe Mello <[email protected]>
  - 2c237ae refactor get_attention_masks to use positions instead of ... by liangel-02 <[email protected]>
  - 74bac7e [graph_trainer] FSDP AG RS overlap (pytorch#3156) by Yiming Zhou <[email protected]>
  - b6830b2 Upgrades torchtitan-ubuntu docker image to 22.04 and CTK ... by Syed Tousif Ahmed <[email protected]>
  - 5fa7af6 [float8] Quantize GroupedExperts params during conversion... by Aditya Venkataraman <[email protected]>
  - e62ab09 [rl] Fix CI loss=0 and logprob=NaN (pytorch#3232) by Jiani Wang <[email protected]>
  - f32a5bb [GraphTrainer] Overhaul README for accuracy and clarity (... by Sherlock Huang <[email protected]>
  - e425316 [rl] Remove VLLMGenerator.__del__ cleanup method (pytorch#3224) by Danielle Pintz <[email protected]>
  - ef54395 [graph_trainer] Move all FSDP-specific passes to fsdp_pas... by Yiming Zhou <[email protected]>
  - 301384b [GraphTrainer] Register BlockMask pytree node in aot_fx_t... by Bob Ren <[email protected]>
  - a24b247 [graph_trainer] Disable cpu_offload_all CI test for upstr... by Sherlock Huang <[email protected]>
  - 2dfee86 [GraphTrainer] Update manifesto: hardware heterogeneity, ... by Sherlock Huang <[email protected]>
  - c6cfaa2 Re-land "Enable bucketing pass in precompile path" (pytorch#3107... by Bob Ren <[email protected]>
  - ae5ff10 [cpu-offloading] Implement prefetching for cpu offloading... by Michael Lazos <[email protected]>
  - 046fdbb Support mark_unbacked in minimal_fx_tracer (pytorch#3046) by Tugsbayasgalan Manlaibaatar <[email protected]>
  - 8599818 [rl] Add a tag to trigger RL CI runs (pytorch#3230) by Jiani Wang <[email protected]>
  - 466da8c [graph_trainer] Port remat_using_tags_for_fwd_loss_bwd_gr... by Sherlock Huang <[email protected]>
  - 94d5f59 Re-land "Fix FlexAttention precompile bitwise determinist... by Bob Ren <[email protected]>
  - e2fea3f Wrong token count in validation when CP>1 (pytorch#3257) by francesco-bertolotti <[email protected]>
  - 1d392ca [torchtitan][llama4_parallelize] fixing fsdp_mesh_info bu... by anshul-si <[email protected]>
  - d91a9fc [Qwen3VL] remove local_map for dtensor interpolation (pytorch#29... by Shuhua Yu <[email protected]>
  - 19f88a3 profiler: drop duplicate dataclass fields (pytorch#3227) by Felipe Mello <[email protected]>
  - 52f3142 [GraphTrainer] Log graph pass names and total time (pytorch#3261) by Sherlock Huang <[email protected]>
  - bf2842d [GraphTrainer] Add memory policy registry and extra graph... by Syed Tousif Ahmed <[email protected]>
  - 4ebb089 Tests HybridEP integration with GraphTrainer (pytorch#3184) by Syed Tousif Ahmed <[email protected]>
  - da6ff79 [rl] Graceful shutdown GRPO (pytorch#3238) by Felipe Mello <[email protected]>
  - 54887a3 [GraphTrainer] Add compile.disable_passes to selectively ... by Sherlock Huang <[email protected]>
  - 4ed3c53 [codex] Fix weight tying parameter accounting (pytorch#3225) by 岛石 <[email protected]>
  - 5638c49 [codex] Fix shared BOS and EOS token inference (pytorch#3279) by 岛石 <[email protected]>
  - ecd117e [graph_trainer] Pass global_valid_tokens into loss_fn ins... by Yidi Wu <[email protected]>
  - 0fae167 [graph_trainer] AutoParallel AOT FX Trace Integration (#2... by sanketpurandare <[email protected]>
  - 74181b1 [LoRA] Add LoRA converter and rename quantization to conv... by Yifan Mao <[email protected]>
  - 0d8f57c Remove unnecessary clone from ChunkedCELoss (pytorch#3272) by Jiani Wang <[email protected]>
  - 28b83bd Merge lora and float8 tests (pytorch#3310) by Yifan Mao <[email protected]>
  - e917ff4 Avoid repeat_interleave output-size sync (pytorch#3274) by Simon Fan <[email protected]>
  - acece3b [graph_trainer] Disable flexattn integration test due to ... by Sherlock Huang <[email protected]>
  - 8ba1c6b Support kwargs in minimal_fx_tracer (pytorch#3262) by Tugsbayasgalan Manlaibaatar <[email protected]>
  - d107aa4 [Quantization] Use class factory for MXFP8/Float8 Grouped... by Yifan Mao <[email protected]>
  - ca4c7f2 [rl] Register customized config parser to vllm + less vll... by Jiani Wang <[email protected]>
  - 0b5e899 Fix precompile tests (pytorch#3316) by Tugsbayasgalan Manlaibaatar <[email protected]>
  - 0fadde3 [graph_trainer] Fix AutoParallel input_fn to include posi... by Ivan Kobzarev <[email protected]>
  - 2ceff82 [graph_trainer] Add log_timer utility for tracing step ti... by Sherlock Huang <[email protected]>
  - e9dbff6 [graph_trainer] Refactor selective activation remat to in... by Tugsbayasgalan Manlaibaatar <[email protected]>
  - b301dfa Remove MoE expert for-loop fallback (pytorch#3308) by sanketpurandare <[email protected]>
  - 1a0fe3e [graph_trainer] Refactor passes.py into focused modules (... by Sherlock Huang <[email protected]>
  - d57df09 Make ChunkedCELoss support torch.autograd.grad (pytorch#3249) by Yidi Wu <[email protected]>
  - 5ca23a5 [GraphTrainer] Add Context Parallel support (pytorch#3305) by Aditya Venkataraman <[email protected]>
  - 7f070c9 Enhance Lychee Link Checker (Resiliency & Performance) (#... by Andrei-Aksionov <[email protected]>
  - 7f602b9 Add AGENTS.md symlinks for Codex usage (pytorch#3326) by sanketpurandare <[email protected]>
  - 34801c0 [graph_trainer] Improve SAC tagging and CPU offload pass ... by Sherlock Huang <[email protected]>
  - 1a22c2d [graph_trainer] Remove deprecated AOT compile mode (pytorch#3327) by Sherlock Huang <[email protected]>
  - 7b418ab Revert "Avoid repeat_interleave output-size sync (pytorch#3274)"... by Simon Fan <[email protected]>
  - 6f2fa2f [rl] switch to vllm v2 engine (pytorch#3330) by Jiani Wang <[email protected]>
  - 1690e0a [cpu-offloading] Encode last consumer as dep arg in ao.wa... by Michael Lazos <[email protected]>
  - cee4982 [graph_trainer] Fix SAC remat to produce fresh FakeTensor... by Ivan Kobzarev <[email protected]>
  - d4a3c63 [graph_trainer] Generalize minimal_fx_tracer to module + ... by Tugsbayasgalan Manlaibaatar <[email protected]>
  - 4614e30 [graph_trainer] Support multiple FSDP PGs in overlap_fsdp... by Sherlock Huang <[email protected]>
  - 3781d1d Back out "[graph_trainer] Fix SAC remat to produce fresh ... by Sherlock Huang <[email protected]>
  - a2a0d99 RL: observability spans across trainer/generator/controll... by Felipe Mello <[email protected]>
  - 8cdfdc2 [rl] Better initial weight loading (pytorch#3318) by Jiani Wang <[email protected]>
  - f0795f0 [RL] - Enable experiment metrics (pytorch#3237) by Felipe Mello <[email protected]>
  - b64292b [graph_trainer] Remove fsdp_reshard_after_fwd_pass (pytorch#3370) by Sherlock Huang <[email protected]>
  - a670699 [graph_trainer] Skip dense numerics tests due to upstream... by Sherlock Huang <[email protected]>
  - cb7bf09 ci: declare workflow-level `contents: read` on 2 workflow... by Arpit Jain <[email protected]>
  - d64eabc [Full DTensor] Config-based Full DTensor for Llama3 (pytorch#3159) by Chien-Chin Huang <[email protected]>
  - a866d04 Fix memory snapshot pickle protocol for compatibility wit... by francesco-bertolotti <[email protected]>
  - 9f9ae4d [graph_trainer] Fix H100 CI failure from DeepEP compilati... by Sherlock Huang <[email protected]>
  - c9126af [graph_trainer] Add bucketing ops to precompile serializa... by Ivan Kobzarev <[email protected]>
  - 013890b [graph_trainer] Defer cudagraph compatibility check to pa... by Ivan Kobzarev <[email protected]>
  - 6a1b334 Fix optimizer state and module state coupling (pytorch#3356) by Tugsbayasgalan Manlaibaatar <[email protected]>
  - 4238c35 Re-enable compile for gpt-oss integration tests (pytorch#3373) by Aditya Venkataraman <[email protected]>
  - ebfceeb [rl] Add TITO generator and gen metrics (pytorch#3391) by Felipe Mello <[email protected]>
  - cf3c431 [graph_trainer] Re-enable FlexAttention tests after upstr... by Sherlock Huang <[email protected]>
  - 8aa96ac [graph_trainer] Fix eager SAC policy mm counter to reset ... by Ivan Kobzarev <[email protected]>
  - 52a292d [graph_trainer] Gate overlap_fsdp_ag_rs_pass behind a con... by Yiming Zhou <[email protected]>
  - 2057b56 [rl] fix CI timeout issue by properly tear down for vllm ... by Jiani Wang <[email protected]>
  - cfe97c6 [rl] use wandb=False in CI (pytorch#3408) by Felipe Mello <[email protected]>
  - 83e4904 [graph_trainer] Rework full_inductor_compilation_pass via... by Tugsbayasgalan Manlaibaatar <[email protected]>
  - 963c20c [MoE][5/n] Refactor MoE to clean DTensor boundaries for s... by Jessica Zhong <[email protected]>
  - da38566 [MoE][6/n] Extract local_reorder, split DeepEP/HybridEP d... by Jessica Zhong <[email protected]>
  - 3f721b4 [graph_trainer] Fix fsdp_passes compat with BitsetAncesto... by Ivan Kobzarev <[email protected]>
  - b585282 Fix imports for latest DeepEP (pytorch#3414) by Steffen Hirschmann <[email protected]>
  - c2a3771 [loss] Fix ChunkedCELoss + TP gradient placement mismatch... by Chien-Chin Huang <[email protected]>
  - 19c567f Debug Numerics with DebugMode (pytorch#3323) by Shangdi Yu <[email protected]>
  - 78b08dd [graph_trainer] Add DeepSeek V3 16B SDPA config (pytorch#3361) by sanketpurandare <[email protected]>
  - af33f76 [Module] Replace from_nn_module with native Module subcla... by Chien-Chin Huang <[email protected]>
  - 58b0344 Add FSDP symmetric memory configuration and related tests... by Masaki <[email protected]>
  (And 259 more changes)

PiperOrigin-RevId: 956923721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu 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.

5 participants