Repository navigation
Conversation
NuojCheng
requested review from
A9isha,
RissyRan,
SurbhiJainUSC,
abhinavclemson,
aireenmei,
bvandermoon,
darisoy,
dipannita08,
gagika,
gobbleturk,
hengtaoguo,
igorts-git,
jiangjy1982,
khatwanimohit,
shralex,
shuningjin and
xibinliu
as code owners
November 26, 2026 14:44
4 tasks done
Contributor
|
🤖 Hi @NuojCheng, I'm running an automatic MaxText review of this pull request. You can track my progress in the logs. To request another review later, add the |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
🤖 I'm sorry @NuojCheng, but I was unable to process your request. Please see the logs for more details. |
NuojCheng
force-pushed
the
chengnuojin-mpmd-jax
branch
6 times, most recently
from
November 28, 2026 09:55
339f61b to
8e9e165
Compare
Add src/maxtext/experimental/mpmd/jax/: MPMD pipeline parallelism for DeepSeek-V3 and the Qwen3.5 family in plain JAX. Each stage is its own set of jitted shard_map programs on its own sub-mesh (FSDP x EP), a stage boundary is a device-to-device copy, and one Python thread replays a fixed schedule. It runs in one process, as multi-controller JAX across hosts and slices, as one Pathways client (each boundary one IFRT CopyArrays, across slices too), and on NVIDIA GPUs. The multi-controller code runs only where jax.process_count() > 1, so never under Pathways, which refuses its flags up front. Schedules: breadth / circular (the default), GPipe, 1F1B, interleaved, and the zero-bubble ZB-H1 and ZB-H2 (--schedule zbh1 / zbh2). These cut each middle chunk's backward program by data dependence into its input-gradient half and its weight-gradient half, which runs later, in the bubbles; --zb-split-last on (off by default) cuts the fused last chunk's program too. On CPU without YNNPACK fusions they give 1F1B's gradients bit for bit; on a TPU, within a measured tolerance. It is a training harness with its own command line (ds_ep_pipeline), not a MaxText trainer. The layer math is a pure-JAX port of each model that the tests hold to MaxText's; the kernels are MaxText's (megablox, ragged sort, Lineage's layers for DeepSeek-V3's batch split) and tokamax's. The package README covers setup, Pathways in docker and on GKE, benchmark results and the tests, which use MaxText's markers and skip on the jaxlib 0.12 XLA:CPU bugs they would trip. pylint skips the two new directories.
NuojCheng
force-pushed
the
chengnuojin-mpmd-jax
branch
from
November 29, 2026 17:58
8e9e165 to
daf5b95
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This adds
src/maxtext/experimental/mpmd/jax/, an experimental MPMD (multiple program, multiple data) pipeline-parallel training harness for mixture-of-experts decoders: DeepSeek-V3 and the Qwen3.5 family, including Qwen3.8-2.4T-A95B. It is written in plain JAX, with no MPMD partitioner.MaxText's own pipeline runs every stage in one SPMD program, with the stages on a mesh axis. Here every stage is its own set of jitted
shard_mapprograms on its own sub-mesh (FSDP x EP inside a stage). A stage boundary is a device-to-device copy, and one Python thread replays a fixed schedule without blocking. The default schedule is breadth / circular; GPipe, 1F1B, interleaved, the zero-bubble ZB-H1 / ZB-H2 and others are also available. It runs:--distributed). Across slices the boundary is a host relay or a collective permute.JAX_PLATFORMS=proxy). Every stage is local to that client and each boundary is one IFRTCopyArrays, across slices too, with no relay and no per-host launcher.--platform gpu).The layer math is a pure-JAX port of each model. The tests hold it to MaxText's own models and trainer: logits, gradients and training steps. The kernels are MaxText's (megablox, the ring of experts, the ragged sort, Lineage's layers for DeepSeek-V3's batch split) and tokamax's splash attention. The package was developed outside MaxText and is ported here at one revision.
Setup (versions, local docker Pathways, GKE), quick start, benchmark results and test commands are in the package README,
src/maxtext/experimental/mpmd/jax/README.md.Headline result: GKE, 2 x TPU7x-4x4x4, 8 DeepSeek-V3 MoE layers, PP=2 with one stage a slice, FSDP 16 x EP 8, GBS 1024.
--zb-split-last on: ZB-H1 3477.9 (−4.0%), ZB-H2 3448.8 (−4.8%), ZB-H2 with two W buffers 3422.4 (−5.5%). The default schedule,--vv 2breadth, gains nothing there (3626.9, +0.1%). On one TPU7x-8 breadth stays faster at four stages (8 microbatches: −13.5% against 1F1B, the best zero-bubble order −9.9%), but not at two (−4.0%, ZB-H2 −6.2%).Companion PR: #6598 adds
experimental/mpmd/partir/, the same idea through Shardy MPMD's partitioner, on Pathways only. Both PRs add the samesrc/maxtext/experimental/mpmd/__init__.pybyte for byte, so they can merge in either order.For reviewers
tests/unit/mpmd_test/, a directory Add experimental MPMD pipeline parallelism on Shardy MPMD, run by Pathways #6598's tests share (no file names collide). Outside these it touches onlyexperimental/mpmd/__init__.pyand one.pre-commit-config.yamlline: pylint skips the package directory and its 32 test files, as it already skipsexperimental/lineage. pyink, codespell and yamllint apply.--schedule zbh1|zbh2(one chunk a stage) cuts each middle chunk's backward program by data dependence (stage_ad.split_jaxpr, no model changes) into I, the input gradient, and W, the weight gradients, run later in the bubbles;--zb-split-last on(off by default) cuts the fused last chunk too, the only split at two stages; it was 0.7–3.3% faster on one TPU7x-8 but 3.5% slower for ZB-H2 at PP=4 on GKE. Memory: 1F1B's residual sets (ZB-H2 about twice them) plus up to--zb-wbuf-cap(default 1) pending W buffers a split stage, each 7.25 GiB a device for two DeepSeek-V3 MoE layers at 4096 tokens. On a TPU VM's own client, which allocates outputs at dispatch, the loop paces the I's. Not with Lineage's batch split, stash modes or--fsdp-scope repeat.ds_ep_pipeline), synthetic or token-file data, a constant learning rate, and no checkpointing.1f1b_pairs,--sync-rs fold,--tiles published, and old aliases. Code for other MaxText revisions, or for running without MaxText, is removed.jax.process_count() > 1(pathways.multi_controller()): never under Pathways, whose one client is the only process, nor on one host.--distributed,--transport relay|xfer,--json-procs/--profile-procsother thanleaders,--norm-reduce allreduce.ds_ep_multihost.shexits at once.--max-aheaddefaults to 2 steps under Pathways, as nothing else bounds how far the client runs ahead; the wait runs beside the dispatch, so step time is unchanged.python3 -m maxtext.experimental.mpmd.jax.pathways flags tpu7xprints them.--profiletakes only ags://directory, and is write-probed before the run.QwenMoeVsPort's programs corrupt XLA:CPU's heap, so it skips on CPU there;MAXTEXT_MPMD_RUN_JAXLIB_CPU_CRASH=1runs it.ragged_dotweight gradients up to 1.8e-7 of the leaf apart with the fusions off, which no other host reproduced.typeguard==2.13.3, which MaxText's requirements leave out, so the Lineage tests skip in CI.Tests
Run on MaxText
c034bc02f(this branch's base) with jax/jaxlib 0.12.0.1. The TPU and GKE runs of the other schedules predate the zero-bubble code; on CPU this head gives those schedules' results bit for bit, from identical programs (below).JAX_PLATFORMSunset, 4 fake CPU devices, CI's marker expression,-n 8on 32 cores, as CI's runner.XLA_FLAGS=--xla_force_host_platform_device_count=4 python3 -m pytest -n 8 -m 'cpu_only and not post_training and not integration_test' tests/unit/mpmd_test--zb-split-lastand the fusion plan on and off; W-buffer caps 0 to 2). The other schedules are unchanged: 28 of 28 runs bit for bit, every program's stripped StableHLO identical in 35 configurations.tpu_onlytests ofOnTpuandSplitBackwardOnTpupass on McJAX and on local Pathways.pathways_test.OneControllerrunsmainin one process for every schedule (1F1B and ZB-H2 on every PR) with 40 multi-controller-only functions patched to raise, and a line trace of CPU, local Pathways and one-host McJAX runs finds none of their lines executed. Multi-process runs (CPU, 2-4 processes with--distributed) give the previous head's results process by process: the 87 multi-process tests, and 14 configurations compared bit for bit.--jsonkeeps a symlinked record's link, writes/dev/stdout//dev/stderr/ a named pipe in place (a named pipe no longer hangs under--profile); ags://--profile/--jsonnaming no bucket stops the run up front, and a--dry-runno longer write-probes it;--transport relay|xferis refused with one message everywhere;xprofpicks the newest trace session by name;testing.jaxlib_versionreads rc builds;OnTpuskips on a multi-slice job; and several tests are tighter or no longer run out of memory maps. The previous revision's 1F1B, breadth, interleaved and zero-bubble runs are bit for bit unchanged (13 configurations).maxtext_parity_test34 tests. The numbers are identical on MaxText4b5b24c92andc034bc02f.--zb-split-last on: 1F1B 1337.5 ms, ZB-H1 1262.0, ZB-H2 1230.6 (1205.4 with two W buffers),--vv 2breadth 1157.3.20261117-jax_0.12.0.1):--vv 2breadth 1254.9.--data maxtext, MaxText's kernels at their defaults.20261124-jax_0.12.0.1): the runs above (the zero-bubble ones on an earlier revision of this branch, one job evicted twice and resumed), and at PP=2 with 8 microbatches 1F1B 3227.6 ms, ZB-H1 3257.6 (1F1B's order without--zb-split-last; losses bit for bit).Not run yet:
gclustercommand (the GKE run used xpk);gpu_onlytests on a GPU;OnTpuon a v6e-4 (its CPU twin passes);--vv 1breadth;Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.skip-ci-testsso only CPU/lint/docs checks run during review; a bot removes it after 2 approvals on a 1-commit PR to run TPU/GPU suites, or remove it yourself / ask a maintainer on fork PRs to run them sooner. On TPU7X, only the TPU tests that the PR adds or modifies run; add therun-tpu7xlabel to run the full TPU7X suite.)