[JAX] Let XLA CSE identical MXFP8 quantizes and drop the per-quantize placeholders #3917
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 335 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3917"
general
weight: 0.35
greptile-apps[bot]
Description
Two small changes to the JAX quantize primitive in
transformer_engine/jax/cpp_extensions/quantization.py, so that XLA can CSE identical MXFP8 quantizes and stops inserting a copy before each one.operand_output_aliases={2: 4}, donating the amax operand toupdated_amax. The FFI only writesupdated_amaxfor tensor scaling. For MXFP8, amax is a constant zero that is never written. The alias still made XLA insert a 4-byte D2D copy before every quantize, and it gave each quantize its own output buffer. That kept otherwise identical quantizes distinct.scaleandrht_matrixplaceholders in_quantize_dbias_implwerejnp.empty. That lowers to oneAllocateBuffercustom call per quantize, so two quantizes of the same tensor never had identical operands and could not be CSE'd. This happens, for example, when one activation feeds several projections.Measured on a DeepSeek-V4 MaxText training stack (GB300, MXFP8 recipe):
Fixes # (none)
Type of change
Changes
Please list the changes introduced in this PR:
updated_amaxalias, and haveimpl()pass the input amax through asupdated_amax. Tensor scaling and NVFP4 keep the alias.jnp.zerosconstants instead ofjnp.emptyfor thescaleandrht_matrixplaceholders in_quantize_dbias_impl. When a real scale or RHT matrix is needed, it still replaces the placeholder as before.Checklist: