Skip to content

Comments

[gguf][torch.compile time] Convert to plain tensor earlier in dequantize_gguf_tensor#13166

Merged
DN6 merged 1 commit intohuggingface:mainfrom
anijain2305:gguf-fix
Feb 20, 2026
Merged

[gguf][torch.compile time] Convert to plain tensor earlier in dequantize_gguf_tensor#13166
DN6 merged 1 commit intohuggingface:mainfrom
anijain2305:gguf-fix

Conversation

@anijain2305
Copy link
Contributor

@anijain2305 anijain2305 commented Feb 19, 2026

Once dequantize_gguf_tensor fetches the quant_type attributed from the GGUFParamter tensor subclass, there is no further need of running the actual dequantize operations on the Tensor subclass, we can just convert to plain tensor right away.

This not only makes PyTorch eager faster, but reduces torch.compile tracer compile time from 36 seconds to 10 seconds for auroflow quantized model, because there is lot less code to trace now.

cc @yiyixuxu @sayakpaul

Once dequantize_gguf_tensor fetches the quant_type attributed from the
GGUFParamter tensor subclass, there is no further need of running the
actual dequantize operations on the Tensor subclass, we can just convert
to plain tensor right away.

This not only makes PyTorch eager faster, but reduces torch.compile
tracer compile time from 36 seconds to 10 seconds, because there is lot
less code to trace now.
Comment on lines +519 to +520
# Conver to plain tensor to avoid unnecessary __torch_function__ overhead.
tensor = tensor.as_tensor()
Copy link
Member

Choose a reason for hiding this comment

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

Does it have any impact on quality?

@sayakpaul sayakpaul requested a review from DN6 February 20, 2026 03:05
Copy link
Collaborator

@DN6 DN6 left a comment

Choose a reason for hiding this comment

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

Good catch! Thanks @anijain2305 👍🏽

@HuggingFaceDocBuilderDev

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.

@DN6 DN6 merged commit 01de02e into huggingface:main Feb 20, 2026
10 of 11 checks passed
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