Skip to content

Add backward overrides and 1x16 weights to NVFP4 four-over-six - #8

Draft
wolfcomos wants to merge 1 commit into
nvfp4-four-over-six-rowwisefrom
nvfp4-four-over-six-backward-overrides
Draft

Add backward overrides and 1x16 weights to NVFP4 four-over-six#8
wolfcomos wants to merge 1 commit into
nvfp4-four-over-six-rowwisefrom
nvfp4-four-over-six-backward-overrides

Conversation

@wolfcomos

Copy link
Copy Markdown
Owner

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.

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>
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