Repository navigation
Conversation
Import compressed-tensors NVFP4 bytes and scales into torchao with explicit BF16 activations, preserving packed weights without requantization. Adapt reciprocal global scales, allow absent input scales, and use scoped converters for base-model prefix handling. Limit the path to ordinary dense Linear modules on one device, account for packed storage during memory planning, and document unsupported operations. Keep the existing loading routes opt-out by default. Expose is_qat_trainable as a boolean property as expected by the trainer, with a regression assertion for the existing compressed route. Include compact CPU/accelerator loading and validation tests.
eryk-roch
marked this pull request as draft
November 24, 2026 12:21
Document the NVFP4-only scope and reuse on devices without native FP4 GEMMs. Remove the validation-specific revision from the usage example. Import NVFP4Tensor directly for conversion and post-load validation, while retaining the early dependency check and existing loader hooks.
Remove redundant deserializer checks covered by module preparation and the single-device loader. Share NVFP4 scheme validation while preserving distinct weight and activation requirements. Retain checkpoint integrity and scope guards, shorten the documentation, and add compact regression coverage for the shared validation.
Replace duplicate input validation with an assertion documenting the config invariant established by post_init in the quantizer constructor.
eryk-roch
marked this pull request as ready for review
December 1, 2026 13:54
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: compressed_tensors_integration |
Member
|
cc @SunMarc for quantization |
This branch has not been deployed
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.
What does this PR do?
Adds
CompressedTensorsConfig(weight_only=True)to load compressed-tensors NVFP4 checkpoints, such as RedHatAI/Qwen3-14B-NVFP4`, into torchao weights without an external adapter or requantization.This is explicitly W4A16: activation quantization is disabled in favor of BF16, so outputs can differ from the original W4A4 deployment. That is why this uses a separate option rather than
use_optimized_inference. Torchao dequantizes weights per forward call; this is not a fused FP4 kernel.compressed-tensors>=0.15.0,torchao>=0.16.0, explicit BF16 and ordinary dense Linear modules on one device. Unsupported combinations are rejected and documented.is_qat_trainablea boolean property, as the trainer expects.Related: #49779 and #49823 target the fine-grained machinery. This PR instead adds an opt-in torchao W4A16 path to the existing compressed-tensors quantizer.
Validation
6 tests passed on CPU and Intel XPU.
Coverage includes weight/output parity, generation, sharding, prefix handling, optional activation scales and malformed tensors. The CPU prefix/optional-scale case fails on unmodified main with missing activation scales because main ignores the new option and selects the existing CT route.
CUDA: 6/6 passed with each of torchao 0.16.0 and 0.19.0+git2b2fa0da on NVIDIA RTX PRO 4500 Blackwell (Windows, torch 2.15 dev, CUDA 13.0). Torchao 0.16 skipped incompatible C++ extensions; this W4A16 path passed
without them.
Changed-file lint/format and config/quantizer type checks passed. Extended checks still report two pre-existing FP8 type errors; the full style runner also hit unrelated comment findings without Git history on the DUT. Full repository CI remains unverified.
Who can review?
@SunMarc @IlyasMoutawwakil