Skip to content

Port the Aurora MoE work onto ezpz, keeping core torchtitan untouched - #17

Merged
saforem2 merged 134 commits into
ezpzfrom
feat/aurora-moe-port
Sep 21, 2026
Merged

saforem2 merged 134 commits into
ezpzfrom
feat/aurora-moe-port

Conversation

@saforem2

@saforem2 saforem2 commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Ports and validates the Aurora MoE work on the ezpz branch while keeping the training implementation under torchtitan/experiments/ezpz/.

aurora_full_sonic is ported and validated on the current TorchTitan stack. The MoE stack retains its DeepSeek-style MLA path, while the AGPT 2B/50K full-Sonic flavor uses GQA; sharding dispatches explicitly between the two attention configurations. The AGPT path builds through the registered JSON factory, trains with EP=12 on Sunspot, and matches a loop reference at DP=2 x EP=2 for outputs and first-order gradients.

Detailed evidence and known constraints:

https://github.com/saforem2/torchtitan/blob/feat/aurora-moe-port/torchtitan/experiments/ezpz/docs/experiments/pr17-moe-merge-readiness.md

Supported expert backends

  • bmm
  • bmm_nodrop
  • grouped_mm
  • for_loop
  • aurora_sycl
  • aurora_full_sonic

The restored production-shaped factory is:

agpt_2b_50k_moe_sdpa_aurora_full_sonic_from_json

Full Sonic currently requires activation checkpointing none; SelectiveAC conflicts with Sonic's nested custom backward. Launch paths continue to use ezpz launch.

Integration fixes

  • restored current-schema dense and full-Sonic AGPT JSON factories;
  • retained the DeepSeek-style MLA sharding path and added explicit GQA dispatch for AGPT MoE;
  • fixed non-square Sonic expert-weight layouts;
  • forwarded padding masks into MoE routing/count and auxiliary-loss semantics;
  • made Sonic fail closed on missing or inconsistent EP topology;
  • narrowed native DDP to supported non-PP, replicated-DP, BF16-autocast scope;
  • bypassed FSDP on native-DDP runs and wrapped only after materialization;
  • propagated launcher and timeout return codes without reporting incomplete runs as successful;
  • made production launch inputs relocatable through validated TT_* overrides;
  • fixed BlendCorpus checkpoint position tracking so resumed training does not replay the first batch;
  • repaired formatting, license headers, spelling, and current documentation links;
  • skipped unavailable PyTorch-hosted GPU jobs for fork PRs while retaining upstream/manual GPU coverage and ordinary lint coverage.

Validation

Local/CPU

135 focused AGPT/MoE/launcher/native-DDP tests passed
9 BlendCorpus layout/checkpoint-state tests passed
17 MLA/GQA registry and sharding tests passed
trainer initialization parity passed
launcher contract tests passed
pre-commit and repository-wide Lychee passed locally

GitHub lint is green. Fork GPU jobs are intentionally skipped because this repository has no access to the PyTorch-hosted runners.

Sunspot XPU

Production full-Sonic smoke — job 12478353, 12 ranks, EP=12:

step 1  loss 11.36224  grad_norm 3.0981
step 2  loss 10.64051  grad_norm 5.0499
Training completed
Exit_status=0

Deterministic numerical/gradient comparison — job 12478371, DP=2 x EP=2:

output max abs diff                 <= 1.53e-05
input-gradient max abs diff         <= 3.05e-05
router-score-gradient max abs diff  <= 5.72e-06
expert-weight-gradient max abs diff <= 1.53e-05
DP replicas                         bitwise identical
Exit_status                         0

The test used non-square D=48/F=80, imbalanced routing, and one empty expert.

Native DCP save/resume — confirmation job 12478383, Exit_status=0:

Three independent ezpz launch processes ran an uninterrupted control, a one-step full-state save, and a fresh process loading step-1 and continuing at step 2:

                         control      resumed      absolute difference
step-2 loss             10.64056     10.64007     0.00049
step-2 gradient norm     5.0449       5.0467       0.0018

The bounds were 0.005 for loss and 0.05 for gradient norm. Save, fresh-process load, resumed backward, and optimizer update all completed. This test exposed and fixed BlendCorpus checkpoint position tracking in 0f7f0c7f5.

Native DDP scope

Native DDP is intentionally limited to AGPT, non-pipeline replicated DP, BF16 autocast over FP32 master parameters/reductions, and one gradient-accumulation step. TP, CP, EP, DP sharding, fault tolerance, CPU offload, seed-checkpoint creation, and custom optimizer parameter groups fail during preflight rather than entering a partially supported path.

A real XPU native-DDP smoke remains useful follow-up evidence but is not on the full-Sonic production path; reducer/update equivalence is covered by a two-rank CPU/Gloo test.

Review notes

  • The vendored aurora_moe implementation is lazily imported; other backends do not require it.
  • No compiled .so files are committed.
  • aurora_sycl requires a coherent Torch/compiler/oneMKL stack and accepts the installed versioned libmkl_sycl_blas.so.* soname.

…ncy inversion

Ports samuelwheeler/torchtitan@653af653 onto current ezpz. Their branch is
2,694 commits behind ours (merge base 2026-05-01, predating the pytorch#4121 token
rename, spmd_types, and the Module.parallelize refactor), so this is a port,
not a merge.

The headline number was misleading: 155 files changed sounds like a large
conflict surface, but 116 are NEW and land clean. Only 39 are modifications,
36 of which overlap files we have touched -- and 23 of those are CORE, which
is what actually needed solving.

THE GATING CHANGE. Their branch has two core -> experiments/ezpz imports,
which invert the dependency and make ezpz un-droppable:

  torchtitan/trainer.py:46                  imports 9 native_ddp symbols
  torchtitan/distributed/pipeline_parallel.py:291  imports NativeDDP

Neither needs an extension point.

  * pipeline_parallel.py: _NativeDDPPipelineStage is a 16-line PipelineStage
    subclass, entirely new (absent from the merge base), referenced only by
    that file and native_ddp.py. Its whole job is unwrapping a NativeDDP
    before metadata inference. Moved next to NativeDDP, where its dependency
    already lives. Verified: both symbols import, bases == [PipelineStage].
    That core import is now gone.

  * trainer.py: the 9 symbols resolve to 7 callsites in exactly three methods
    -- __init__ (3), train_step (2), forward_backward_step (2). We already
    override __init__ and train_step, and our __init__ does not call super()
    at all: it is a 562-line reimplementation that already builds loss_fn and
    gradient_accumulation_steps itself. So 5 of 7 hooks are insertions into
    code we own, and the remaining 2 need one new forward_backward_step
    override. Still zero core changes. Anchors confirmed present in our file.

This commit lands the 116 new files (103 under vendor/aurora_moe_dropin, 8
experiments/ezpz configs + native_ddp.py, 3 unit tests, xpu_phase_timer,
one doc) and the pipeline-stage move. NOTHING outside vendor/, tests/, docs/,
torchtitan/tools/ and torchtitan/experiments/ is touched -- verified by
git status.

Next: wire the 7 trainer hooks into experiments/ezpz/trainer.py, then re-diff
to see what core surface genuinely remains. Not touching core until that
residual is measured and reviewed.
…touched

Wires the hooks their branch put in core torchtitan/trainer.py behind a
module-scope `from torchtitan.experiments.ezpz.native_ddp import ...`. They go
into FaultTolerantTrainer instead, so core never imports from experiments/ezpz.

Five hooks landed (45 lines):
  __init__     validate_native_ddp        after the GAS assert
  __init__     wrap_native_ddp            after parallelize_fn, so it wraps the
                                          already-sharded module
  __init__     install_agpt_dtype_probe   env-gated, after model_parts is set
  train_step   record_native_ddp_grad_streams   before clip_grad_norm_
  (plus the import)

The other two hooks are NOT ported, deliberately. They sit in
forward_backward_step, which we call but do not override, and both are
pipeline-only. All 14 configs on their branch run pp=1, so neither is reachable
for anything they ship. Adding an override on spec would have been dead code --
the same class of thing this repo keeps producing. If a PP config ever appears,
the override is a small, obvious addition.

Every hook is `getattr(..., "enable_data_parallel_native_ddp", False)`, and that
field does not exist in our config yet, so all of this is inert today: verified
against agpt_debugmodel, the attribute is absent and the getattr returns False.
Existing runs cannot change behaviour.

That inertness is also the next decision. The flags have to be declared
somewhere or the feature is unreachable -- their branch adds them to core
config/configs.py (117 lines) plus distributed/parallel_dims.py (110). Whether
those go into core or become an ezpz-local config extension is a call for the
repo owner, not something to settle inside a port.

Residual core surface, measured against the merge base (their changes, not our
drift): pipeline_parallel.py 526 (525 additions, overlapping the class already
relocated in ab24c5c), models/common/moe.py 333, trainer.py 230 of which 51
were native-DDP and are now handled, configs.py 117, parallel_dims.py 110.
The hooks landed in step 2 but were dead: every call site is guarded with
getattr(config.parallelism, "enable_data_parallel_native_ddp", False), and
nothing declared that field, so native DDP was permanently off.

Upstream's Aurora MoE branch declares these five fields on core
ParallelismConfig (117 lines in config/configs.py). We do not need to.
Upstream's hook lives in core torchtitan/trainer.py -- including the
non-PP path at its line 441 `else:` branch, which calls wrap_native_ddp
at 461 -- so core genuinely has to know the fields. Ours were inverted
into experiments/ezpz/trainer.py in step 2, and nothing in core ever
reads them.

So: new experiments/ezpz/config.py with EzpzParallelismConfig, a
ParallelismConfig subclass carrying the five fields our port actually
reads. Field definitions and docstrings are taken verbatim from upstream
so the two stay comparable. disable_degree_one_fsdp and
enable_fsdp_async_all_reduce are omitted -- nothing in our port reads
them, and an unread flag is a promise we would not be keeping.

FaultTolerantTrainer.Config re-declares `parallelism` with the subclass
as its default_factory. tyro builds its CLI from the factory rather than
the annotation (verified), so that alone makes --parallelism.native-ddp-*
parse, with no change to the core field declaration. The subclass passes
isinstance(ParallelismConfig), so every core annotation still accepts it.
slots=True on the parent does not block adding fields in a subclass.

Verified through ConfigManager.parse_args:
  --parallelism.enable-data-parallel-native-ddp  -> True
  --parallelism.native-ddp-bucket-cap-mb=50      -> 50.0
  --parallelism.native-ddp-compute-policy=...    -> set, and a bogus
                                                    value is rejected
  core field (tensor_parallel_degree)            -> intact
  the getattr guard in trainer.py                -> now True (was
                                                    permanently False)

Core stays clean: none of the five fields exist on core
ParallelismConfig, and git diff on torchtitan/trainer.py and
torchtitan/config/configs.py is zero lines.
Takes `_run_experts_batched_mm_padded` from samuelwheeler/torchtitan
feature/aurora-moe-training into our ezpz-local experts module, where
`EzpzGroupedExperts` and its ExpertComputeBackend selector already live.
Core torchtitan is untouched; upstream puts this in
torchtitan/models/common/moe.py, we do not need to.

Renamed to `_run_experts_bmm_nodrop`. It is NOT a duplicate of our
existing `bmm` backend, and the names should say why: ours pads to a
capacity derived from `capacity_factor` and DROPS overflow tokens, this
one pads to the largest actual per-expert count and drops nothing. That
makes it the numerically exact choice, at the cost of a leading dimension
that moves with the routing each step (so it is less compile-friendly
than the fixed-capacity path). Measured on imbalanced routing: `bmm`
zeroes 86/300 rows, `bmm_nodrop` zeroes none.

Adapted to our post-pytorch#3425 parameter names -- upstream's copy predates the
w1_EFD/w2_EDF/w3_EFD shape-suffix rename, so it could not be taken
verbatim.

Two fixes to the test that came across in step 1 and could never have
passed here:

1. It imported `_run_experts_batched_mm_padded` from
   torchtitan.models.common.moe, which is where UPSTREAM put it. On our
   branch that symbol does not exist in core (0 occurrences). Repointed
   to the ezpz module, aliased so the test body is unchanged.

2. It built fp32 inputs and asserted rtol=1e-5, but
   `_run_experts_for_loop` casts to bf16 internally -- so it compared a
   bf16 computation against a full-precision one and saw ~3.5e-3
   relative error. That is bf16 rounding, not a backend defect. Switched
   to bf16, the dtype production runs.

Verified on Aurora (macOS cannot collect this file -- no triton): in
bf16 the forward and all four gradients (w1, w2, w3, x) are bit-exact
against the for_loop reference, including an expert with zero tokens.

The remaining tests in that file exercise aurora_sycl / aurora_full_*
backends and 50K config flavors that are not ported yet; they still fail
and are left for the next step rather than silently deleted.
…date

One live monitor (bdaixcfx2) and its re-arm command, plus the facts needed to
resume: p3 finished clean on walltime (Exit_status=-29), p4 is queued behind
ordinary contention (212h eligible, 58 nodes free, no reservation), chain head
is step 6,263 so the resume point is step-6200, and no successor is queued
behind p4.
…ardware)

Fourth and last portable backend from samuelwheeler/torchtitan
feature/aurora-moe-training. Ported ezpz-local; core untouched.

Why this one and not the other three: sww's GroupedExperts.forward is
(x, top_scores, selected_experts_indices, shared_experts) and owns
dispatch/combine/scatter_add. Ours is (x_RD, num_tokens_per_expert_E) --
"raw expert computation without dispatch/combine" -- because upstream
moved dispatch into the token dispatcher and his branch predates that.
scattermoe and aurora_full_* need the routing scores our forward never
receives, and aurora_full_* additionally requires an EP mesh. Those are a
dispatcher restructuring, not a port. aurora_sycl's entry point
torchtitan_exact_experts(w1, w2, w3, x, expert_rows) matches our slot
exactly.

Checkpoint-transparent. In sww's __init__ only scattermoe
(scattermoe_w13/w2) and aurora_full_* (aurora_up/gate/down) register
alternate parameter names; aurora_sycl sits in the else: branch on plain
w1/w2/w3. So selecting it changes no tensor name and no existing
checkpoint.

The import is lazy: with aurora_moe absent every other backend still
works (verified), and requesting this one raises an ImportError naming
the vendored path rather than failing at module import.

NOT YET VALIDATED ON HARDWARE. The kernels JIT-compile through
torch.utils.cpp_extension.load against oneMKL, and Aurora has the headers
plus libmkl_sycl_blas.so.5 the loader probes for under
/opt/aurora/26.26.0/oneapi/mkl/2025.3 -- but neither the build nor the
numerics has been confirmed on an XPU yet. Job 8829251 (next-eval) is
doing that: JIT-build, then compare against a per-expert reference loop
including a zero-token expert. Treat this backend as unproven until that
result lands.
The ported backend did the GEMMs in whatever dtype it was handed, so it
raised "RuntimeError: expected scalar type Float but found BFloat16" the
moment parameters and activations disagreed -- which is the normal case
under mixed precision, where params stay fp32 and x arrives bf16.

Both existing backends already handle this: _run_experts_for_loop does
x_expert.bfloat16() plus w{1,2,3}[i].bfloat16() and returns
h.type_as(x); _run_experts_bmm does the same in batched form. The sww
original omitted the casts because on that branch the caller had already
aligned dtypes. Ported code inherited the omission.

Now computes in bf16 and returns type_as(x), matching the convention.
Verified both ways round:
  fp32 params + bf16 x -> ok, out bf16, matches for_loop
  all bf16             -> ok, out bf16, matches for_loop

Also finishes adapting tests/unit_tests/test_moe_expert_backends.py,
which came from the sww branch and disagreed with our tree in six
separate places -- that branch forked before several upstream refactors,
so nothing in it can be lifted verbatim:

  1. compute_backend is on our EzpzGroupedExperts.Config, not on core
     GroupedExperts.Config (0 hits in core)
  2. w1/w2/w3 -> w1_EFD/w2_EDF/w3_EFD (upstream PR pytorch#3425)
  3. _experts_forward -> forward
  4. score_before_experts: removed from LocalTokenDispatcher.Config
  5. use_grouped_mm / token_dispatcher: not fields on our config
  6. the _init_grouped_experts_weights helper, same rename as (2)

Three tests are skipped rather than deleted, each naming its reason: two
exercise aurora_full_* (deliberately not ported -- they need routing
scores our forward never receives, plus an EP mesh), and one needs four
config flavors we do not define AND a count_params() that assumes
cfg.experts, which our Config does not expose.
Measured on a real compute node rather than inferred: job 8829454,
12 XPUs, torch 2.13.0.dev20260428+xpu.

The JIT build SUCCEEDS. Both extensions compile and cache:
  sycl_build/one_mkl_exact_expert/aurora_moe_one_mkl_exact_expert.so
  sycl_build/swiglu_ops/aurora_moe_swiglu_ops.so
oneMKL headers and libmkl_sycl_blas.so.5 are where the loader expects
them under /opt/aurora/26.26.0/oneapi/mkl/2025.3.

The first kernel call does not:
  hidden = swiglu.swiglu_forward_bf16(up, gate)
  RuntimeError: Invalid argument
  level_zero backend failed with error: 37 (UR_RESULT_ERROR_UNINITIALIZED)
  opencl     backend failed with error: 37 (UR_RESULT_ERROR_UNINITIALIZED)

torch.utils.cpp_extension warns that the kernels are compiled with icpx
while this torch was built with g++ -- the most likely cause, and the
same class of SYCL/compiler skew this stack has produced before. That is
an Intel-runtime problem, not a torchtitan one.

No code change: the backend stays wired behind a lazy import, so it
cannot affect anyone who does not select it, and 987177d already
labeled it unvalidated. This replaces that open question with a measured
negative and says what to try next.

Separately, the XPU torch.topk tie-instability that motivated a possible
core router change also does NOT reproduce on this stack: 0 differing
results over 20 identical calls with ties present in 2913/4096 rows.
That core change is therefore not warranted here and was not made.
cb4a989 reported aurora_sycl as failing at runtime on Aurora. That
conclusion was wrong: it was measured with a oneMKL that did not match
the image the job was running under.

Two measurements on real compute nodes, both 2026-09-15:

  8829454  MKLROOT=/opt/aurora/26.26.0/.../mkl/2025.3
           builds, then swiglu_forward_bf16 dies with "Invalid argument"
           and level_zero/opencl UR_RESULT_ERROR_UNINITIALIZED (37)
  8829416  module load frameworks/2026.1.0,
           MKLROOT=/opt/aurora/26.181.0/oneapi/mkl/latest
           BUILD_RC=0, forward finite, all 4 gradients populated,
           output tracks a torch per-expert reference

The discriminator is a toolchain soname split, not the kernels. The
next-eval queue runs a TEST bkc image (compute_aurora_test_20260831,
26.181.0 / oneAPI 2026.1 / libsycl.so.9) while debug and small run the
PROD image (compute_aurora_prod_20260828, 26.26.0 / oneAPI 2025.3 /
libsycl.so.8) -- verified with `qstat -Qf <queue> | grep bkc_definition`.
Building against the 2025.3 oneMKL under the 2026.1 image produces an
.so needing libsycl.so.9 while MKL pulls libsycl.so.8. Note 26.181.0 is
not visible from a login node at all, which is why the mismatch was not
obvious.

One upstream change is still needed for this to work unpatched:
aurora_moe's oneMKL loader hardcodes a libmkl_sycl_blas.so.5 check while
the 26.181.0 image ships .so.6, so it refuses an oneMKL that works. The
probe patched a scratch copy to confirm; the repo was not touched.

No functional change here -- the backend was already wired behind a lazy
import. This replaces a wrong negative with the measured result and the
exact environment it needs.
206d759 said aurora_sycl works given an image-matched oneMKL. True for
the frameworks module python; NOT true for the venv production actually
trains with. The earlier measurement could not see that, because it was
taken on the module python.

Three measurements, all real compute nodes on next-eval, 2026-09-15:

  8829416  frameworks/2026.1.0 py3.12, MKLROOT=26.181.0  -> WORKS
  8829454  yeeted /tmp/.venv py3.14 + 2.13.0.dev20260428+xpu,
           MKLROOT=26.26.0 (wrong image)                 -> fails
  8829790  same venv, MKLROOT=26.181.0 (.so.6 present)   -> STILL FAILS
           oneapi::mkl::blas::gemm_bf16bf16bf16: unsupported device
           + UR_RESULT_ERROR_UNINITIALIZED (37)

8829790 decides it: correct image-matched oneMKL and it still failed, so
the oneMKL image is not the whole story. The remaining difference is the
torch build itself.

bmm_nodrop ran in the SAME job on the SAME device and returned
rel_err 0.000e+00 against for_loop -- its first XPU verification, having
only ever been CPU-checked. That isolates the failure to the aurora-moe
SYCL path rather than to XPU or to the venv.

Recorded from the compute node, since these paths are invisible from a
login node: 26.181.0 ships libmkl_sycl_blas.so.6, prod 26.26.0 ships
.so.5 only, and /opt/aurora/default resolves to 26.26.0 -- so MKLROOT
set off `default` yields the failing configuration. The hardcoded .so.5
check also lives in THREE files, not one; credit to the sunspot-tt-ezpz
session for catching that, since patching only one would have produced a
partial fix carrying a whole-backend conclusion.

No code change. The backend stays behind a lazy import and no config
selects it.
The oneMKL loaders hardcoded a `libmkl_sycl_blas.so.5` presence check in
three files, so on Aurora's 26.181.0 image -- the one behind the
next-eval queue, which ships .so.6 -- they REFUSED an oneMKL that works.
The 26.26.0 prod image ships .so.5, which is why this went unnoticed.

Glob rather than bump the number. The check is a presence probe ("is
oneMKL SYCL BLAS here at all", per its own error text), not a version
assertion -- ABI compatibility is enforced by the linker at load time. A
bare 5 -> 6 bump would relocate the wrong pin and reject .so.7 on the
next image.

Verified semantics: .so.5, .so.6 and .so.7 all match; an empty directory
does not; and a bare `libmkl_sycl_blas.so` symlink alone does not, which
is right -- that is a link-time name, not a runtime soname.

All three call sites, not one. Patching only
one_mkl_exact_expert_gemm.py (as an earlier scratch probe did) leaves
one_mkl_ops.py and one_mkl_grouped_gemm.py still refusing .so.6, so any
code path reaching those would fail while the exact-expert path appeared
to work -- a partial fix carrying a whole-backend conclusion. Credit to
the sunspot-tt-ezpz session for catching that.

Scope: this fixes a check that wrongly REFUSES a working oneMKL. It does
NOT stop someone pointing MKLROOT at the wrong oneMKL for their image --
under /opt/aurora/default the glob finds whatever that image ships and
passes, then the kernels fail at runtime. Two different failures; only
this one is in aurora_moe's control.

Separately measured and unaffected by this change: aurora_sycl still
fails under the production training venv even with an image-matched
oneMKL (job 8829790, gemm_bf16bf16bf16: unsupported device). See the
_run_experts_aurora_sycl docstring.
Six instances in two days of one error shape -- a check that returns the
same answer whether or not the thing works: imports passing while 0/14
flavors build, a #181519 probe matching the raise the patch removes, a
chain-depth monitor reading healthy through 79h of zero progress, an
[ -x ] interpreter check from a login node, one of three soname call
sites patched, and Exit_status=0 on jobs that died before running Python.

Records what shipped (soname glob, bmm_nodrop dtype, the 80B guard
placement, ezpz pytorch#244/pytorch#245), what was withdrawn (aurora_sycl three times,
the #181519 PRESENT verdict, the MKLROOT-off-default claim), and the
rule that covers the whole probe-failure class: 114/122 PBS scripts here
use --login, so start from an existing submit script.
Written mid-session as a crash-safe handoff before a Claude restart, so
it landed in the repo root. It has real content -- the venv/clone trap,
the live job IDs, the monitor re-arm list -- but the root is not where
one-off notes belong. Filed under docs/session-state/ and kept rather
than deleted; the journal entry for the same window summarizes it, this
is the raw version.
I closed that question on four greps of _fsdp_param.py. The stronger
evidence arrived after: sunspot-tt-ezpz ran the merged sync-84 tree on
BOTH bkc images and got byte-identical FSDP failures (8829185 prod,
8831522 test), against a pre-merge tree that trains (8829243).

8831522 matters most -- the test image was the last place the blocker
could plausibly have been absent, given the two images differ materially
enough that aurora_moe's SYCL kernels work on one and not the other. It
reached IMPORT_OK and built the model first, so it is the FSDP path, not
packaging.

Citing that instead. An execution failure on the image where the fix was
most likely to be present beats four greps -- particularly since my
first grep on this question returned a false positive by matching the
raise the patch removes.
4ea7a16 said aurora_sycl "does not work under the production training
venv". Wrong, and wrong in an avoidable way: every measurement behind
that claim was taken on a TEST bkc image while the venv is prod-era, so
what I had actually measured was mismatch, not the venv.

Ran the coherent combination -- debug queue (PROD bkc), our yeeted
/tmp/.venv, and MKLROOT pointing at that same image's oneMKL:

  8831582  debug, PROD bkc, py3.14 + 2.13.0.dev20260428+xpu,
           MKLROOT=/opt/aurora/26.26.0/oneapi/mkl/2025.3, icpx 2025.3.2
           -> runs. finite output, no UR_RESULT_ERROR_UNINITIALIZED, no
              "unsupported device".

Full picture, four jobs:

  8829416  TEST bkc + module py3.12 + 26.181.0 oneMKL   coherent  WORKS
  8829454  TEST bkc + our venv      + 26.26.0  oneMKL   mismatch  UR_RESULT_ERROR
  8829790  TEST bkc + our venv      + 26.181.0 oneMKL   mismatch  unsupported device
  8831582  PROD bkc + our venv      + 26.26.0  oneMKL   coherent  WORKS

8829790 is what misled me: I treated "image-matched oneMKL and it still
fails" as proof the venv was at fault, when the venv's torch was itself
from the other release. Matching one component of three is not matching.

Numerics are bf16 rounding, not a kernel defect. Against the for_loop
reference: rel_err 4.4e-03, 14/1280 elements (1.09%) outside a 0.05
tolerance, rowwise cosine min 0.999993. The mismatched elements are
large-magnitude ones (max |diff| 8.0 against a reference max near 2000).
A structurally wrong kernel would break the cosine, not a handful of
elements. bmm_nodrop scored exactly 0.0 with 0 mismatches in the same
job on the same device, which rules out the harness.

Credit for the question that produced this: it came from asking whether
the failure had ever been tested on the debug queue with our tarball on
top of oneapi/2025.3.1. It had not. Three prior jobs all varied the
oneMKL while holding the image fixed.
ALCF support, 2026-09-16, on oneCCL bootstrap failures with the 2026.1.0
frameworks: the workaround is `unset CCL_KVS_MODE; export
CCL_KVS_MODE=pmi` with NO other CCL_* vars set, while the oneCCL team
investigates the root cause.

Khalid Hossain: "after dropping export CCL_KVS_MODE=mpi from the user's
job script, I could run their example as is in 2-nodes, PPN=1, each node
coming from a different rack." Nathan Nichols, on a user's tuning block
very like the one this file carried: "I would recommend that they don't
do that."

This file came in with the sww MoE port and set `CCL_KVS_MODE=mpi` --
the exact value ALCF identifies as the problem -- plus
CCL_ATL_TRANSPORT=mpi, CCL_KVS_CONNECTION_TIMEOUT=1800,
CCL_KVS_USE_MPI_RANKS=1, CCL_CONFIGURATION_PATH, CCL_CONFIGURATION,
CCL_ZE_CACHE_OPEN_IPC_HANDLES_THRESHOLD and MPIR_CVAR_ENABLE_GPU.

Now exactly three:

  export CCL_PROCESS_LAUNCHER=pmix
  export CCL_OP_SYNC=1
  export CCL_KVS_MODE=pmi

Dropped the rest rather than keeping the ones that look harmless. We
have no before/after measurement for any of them, and "no other CCL_*"
was explicit. Each removal is commented with why, so restoring one is a
deliberate act with a burden of proof rather than a silent revert.

Audited the rest of the tree while here: the production submits
(scripts/submit_agpt_{multi,2b}_autoretry.sh) carry ZERO flagged vars and
never set CCL_KVS_MODE at all -- they are already consistent with this
guidance, no change needed. Eight rl/scripts/grpo* files carry the
Cassini FI_CXI_* trio ALCF also warns against; left alone here since
this commit is scoped to the MoE submit and those are a separate,
independently-validated RL path.

Two ALCF-sanctioned alternatives, recorded but not adopted: an older
mpich module, or `from mpi4py import MPI` right after `import torch` (its
MPI.Init() fixes an initialization ordering problem even when unused).
Copilot AI lite review requested due to automatic review settings September 16, 2026 16:53

@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.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 20000 lines

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.

🟡 Changes recommended

Unresolved critical findings affect configuration loading, launchers, and native-DDP setup.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This pull request ports Aurora MoE functionality into the ezpz experiment layer while keeping core TorchTitan functionally unchanged.

Changes:

  • Adds ezpz-local native-DDP integration and bmm_nodrop/aurora_sycl backends.
  • Vendors the Aurora runtime and SYCL/oneMKL kernels.
  • Adds configurations, launchers, tests, documentation, and XPU timing tooling.

Review findings:

  • docs/aurora_moe_training.md:11 — nit (1 vote): documents an unsupported full-Sonic production flavor.
  • docs/aurora_moe_training.md:90 — nit (1 vote): claims verification coverage from an uncollectable test.
  • tests/unit_tests/test_agpt_moe_config.py:5 — critical (2 votes): references a missing factory and flavor; collection fails.
  • tests/unit_tests/test_agpt_moe_config.py:75 — critical (1 vote): adapter assertion conflicts with the registry.
  • torchtitan/experiments/ezpz/moe/experts.py:299 — nit (2 votes): setup text requires obsolete .so.5 instead of the soname glob.
  • The three affected JSON run configurations contain obsolete overrides or schemas and fail strict loading: critical (1 vote each).
  • torchtitan/experiments/ezpz/native_ddp.py:554 — moderate (1 vote): PP reducer lifecycle helpers have no callsites.
  • torchtitan/experiments/ezpz/native_ddp.py:376 — critical (2 votes): omitted config fields are dereferenced unconditionally.
  • The dense launcher references an unregistered config factory — critical (2 votes).
  • The full-Sonic launcher references a missing factory — critical (3 votes) — and has an invalid environment setup — moderate (1 vote).
  • torchtitan/experiments/ezpz/trainer.py:586 — critical (3 votes): required native-DDP validation arguments are omitted.
  • torchtitan/experiments/ezpz/trainer.py:719 — critical (1 vote): native DDP is built before meta-module materialization.
  • torchtitan/experiments/ezpz/trainer.py:719 — critical (3 votes): the PP native-DDP wrapper is never invoked.
  • torchtitan/experiments/ezpz/trainer.py:714 — critical (1 vote): FSDP wrapping precedes the native-DDP path.
  • vendor/aurora_moe_dropin/src/aurora_moe/layer.py:63 — moderate (2 votes): invalid backend/device/dtype combinations are accepted until forward execution.
File summaries
File Summary
vendor/aurora_moe_dropin/tests/test_dropin.py Drop-in runtime tests
vendor/aurora_moe_dropin/src/aurora_moe/torchtitan_full.py Full routed-MoE adapter
vendor/aurora_moe_dropin/src/aurora_moe/runtime.py Runtime environment presets
vendor/aurora_moe_dropin/src/aurora_moe/layer.py Public Aurora MoE module
vendor/aurora_moe_dropin/src/aurora_moe/distributed.py Distributed process-group setup
vendor/aurora_moe_dropin/src/aurora_moe/build.py Extension build helpers
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/xmx_gemm.py XMX GEMM kernel helper
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/xetla_grouped_gemm.py XeTLA grouped GEMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/xetla_grouped_gemm_f32.py FP32 grouped GEMM path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/tla_ops.py TLA operation helpers
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/tla_builder_gemm.py TLA builder GEMM wrapper
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/tla_builder_gemm_probe.py TLA builder probe
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/swiglu_ops.py SwiGLU operations
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/streamed_shared_expert.py Streamed shared-expert path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/shared_expert_bmm.py Shared-expert BMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/segmented_moe_tla.py Segmented MoE TLA path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/segmented_grouped_gemm.py Segmented grouped GEMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/segmented_expert_layout.py Segmented expert layout
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/route_grad_ops.py Routing gradient operations
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/packed_swiglu_ops.py Packed SwiGLU operations
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/ops.py Kernel operation utilities
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/one_mkl_grouped_gemm.py oneMKL grouped GEMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/one_mkl_exact_expert_gemm.py oneMKL exact expert GEMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/local_forward.py Local forward path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/level_zero_ipc.py Level Zero IPC helpers
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/level_zero_ipc_push.py Level Zero IPC push helpers
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/level_zero_ipc_ep_a2a.py Level Zero EP all-to-all IPC
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/expert_sharded_ep.py Expert-sharded EP path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/direct_layout_payload_fusion.py Direct-layout payload fusion
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/ddp_anchor.py DDP anchor utilities
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/tla_builder_gemm.sycl SYCL TLA builder kernel
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/tla_builder_gemm_probe.sycl SYCL probe kernel
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/swiglu_ops.sycl SYCL SwiGLU kernels
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/segmented_moe_grouped_gemm.hpp Segmented GEMM declarations
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/packed_swiglu_ops.sycl SYCL packed SwiGLU kernel
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/one_mkl_batched_gemm.sycl SYCL oneMKL batched GEMM
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/expert_slot_ops.sycl SYCL expert-slot operations
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/csrc/direct_layout_payload_fusion.sycl SYCL payload-fusion kernel
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/collapsed_shared_expert.py Collapsed shared-expert path
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/chunked_direct_layout_bmm_moe.py Chunked direct-layout BMM MoE
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/canonical_bf16_gemm_gate.py Canonical BF16 GEMM gate
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/_prebuilt_extension.py Prebuilt extension handling
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/_ipc_trace.py IPC tracing
vendor/aurora_moe_dropin/src/aurora_moe/_kernels/__init__.py Kernel package exports
vendor/aurora_moe_dropin/src/aurora_moe/__init__.py Package exports
vendor/aurora_moe_dropin/scripts/enable_training_runtime.sh Runtime setup script
vendor/aurora_moe_dropin/README.md Drop-in documentation
vendor/aurora_moe_dropin/pyproject.toml Package metadata
vendor/aurora_moe_dropin/examples/train_step.py Training example
vendor/aurora_moe_dropin/.gitignore Package ignore rules
torchtitan/experiments/ezpz/trainer.py ezpz trainer and native-DDP integration
torchtitan/experiments/ezpz/submit/aurora/freeze_matched_dense_moe_2n_1100.py Dense/MoE comparison utility
torchtitan/experiments/ezpz/moe_runs/agpt_moe_2b_50k_ep12_dp256_50k.json Large MoE run configuration
torchtitan/experiments/ezpz/moe_runs/agpt_dense_2b_50k_hsdp256_50k.json Dense run configuration
torchtitan/experiments/ezpz/moe_runs/agpt_2b_50k_moe_ep12_dp2_full_sonic_1100.json Full-Sonic run configuration
torchtitan/experiments/ezpz/moe_runs/agpt_2b_50k_moe_ep12_1node_smoke.json One-node smoke configuration
torchtitan/experiments/ezpz/docs/MONITORS-restart-20260915.md Restart and monitoring notes
torchtitan/experiments/ezpz/docs/journal.md Development journal
torchtitan/experiments/ezpz/docs/claude-sessions.md Session records
torchtitan/experiments/ezpz/config.py Local parallelism configuration
tests/unit_tests/test_moe_routing_counts.py Routing-count tests
tests/unit_tests/test_agpt_moe_config.py AGPT configuration tests
docs/aurora_moe_training.md Aurora training documentation
Review details

Suppressed comments (11)

docs/aurora_moe_training.md:11

  • This document presents AGPT_2B_50K_MOE_sdpa_aurora_full_sonic as the production flavor, but the port explicitly does not integrate aurora_full_*: ezpz exposes the local aurora_sycl expert backend instead, and the referenced full-Sonic config factory is absent. Following this guide therefore points users at an unsupported configuration; update it to describe a registered, supported backend or clearly mark the historical run as unavailable.
    docs/aurora_moe_training.md:94
  • The verification section claims the architecture/parameter-count contract is covered, but test_agpt_moe_config.py cannot be imported because its factory and flavor are absent. This makes the documented verification procedure misleading; either repair the test/registry first or remove that claim until the test can collect.
    tests/unit_tests/test_agpt_moe_config.py:15
  • FLAVOR is not a key in the current moe_configs registry, so both tests that index moe_configs[FLAVOR] fail even if the missing import is repaired. Register the 50K architecture before asserting its dimensions, or use an existing flavor with matching expectations.
    tests/unit_tests/test_agpt_moe_config.py:36
  • The port explicitly does not implement aurora_full_sonic; EzpzGroupedExperts.forward only accepts grouped_mm, for_loop, bmm, bmm_nodrop, and aurora_sycl. A config asserting this backend advertises a path that will raise ValueError on the first expert forward.
    tests/unit_tests/test_agpt_moe_config.py:77
  • Activation checkpointing is now represented by a policy config, and MoeSelectiveAC.Config has no mode attribute. This direct access raises AttributeError; assert the policy type or validate the mode through the factory argument instead.
    tests/unit_tests/test_agpt_moe_config.py:80
  • moeModel.Config.update_from_config requires the keyword config, not trainer_config; this call raises TypeError after the earlier collection issues are fixed.
    torchtitan/experiments/ezpz/moe_runs/agpt_dense_2b_50k_hsdp256_50k.json:22
  • The current AC API uses FullAC.Config/SelectiveAC.Config policy objects, not a mode field. The dense JSON factory starts from FullAC.Config, so _apply_config_overrides raises KeyError on this nested mode before training; choose the policy in the factory or remove this obsolete override.
    torchtitan/experiments/ezpz/moe_runs/agpt_moe_2b_50k_ep12_dp256_50k.json:23
  • The current AC API uses policy objects, so the base MoE config contains MoeSelectiveAC.Config and _apply_config_overrides only accepts its dataclass fields. It has no mode field; loading this JSON raises KeyError before the 50K run starts. Remove this obsolete nested override or select the policy in the factory.
    torchtitan/experiments/ezpz/native_ddp.py:558
  • These PP reducer-lifecycle helpers have no callsites anywhere in the repository: no code arms the one-time rebuild after a 1F1B schedule, invokes the rebuild before the next schedule, or validates the pristine state after checkpoint load. Even after the stage is wrapped, the claimed PP native-DDP path therefore cannot perform its required bucket transition and checkpoint invariant checks; wire these calls into the PP training/checkpoint lifecycle or remove PP from validation.
    torchtitan/experiments/ezpz/submit/aurora/submit_agpt_dense_moe_256n_50k.pbs:54
  • agpt_2b_50k_moe_sdpa_aurora_full_sonic_from_json is not defined in moe/config_registry.py, so the MoE case cannot resolve its --config and never reaches training. Register a factory for the JSON file or change this launcher to a supported ezpz backend/config; the current aurora_full_sonic name is not part of the port.
    torchtitan/experiments/ezpz/submit/aurora/submit_agpt_moe_full_sonic_2n_1100.pbs:55
  • This launcher does not set CCL_KVS_MODE=pmi and still exports the IPC-handle tuning variable that the updated 256-node launcher explicitly removed under the ALCF bootstrap guidance. On this same oneCCL stack, the job can fail during communicator bootstrap or inherit an unsafe site default; match the validated minimal environment.
  • Files reviewed: 20/123 changed files
  • Comments generated: 15
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread torchtitan/experiments/ezpz/trainer.py Resolved
Comment thread torchtitan/experiments/ezpz/trainer.py Resolved
Comment thread torchtitan/experiments/ezpz/trainer.py Resolved
Comment thread torchtitan/experiments/ezpz/trainer.py Resolved
@saforem2

Copy link
Copy Markdown
Owner Author

Self-review: the native-DDP path has never executed

Ran a high-effort review on my own PR. 15 findings. The headline is that step 2 of this port does not work and never could have — I verified the top finding programmatically rather than reasoning about it:

validate_native_ddp  required keyword-only args : 9
trainer.py passes                               : 6
MISSING: fault_tolerance_enabled, create_seed_checkpoint, optimizer_has_param_groups

Any run with enable_data_parallel_native_ddp=true raises TypeError at trainer construction. I shipped f5f6ee684 claiming the hooks were wired, and wrote in 73824cf71 that the flags made the path "live". Neither statement was ever true, and nothing I ran would have caught it, because every test I wrote exercises the expert backends rather than the DDP path.

Blocking — native-DDP is unreachable

  1. trainer.py:586 — validate_native_ddp called with 6 of 9 required kwargs. TypeError at construction.
  2. native_ddp.py:378,381-382 — the validator reads parallelism.enable_fsdp_async_all_reduce and pipeline_parallel_fsdp_overlap*, none of which exist on ParallelismConfig or EzpzParallelismConfig. My own config.py docstring says I omitted enable_fsdp_async_all_reduce because "nothing in our port reads them" — this validator reads it. AttributeError even after fixing Saforem2/blendcorpus #1.
  3. trainer.py:719 — wrap_native_ddp runs on a meta-device model, before to_empty at 727. device_ids=[None], DDP builds reduction buckets from meta storage, and the subsequent to_empty reallocates every parameter, invalidating the bucket views it just built with gradient_as_bucket_view=True.
  4. native_ddp.py:645 — imports _NativeDDPPipelineStage from core pipeline_parallel, where it does not exist. It is defined at line 847 of that same file, and the header comment I wrote at 840-846 explains that I moved it there. Only unreached because the function has no callers.

Blocking — silent numerics

  1. native_ddp.py:301 — scale_native_ddp_loss is defined and never called from the training path (grep: two hits, both inside its own definition). The ezpz train_step normalizes by global_valid_tokens, already a cross-DP sum, and DDP's reducer then divides by process_group.size() again. FSDP has disable_fsdp_gradient_division for exactly this reason. So native DDP would be dp_degreex off from the path it replaces — and it would train, not crash.

Blocking — configs and tests that cannot run

  1. tests/unit_tests/test_agpt_moe_config.py:5 imports a nonexistent symbol → collection error for all of tests/unit_tests/
  2. submit_agpt_moe_full_sonic_2n_1100.pbs:151 preflights a config that does not exist → burns the allocation
  3. submit_agpt_dense_moe_256n_50k.pbs:49 — the dense arm's config does not exist either, so both branches are broken
  4. All four new moe_runs/*.json use training.local_batch_size/global_batch_size/seq_len, removed by fold batch dim pytorch/torchtitan#4121 → KeyError
  5. agpt_moe_2b_50k_ep12_dp256_50k.json:66 sets keep_latest_k: 2 on a 50,000-step run. Project memory: "NEVER use keep-latest-k — destroyed ~334 ckpts". This one is a data-loss hazard and I imported it without reading it.
    10-12. test_moe_routing_counts.py — wrong arity, a nonexistent Config field, and an unpack order that binds counts to the (T,E) score matrix, so its assertion tests something other than what it claims

Non-blocking

  1. bmm_nodrop has no counts.sum() == x.shape[0] check; a violation surfaces as a confusing broadcast error. The vendored aurora_sycl path validates this.
  2. record_native_ddp_grad_streams calls torch.accelerator.current_stream() unguarded on a path that explicitly supports CPU. Latent today.

What holds

The expert backends are the part with hardware evidence and they survive: bmm_nodrop bit-exact on XPU, aurora_sycl at cosine 0.999993, the oneMKL soname fix, the CCL guidance, and the ezpz-local config mechanism (the subclass and tyro wiring are correct — the validator that reads it is what is broken).

What I got wrong about my own work

I described this PR as "MoE port complete" and "core untouched, tests green". The second half is true. The first half was not, and the gap is that I verified the parts I had built tests for and asserted the rest. Findings 1-4 are all reachable by running the path once, which I never did — I only ever ran the expert-backend probes.

Recommendation: do not merge as-is. Split it — the expert backends plus the soname and CCL fixes are defensible on evidence today; the native-DDP half needs findings 1-4 and 15 fixed and then an actual run with the flag enabled before anyone should believe it works.

… path

I imported two production configs in ab24c5c without reading them.
Both set keep_latest_k=2 on a 50,000-step 256-node run with
interval=500:

  agpt_moe_2b_50k_ep12_dp256_50k.json
  agpt_dense_2b_50k_hsdp256_50k.json

100 checkpoints written, 2 survive, 98 irreversibly deleted -- per run.
That is the exact mechanism that cost ~334 chain checkpoints on
2026-05-25 (job 8505252), and the reason submit_agpt_2b_autoretry.sh
hardcodes CKPT_KEEP_LATEST_K=0 with a refusal on any non-zero override.

Both set to 0.

The more important half: THE EXISTING GUARD DOES NOT COVER THIS PATH.
submit_agpt_{2b,multi}_autoretry.sh check the CKPT_KEEP_LATEST_K env
var, but a JSON config sets checkpoint.keep_latest_k directly and never
passes through that check. Grep for keep_latest_k across
experiments/ezpz/*.py returned nothing before this commit -- the JSON
path was entirely unguarded, which is how these two files walked in.

_apply_config_overrides now rejects any non-zero keep_latest_k from
JSON, naming the consequence. A hard error rather than a clamp:
silently rewriting a value the operator asked for is how the original
loss looked like it had been configured deliberately.

Verified both directions: keep_latest_k=2 raises, keep_latest_k=0 is
accepted.

Found by running /code-review on my own PR (#17). It is finding 9 of 15;
findings 1-4 say the native-DDP path has never executed at all.
The native-DDP preflight could never run. Two independent defects, both
on the same call path, both from f5f6ee6:

1. trainer.py passed 6 of the 9 required keyword-only args. Missing:
   fault_tolerance_enabled, create_seed_checkpoint,
   optimizer_has_param_groups -- none of which have defaults. Any run
   with enable_data_parallel_native_ddp=true died with TypeError at
   trainer construction, before anything else was reached.

   All three are available at the callsite and now passed:
   config.fault_tolerance.enable, config.checkpoint.create_seed_checkpoint,
   and whether config.optimizer declares param_groups.

2. Even fixed, the validator read three fields that do not exist here:
   parallelism.enable_fsdp_async_all_reduce,
   pipeline_parallel_fsdp_overlap and pipeline_parallel_fsdp_overlap_policy.
   Those are on the upstream Aurora MoE branch's CORE ParallelismConfig;
   ours is EzpzParallelismConfig, which deliberately ports only the five
   fields our code reads, and core torchtitan never had them. Reading
   them on a slotted dataclass raised AttributeError, and they sit two
   gates before the final check, so they were always reached.

   Now read via getattr with the upstream default. Keeping the checks
   rather than deleting them means the rejection still fires if those
   fields are ever added; deleting would silently accept a combination
   the author explicitly rejected.

Verified by calling the validator against REAL objects -- a real
ParallelDims built from its own dataclass fields, a real TrainingConfig,
and a real EzpzParallelismConfig with the flag on. It now runs every
gate and returns a policy ValueError ("native DDP currently requires
standard CrossEntropyLoss") instead of TypeError or AttributeError.
That is the validator working.

Both found by /code-review on my own PR (#17), findings 1 and 2 of 15.
I shipped f5f6ee6 saying the hooks were wired and 73824cf saying the
flags made the path live. Neither was true, and no test I wrote would
have caught it -- they all exercise the expert backends instead.

Still open from that review: #3 (wrap_native_ddp runs on a meta-device
model before to_empty), #4 (a helper imports _NativeDDPPipelineStage from
core, where I moved it out of), and #15 (scale_native_ddp_loss defined
but never called, leaving gradients dp_degree x off).
…(review #3, #4, #15)

Three remaining findings from /code-review on #17. With b2deeb2 this
closes all five blockers on the native-DDP path.

#3 -- wrap_native_ddp ran on a META-DEVICE model.

The model is built under torch.device("meta") and moved to the real
device by to_empty(). The wrap sat BEFORE that, so DDP read
next(model.parameters()).device, got device(type='meta') with .index
None, computed device_ids=[None], and built reduction buckets over meta
storage. to_empty() then reallocated every parameter, invalidating the
bucket views DDP had just built with gradient_as_bucket_view=True.

Moved after to_empty/init_states and before model.train(). Order is now
to_empty -> init_states -> wrap -> train.

#4 -- wrap_native_ddp_pipeline_stage imported _NativeDDPPipelineStage
from torchtitan.distributed.pipeline_parallel, where it does not exist.

ab24c5c moved that class into native_ddp.py as part of the dependency
inversion -- it is defined at line 853 of the same file that was
importing it from core. ImportError for any PP + native-DDP run, and the
isinstance check three lines later could never have matched. Only
unreached because the function has no callers. Import dropped; the
class resolves from module scope.

#15 -- scale_native_ddp_loss was defined and never called, leaving
gradients dp_degree x too small. This is the one that would have
TRAINED, not crashed.

Core's forward_backward_step states it: "The returned loss here is local
SUM loss / global_valid_tokens". global_valid_tokens is a cross-DP sum
(dist_sum over batch_mesh), so gradients are already globally normalized
before backward. DDP's reducer then divides by process_group.size()
again. FSDP hits the same thing and solves it with
disable_fsdp_gradient_division (agpt/parallelize.py); DDP exposes no
equivalent switch, so the compensation has to happen on the loss -- which
is precisely what scale_native_ddp_loss exists for.

Wired at self.loss_fn construction, which ezpz owns, so it lands before
every consumer without touching core's forward_backward_step. Guarded on
the flag and on dp_degree > 1.

Verified: gradient ratio exactly 4.0 at dp=4 and 8.0 at dp=8, loss VALUE
unchanged in both (so reported loss stays comparable across paths), and
dp=1 refuses rather than silently no-opping.

Not yet run end-to-end with the flag enabled on hardware. These fixes are
reasoned from the code plus unit-level verification of the scaling math;
the path still needs a real run before anyone should trust it, and that
is the next step rather than a claim this commit makes.
The page opened with an [!IMPORTANT] callout reading "Aurora production
is IDLE and has not trained since 2026-08-26", plus two per-chain rows
marked "IDLE since 2026-08-26". Meanwhile 8828611 has been job_state=R
on 2,098 nodes since 02:26 UTC today with all five seats writing.

Replaced with live state (2026-09-17 12:11 UTC), 5/5 seats:

  2B-512 stage2-dolmino    21,553   2.48037
  2B-256 stage2-dolmino    26,938   2.47324
  2B-512 constlr-from9200  39,152   2.65700
  20B-512                  10,800   2.25807
  20B-256                  15,077   2.25079

The old callout blamed a queue defect: 8784460 sitting Q with
score_boost=0 and 101h eligible time, with a drafted-but-unsent ALCF
ticket. That reading did not survive. A later submission (8828611)
scheduled normally once the machine drained, so the boost was not the
obstacle. The chain DID sit idle a long time -- no checkpoint advanced
between 09-13 and 09-17, 93 hours -- but because a 2,098-node request
cannot place on a machine with 9,976 nodes job-exclusive. Capacity, not
scheduling policy. Said so rather than leaving the ticket narrative
standing.

The per-chain tables still carry last-persisted numbers and are now
explicitly labelled as behind the live table rather than as current.

Found by auditing what is actually stale, prompted by the question of
whether the production docs are up to date. They were not: the charts
are also 17 days old (last SVG commit 2026-08-31) and the eval gap is
large -- 20B-512 evaluated through step 7,600 against a step-10,800
checkpoint, and both 2B stage-2 dolmino seats have NO evals at all
despite being at steps 26,938 and 21,553. Those are separate fixes.
Generated by refresh_all.sh from the trajectories.py manifest:
=== 0 leaf field(s), 0 rollup row(s) changed, 0 warning(s) ===
=== summary: 0 up-to-date, 0 stale, 0 missing-README ===
…at/aurora-moe-port

# Conflicts:
#	torchtitan/experiments/ezpz/docs/claude-sessions.md
#	torchtitan/experiments/ezpz/docs/journal.md
…512 at its fork

refresh_all.sh has been exiting 0 and committing chart churn while
producing no new data. Two registry gaps, both silent:

1. TWELVE W&B runs across four umbrellas were never registered:

     no8zak98 qzhfr1zi f1pzca4k pltbp016   2B-512 stage2-dolmino
     av8h56xt wnws2jtn fpw58jgz            20B-512
     s2iqoonn 23magxfo xmdg7z2g            20B-256
     ozcm9s2t q5pa4ssw                     2B-512 constlr-from9200

   Jobs 8808931, 8808932, 8812215 and 8828611. The plotters chart what
   the registry names, so every production figure stops at 2026-08-26
   even though the chains have advanced thousands of steps since. Added
   oldest-first, since run-id order is semantic (last listed wins a
   contested step).

2. 20b_v2_512's ckpt_dir pointed at
   agpt-20b-sophiag-olmo-mix-1124-n512-gbs12288, which last advanced
   2026-08-21 (126 ckpts, frozen). The seat forked that day to
   ...-constlr-from9000, now at 20 ckpts with the newest written today.
   So the 20B-512 curve looked flat because the registry was tracking a
   chain the seat had already left -- not a plotting bug.

The constlr_from9200 record already carries a comment describing this
exact failure from 2026-08-17 ("running across three umbrellas with NO
trajectory entry at all"). Same trap, four more umbrellas later. Nothing
registers a new leg automatically; refresh_all only catches what is
already listed.

Still unregistered and deliberately left for a separate change:
agpt-2b-stage2-dolmino-n256-gbs6144 (seat t4) has NO trajectory record
at all. It is at step 28,035 and is invisible to every chart, table and
eval -- which is also why it shows up in the eval audit as never
evaluated. Adding it needs a token_target and a readme target, not just
an id list.
Generated by refresh_all.sh from the trajectories.py manifest:
=== 0 leaf field(s), 0 rollup row(s) changed, 0 warning(s) ===
=== summary: 0 up-to-date, 0 stale, 0 missing-README ===
@saforem2

Copy link
Copy Markdown
Owner Author

I added a standalone merge-readiness and validation report for this PR:

https://github.com/saforem2/torchtitan/blob/feat/aurora-moe-port/torchtitan/experiments/ezpz/docs/experiments/pr17-moe-merge-readiness.md

Highlights:

  • AGPT 2B/50K full-Sonic EP=12 training smoke passed on Sunspot (12478353, 2 steps, forward/backward/optimizer, finite metrics, exit 0).
  • Deterministic Sonic-vs-loop output and gradient parity passed at DP=2 × EP=2 (12478371), including non-square expert dimensions, imbalanced routing, an empty expert, router-score gradients, routed/shared expert gradients, and bitwise-identical DP replicas.
  • The report records each diagnostic failure and the specific issue it exposed rather than counting failed harness runs as model failures.
  • Native DDP has been narrowed to non-PP/autocast-only scope with CPU/Gloo equivalence coverage.
  • Launcher exit propagation, relocatable TT_* inputs, padding-mask routing, EP fail-closed validation, formatting/license checks, and fork GPU workflow behavior are documented.
  • Native-DCP interrupted/resumed equivalence is still open: the latest synthetic DTensor harness (12478377) restored the step but diverged afterward. That remains a merge gate pending diagnosis or a more faithful TorchTitan CheckpointManager test.

The report also lists the remaining CI, XPU native-DDP, PR-description, and review-thread gates. I will keep it updated as those close.

@saforem2
saforem2 merged commit 9fe3e38 into ezpz Sep 21, 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