Add backward overrides and 1x16 weights to NVFP4 four-over-six - #8
Draft
wolfcomos wants to merge 1 commit into
Draft
Add backward overrides and 1x16 weights to NVFP4 four-over-six#8wolfcomos wants to merge 1 commit into
wolfcomos wants to merge 1 commit into
Conversation
Mirrors TransformerEngine's NVTE_BACKWARD_OVERRIDE (PRs pytorch#2644/pytorch#3141) on four_over_six_mm / four_over_six_linear / NVFP4FourOverSixLinear: - backward_override="quantized" | "high_precision" | "dequantized"; None keeps the existing defaults (per-tensor -> quantized backward, row-scaled -> high-precision backward), so current callers are unchanged. "dequantized" saves the rowwise fprop-quantized operands (4-bit codes + scales) and backpropagates through bf16 GEMMs on their dequantizations - the RL train/inference-consistency mode. - four_over_six_dequantize: public inverse transcribed op-for-op from TransformerEngine's dequantize_nvfp4.cuh ((scale * amax) * factor_inv with a correctly-rounded FP32 reciprocal), per-tensor and row-scaled. - weight_block="1x16" quantizes weights with 1x16 blocks, mirroring NVTE_NVFP4_DISABLE_2D_QUANTIZATION=1 (the miles NVFP4 RL recipe). Validation (GB200, TE 2.19 devel container): full suite 83 passed / 13 skipped, including new bitwise tests - dequantize vs TE's NVFP4 dequantize kernel 8/8 bitwise (256/448 x per-tensor/row-scaled x bf16/fp32 out), high_precision grads == bf16 GEMMs on the original operands, dequantized grads == bf16 GEMMs on dequantized fprop operands, and row-scaled default backward unchanged bitwise. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Mirrors TransformerEngine's NVTE_BACKWARD_OVERRIDE (PRs pytorch#2644/pytorch#3141) on four_over_six_mm / four_over_six_linear / NVFP4FourOverSixLinear:
Validation (GB200, TE 2.19 devel container): full suite 83 passed / 13 skipped, including new bitwise tests - dequantize vs TE's NVFP4 dequantize kernel 8/8 bitwise (256/448 x per-tensor/row-scaled x bf16/fp32 out), high_precision grads == bf16 GEMMs on the original operands, dequantized grads == bf16 GEMMs on dequantized fprop operands, and row-scaled default backward unchanged bitwise.