Skip to content

Add: use MXFP8 and MXFP4 in DeepSeek V4 Pro - #911

Draft
yanghaoran29 wants to merge 1 commit into
hw-native-sys:mainfrom
yanghaoran29:feat/prototype-mxfp8-shared-expert-down-projection
Draft

Add: use MXFP8 and MXFP4 in DeepSeek V4 Pro#911
yanghaoran29 wants to merge 1 commit into
hw-native-sys:mainfrom
yanghaoran29:feat/prototype-mxfp8-shared-expert-down-projection

Conversation

@yanghaoran29

@yanghaoran29 yanghaoran29 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use dynamic MXFP8 activation quantization for dense QKV, output, MTP,
    gate, and shared-expert projections.
  • Store routed-expert weights as MXFP4, convert each MXFP4 tile to MXFP8,
    and materialize its values/scales through GM before matmul_mx.
  • Wire the packed formats through decode, prefill, layer, MTP, and forward
    entries, and avoid duplicate shared-memory copies for large immutable
    resident golden inputs.
  • Keep quant_mx and matmul_mx in separate tasks. Putting both in one
    mixed InCore task is intentionally not supported by this PR.

Test environment

  • A5, EP2
  • PyPTO 72d9b9f (backup/pr-2372-ai-comments)
  • simpler 3165cc8
  • remote PTOAS 0.58
  • pto-isa 0cefc9a
  • Error columns below are the percentage of elements whose relative error is
    greater than 0.1% / 0.3% / 0.5% / 1% / 3% / 5% / 10%.
  • Precision checks were diagnostic only; runtime/compiler errors remained
    fatal.

A5 operator results

Operator Runtime Error percentages at 0.1/0.3/0.5/1/3/5/10%
shared expert PASS 0.019182 / 0.008719 / 0.003488 / 0 / 0 / 0 / 0
routed expert PASS 0.000173 / 0.000127 / 0.000023 / 0 / 0 / 0 / 0
gate (floating outputs) PASS 0 / 0 / 0 / 0 / 0 / 0 / 0
QKV+RoPE decode PASS 0.003407 / 0.002082 / 0.000568 / 0 / 0 / 0 / 0
QKV+RoPE prefill PASS 0.006375 / 0.003584 / 0.000781 / 0 / 0 / 0 / 0
MTP projection decode PASS 0 / 0 / 0 / 0 / 0 / 0 / 0
MTP projection prefill PASS 0.002507 / 0 / 0 / 0 / 0 / 0 / 0
indexer decode (floating outputs) PASS 0 / 0 / 0 / 0 / 0 / 0 / 0
indexer prefill (floating outputs) PASS 0.112305 / 0.021973 / 0.002441 / 0 / 0 / 0 / 0
sparse decode / HCA / SWA PASS 0 / 0 / 0 / 0 / 0 / 0 / 0
sparse prefill PASS 0 / 0 / 0 / 0 / 0 / 0 / 0
attention decode CSA PASS 0.000012 / 0.000012 / 0 / 0 / 0 / 0 / 0
attention decode HCA PASS 0.000928 / 0.000476 / 0.000139 / 0 / 0 / 0 / 0
attention decode SWA PASS 0.002611 / 0.001450 / 0.000383 / 0 / 0 / 0 / 0
attention prefill CSA PASS 0.459480 / 0.172491 / 0.071244 / 0.007182 / 0.000008 / 0 / 0
attention prefill HCA PASS 0.226933 / 0.008782 / 0.000481 / 0 / 0 / 0 / 0
attention prefill SWA PASS 0.113114 / 0.003549 / 0.000216 / 0 / 0 / 0 / 0
MoE PASS 5.783081 / 3.843035 / 2.327183 / 1.055690 / 0.310843 / 0.091771 / 0.001744
decode layer PASS 0.885480 / 0.569553 / 0.389743 / 0.170661 / 0.018183 / 0.002878 / 0.000006
prefill layer PASS 1.117814 / 1.015878 / 0.949986 / 0.813411 / 0.504222 / 0.341969 / 0.147878
decode MTP PASS 1.547509 / 1.109450 / 0.788132 / 0.369208 / 0.036886 / 0.005297 / 0.000017
prefill MTP PASS 3.605382 / 3.477694 / 3.402367 / 3.296920 / 3.067186 / 2.920182 / 2.657757

Integer-output exact mismatch rates: gate x_norm 0.003488%, decode
index-cache 0.000095%, decode top-k 0.006104%, prefill index-cache 0.000191%,
and prefill top-k 0.012207%.

The bounded full-forward runtime smoke passed before the final rebase: decode
with five layers and prefill with three layers. Full 61-layer fixtures exceed
the available host/device memory on this test machine. After rebasing onto
37d6115, tests/golden/test_runner.py passes (74 tests) and all changed
Python sources compile. The rebased full-forward compile reaches the unchanged
upstream lm_head_greedy_sample, where PTOAS 0.58 rejects sort32 without an
explicit temporary; no MX operator fails before that point.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fb867d94-8813-46a2-9b1f-f909efe14b49

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yanghaoran29
yanghaoran29 force-pushed the feat/prototype-mxfp8-shared-expert-down-projection branch 2 times, most recently from b975474 to ac3e17d Compare August 7, 2026 07:39
@yanghaoran29
yanghaoran29 force-pushed the feat/prototype-mxfp8-shared-expert-down-projection branch from ac3e17d to eed5080 Compare August 16, 2026 13:55
- Add dynamic MXFP8 quantization to dense projections and shared experts
- Store routed expert weights as MXFP4 and materialize converted MXFP8
  values and scales through GM before matmul
- Wire packed MX formats through decode, prefill, layer, MTP, and forward
  entries with bounded full-forward smoke fixtures
- Avoid shared-memory copies for immutable resident golden inputs
- Document the separate quant_mx and matmul_mx task limitation
@yanghaoran29 yanghaoran29 changed the title Add: prototype MXFP8 shared-expert down projection Add: use MXFP8 and MXFP4 in DeepSeek V4 Pro Aug 16, 2026
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.

1 participant