Skip to content

add DeepSeek-V4-Flash-0731 support and mxfp4->fp8 converter - #2717

Merged
yueming-yuan merged 12 commits into
mainfrom
yueming/deepseek-v4-0731
Aug 24, 2026
Merged

add DeepSeek-V4-Flash-0731 support and mxfp4->fp8 converter#2717
yueming-yuan merged 12 commits into
mainfrom
yueming/deepseek-v4-0731

Conversation

@yueming-yuan

Copy link
Copy Markdown
Collaborator

Summary

Adds DeepSeek-V4-Flash-0731 (official deepseek-ai release, MXFP4 routed experts) to the DeepSeek-V4 launcher. The architecture is identical to DeepSeek-V4-Flash, so this is wiring plus one new conversion stage:

  • tools/convert_mxfp4_to_fp8.py: casts packed-e2m1fn expert weights (int8 + per-(1,32)-block ue8m0 scales) losslessly to e4m3fn with (128,128)-block e8m0 scales — the same cast_e2m1fn_to_e4m3fn the official inference/convert.py uses, producing the sgl-project FP8 repackage layout. All other tensors are copied unchanged; expert_dtype is dropped from config.json.
  • scripts/run_deepseek_v4.py: new --model-name DeepSeek-V4-Flash-0731 (org deepseek-ai, megatron type deepseek-v4-flash), new prepare-fp8 stage chained into full-train (sentinel-skipped), rollout/bf16 stages read from the cast FP8 dir. Downstream (fp8_cast_bf16, torch_dist conversion, fp8 rollout) is byte-identical to the DeepSeek-V4-Flash-FP8 path.

Validation

  • Converter numeric round-trip on GPU: dequant(mxfp4) == dequant(cast fp8), bit-exact.
  • tests/fast/launch_scripts: 39 passed; tests/manual/launch_scripts: 455 passed (the 4 scripts/amd/* errors are pre-existing on main), prepare_fp8 snapshot recorded.
  • 8-node GB300 (32 GPU) full-train bringup running: TP2/PP8/CP2/EP4, fp8 rollout, DAPO 4k response len — will report once steady.

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@yueming-yuan yueming-yuan changed the title DeepSeek-V4-Flash-0731 support: lossless MXFP4->FP8 cast + launcher wiring add DeepSeek-V4-Flash-0731 support Aug 23, 2026
@yueming-yuan yueming-yuan changed the title add DeepSeek-V4-Flash-0731 support add DeepSeek-V4-Flash-0731 support and mxfp4->fp8 converter Aug 23, 2026
Triton weight_dequant (and the sgl FP8 repackage convention) expect float32
blockwise scales; e8m0fnu KeyError'd inside triton during fp8_cast_bf16.
The broad except swallowed triton's KeyError('float8_e8m0fnu') from
weight_dequant and mislabeled it as a missing scale_inv tensor.
Official ue8m0 checkpoints (DeepSeek-V4-Flash-0731) store every fp8 scale
as float8_e8m0fnu; cast to float32 (exact) before the triton dequant.
tp4 engines keep a per-rank memory-saver host shadow of the full engine
weights (~75GB fp8 x 4 ranks/node); with the colocated Megatron actors
loaded on top this OOMs the ~1TB host RAM. tp8 engines spanning 2 nodes
halve the shadow.
…ry=True)

Checkpoint loading churns through millions of MB-scale CPU tensors that
glibc keeps in its arenas after free (below the 32MB dynamic mmap
threshold), so actor RSS stays at the loading high-water mark (~26GB/rank
observed). _host_emptyCache only covers the pinned cache; trim the glibc
arenas too so the pre-sleep clear returns the pages before the offload
backup is allocated.
Frozen params (requires_grad=False, e.g. --moe-router-freeze-gate) are
excluded from the DDP param buffers so they have no master weight to
rebuild from; back them up alongside the fp32 params. DSV4 hit this via
its frozen router gate.
The loading residency it targeted is not glibc free arena pages (trim
reclaimed ~0.05GB against a ~26-38GB residual); root cause still open.
@yueming-yuan yueming-yuan added the run-ci-model-scripts Run model script smoke tests label Aug 24, 2026

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

LGTM

@yueming-yuan
yueming-yuan merged commit 851ddba into main Aug 24, 2026
23 of 30 checks passed
@yueming-yuan
yueming-yuan deleted the yueming/deepseek-v4-0731 branch August 24, 2026 06:42
guapisolo added a commit that referenced this pull request Aug 24, 2026
PR #2717 treated every four-GPU node as the GB300 full-model profile,
which routed the single-node 4-layer H200 smoke test into TP8/EP8.

Exclude the 4-layer model from the GB300 branch and keep only the two
launcher regression cases that distinguish the intended profiles.
@Suhail

Suhail commented Aug 24, 2026

Copy link
Copy Markdown

Hi @yueming-yuan - did you test what logprob differences ended up being between rollout/actor by chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci-model-scripts Run model script smoke tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants