Skip to content

Fix compressed tensors impl - #47652

Merged
SunMarc merged 3 commits into
mainfrom
update-ct
Jul 31, 2026
Merged

Fix compressed tensors impl #47652
SunMarc merged 3 commits into
mainfrom
update-ct

Conversation

@SunMarc

@SunMarc SunMarc commented Jul 30, 2026

Copy link
Copy Markdown
Member

CI

What does this PR do?

This PR updates CT implementation. One of the PR were a bit too breaking so we are requiring to set an attributed to unlock the optimized inference path vs before where it was the default one. Also, we don't decompress the model by default as this was creating issues.

cc @kylesayrs


FP8-kernel modules were never wrapped (their weights loaded directly in FP8) and hold no
compressed-tensors scheme, so neither the call below nor that hook touches them."""
if self.quantization_config.dequantize and self.quantization_config.is_quantization_compressed:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we bring this back, should help with dequantizing without using too much memory cc @kylesayrs

# `use_optimized_inference` has been resolved against the checkpoint by
# `CompressedTensorsConfig.post_init`; what is left to check is whether the hardware can run
# the kernels. When it cannot, the model goes through the regular compressed-tensors route.
self.use_fp8_kernel = self.quantization_config.use_optimized_inference

@SunMarc SunMarc Jul 30, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have use_optimized_inference arg now that the user must set if they want to hit non CT path

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@kylesayrs kylesayrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TYSM!

dequantize: bool = False,
use_optimized_inference: bool = False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to have this default to True

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever you prefer, this was a bit breaking on your side no ? We can wait a bit until you start using this arg and always set it to False on your side.


## FP8 kernel acceleration

Pass `use_optimized_inference=True` to keep an FP8 compressed-tensors model in FP8 and run its matmuls through hardware-accelerated FP8 kernels (`torch._scaled_mm`), instead of dequantizing the weights back to BF16. Keeping weights in FP8 throughout inference lowers memory usage and speeds up computation. This is inference only, so leave it off to fine-tune.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should primarily mention the public api, the reason being that the public one dispatches to torch._scaled_mm_v2 and torch._scaled_mm

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed !

@IlyasMoutawwakil IlyasMoutawwakil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: compressed_tensors_integration

@SunMarc
SunMarc enabled auto-merge July 31, 2026 14:54
@SunMarc
SunMarc added this pull request to the merge queue Jul 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 30640404473:1
Result: success | Jobs: 16 | Tests: 178,176 | Failures: 1 | Duration: 17h 25m

Merged via the queue into main with commit 20c8db7 Jul 31, 2026
112 checks passed
@SunMarc
SunMarc deleted the update-ct branch July 31, 2026 15:34
Sainava pushed a commit to Sainava/Sai-transformers that referenced this pull request Aug 3, 2026
* fix compressed tensors

* update
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.

4 participants