Skip to content

[Kernel][SM70] Fold DeepSeek V4 MXFP4 decode exponents - #312

Closed
yangzhuxinyzx wants to merge 1 commit into
agent/v100-dsv4-pp2tp4-fp8-prescaled-decode-20260826from
agent/v100-dsv4-pp2tp4-mxfp4-prescaled-decode-20260826
Closed

yangzhuxinyzx wants to merge 1 commit into
agent/v100-dsv4-pp2tp4-fp8-prescaled-decode-20260826from
agent/v100-dsv4-pp2tp4-mxfp4-prescaled-decode-20260826

Conversation

@yangzhuxinyzx

Copy link
Copy Markdown
Contributor

Purpose

Stacked on #309. Fold the exact E2M1 conversion factor into adjusted UE8M0 exponents for the DeepSeek V4 PP2 x TP4 M=6 direct-order decode shapes. Preserve the ordinary measured CTA, split-K, and swizzle so the reduction order and output bits stay unchanged.

Test Plan

  • Audit every MXFP4 scale byte in the V4-Flash checkpoint.
  • Enumerate every signed E2M1 code across the observed exponent interval.
  • Compile the affected SM70 CUDA translation units and link the stacked extension.
  • Run real-weight, changing-input CUDA Graph A/B/B/A operator checks.
  • Run the focused CPU unit tests and Ruff.
  • Run matched PP2 x TP4 full-model speed and GSM8K-64 before promoting from Draft.

Test Result

  • Checkpoint audit: 35,718 scale tensors, 9,261,408,000 bytes; raw E8M0 114--126, adjusted half exponents 2--14, folded exponents 16--28.
  • Exhaustive arithmetic proof: 208/208 FP16 bit patterns equal.
  • Final extension SHA256: 5b8cd4cd5796b8180b6e209c5737df753fd08c4118cbc3363741dce65785e2e6.
  • Real layer-0 TP4-rank-0 weights: 64/64 dynamic CUDA Graph cases bitwise equal at W13, SwiGLU, and W2.
  • Pipeline-first A/B/B/A median: 95.141 -> 53.163 us/layer, projecting 1.805 ms/token across 43 layers.
  • pytest focused exponent-fold cases: 5 passed.
  • Ruff and git diff --check: passed.
  • Full-model and GSM8K-64: pending GPU availability; keep Draft.

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Latest-main audit update (main d9d0da2): leave this PR open, but do not merge the current performance claim yet.

Source audit found repairable issues in the original stack: C++ reads the environment directly and can bypass the Python scale audit; the old extension capability is not distinguishable; the route logs before folded-kernel selection; and a missing mirrored kernel returns no launch instead of the numerically valid ordinary transform. I rebuilt a local repair with a distinct folded op, per-layer validated admission, default fallback / explicit fail-closed behavior, generic tensor/runtime naming, and ordinary-kernel fallback. Focused math/config/module tests, full pre-commit, and standalone compilation of torch_bindings.cpp, awq_sm70_gemm.cu, gemm.cu, and sm70_884_4.cu all pass.

However, the stored performance evidence does not pass attribution:

  • r1 warm pipeline: 52.968 -> 58.177 us/layer (regression).
  • r2 warm pipeline: 52.766 -> 53.096 us/layer (0.330 us/layer regression).
  • r3/r4 pipeline-first: about 95 -> 53 us, but the advantage moves to whichever graph is captured after the first baseline has established/tuned dispatch state.
  • In r4, individually warmed W13 is 32.421 -> 32.706 us and W2 is 19.183 -> 19.302 us, both slightly slower folded.

This pattern is consistent with graph-capture/dispatch-cache order, not a 1.805 ms/token exponent-fold gain. The production-relevant gate must independently prewarm identical ordinary tactics before capturing each arm, use the merged direct-order main baseline, and then show a positive A/B/B/A result. All eight V100s are currently occupied by existing services, so I am not perturbing them for a rerun.

I am not closing #312. Once clean matched evidence is available, the repaired source design can be promoted and merged; until then, merging or default-enabling it would import a measured warm-path regression.

@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Public development has ended and this PR head was preserved in the private migration archive before closure. The public repository is frozen at v1.3.0 and will be archived read-only. Thank you for the contribution.

@1CatAI 1CatAI locked and limited conversation to collaborators Aug 26, 2026
@yangzhuxinyzx
yangzhuxinyzx deleted the agent/v100-dsv4-pp2tp4-mxfp4-prescaled-decode-20260826 branch August 26, 2026 07:55
@yangzhuxinyzx
yangzhuxinyzx restored the agent/v100-dsv4-pp2tp4-mxfp4-prescaled-decode-20260826 branch August 27, 2026 14:35
@1CatAI 1CatAI unlocked this conversation Aug 27, 2026
@yangzhuxinyzx yangzhuxinyzx reopened this Aug 27, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Public development has resumed through #342, and this PR was unarchived, unlocked, and restored as a Draft at its preserved stacked head. The prior audit remains binding: independently warmed folded W13/W2 did not show a positive result, so fresh matched evidence and the repaired fallback design are required before merge.

@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Closing the exponent-fold experiment after the matched warm-path audit failed to reproduce a speed benefit. Independently warmed W13 measured 32.421 → 32.706 µs and W2 19.183 → 19.302 µs; the earlier 95 → 53 µs result depended on graph-capture/dispatch-cache ordering. The exactness checks remain useful evidence, but do not establish an optimization to enable. The ordinary decode path remains unchanged. The branch and audit discussion are retained. Future work can reuse the arithmetic proof with independently warmed, matched tactics before proposing a new optimization.

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