[None][feat] Support NVFP4 dsv4#14026
Open
Tracin wants to merge 7 commits into
Open
Conversation
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
…P4 block-scale kernel without bias
The TRTLLM-Gen fp4-block-scale fused-MoE kernel (`run_fp4_block_scale_moe`
in `fused_moe_trtllm_gen.py:760`, used for NVFP4 / W4A16-MXFP4 /
W4A8-MXFP4-MXFP8) only implements the GPT-OSS-style SwiGLU clamping
path, which expects `bias`, `swiglu_alpha`, `swiglu_beta` to be set
alongside `swiglu_limit`. DeepSeek-V4 has no FFN bias, so passing
`swiglu_limit` through that kernel collapses the routed-experts output
to all zeros.
`tests/unittest/_torch/modules/test_fused_moe.py::test_fused_moe_nvfp4`
only exercises `swiglu_limit` via `gptoss_style=True` (which also sets
the bias and alpha/beta tensors), so this bias-free combination is
uncovered by tests.
Minimal repro (single-rank, layer-0 only):
python scripts/dsv4_nvfp4_one_layer_repro.py --routing dsv4-hashed
python scripts/dsv4_nvfp4_one_layer_repro.py --routing dsv4-hashed \
--swiglu-limit 10.0
The only difference between these two invocations is the
`--swiglu-limit` flag, and that single change flips the routed-MoE
output absmax from ~0.17 to 0.
Workaround applied here: when `moe_cls` resolves to TRTLLMGenFusedMoE
or WideEPMoE and the experts quant mode uses any FP4 block-scale
variant, do not construct the `moe_swiglu_limit` tensor. The shared
experts still apply the limit via the standard `GatedMLP` linear stack
below, so only the routed-experts pre-activation clamping is dropped.
Verified on a 2-layer truncated `flash-nvfp4-experts-v3.5` checkpoint
via the DSv4 dump infra: `layer.0.routed_output` went from absmax=0,
nnz=0/32768 to absmax=0.64, nnz=32768/32768.
The proper long-term fix is on the kernel side -- either add a no-bias
clamping variant to `run_fp4_block_scale_moe`, have the kernel skip the
clamp when bias is None, or enforce that all four (bias, swiglu_alpha,
swiglu_beta, swiglu_limit) be set together and gate the construction at
the Python level so the silent-zero failure mode becomes impossible.
Signed-off-by: Barry Kang <jinshik@nvidia.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
Signed-off-by: Tracin <10434017+Tracin@users.noreply.github.com>
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.
@coderabbitai summary
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.