[gguf][torch.compile time] Convert to plain tensor earlier in dequantize_gguf_tensor#13166
Merged
DN6 merged 1 commit intohuggingface:mainfrom Feb 20, 2026
Merged
[gguf][torch.compile time] Convert to plain tensor earlier in dequantize_gguf_tensor#13166DN6 merged 1 commit intohuggingface:mainfrom
DN6 merged 1 commit intohuggingface:mainfrom
Conversation
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.
sayakpaul
reviewed
Feb 20, 2026
Comment on lines
+519
to
+520
| # Conver to plain tensor to avoid unnecessary __torch_function__ overhead. | ||
| tensor = tensor.as_tensor() |
Member
There was a problem hiding this comment.
Does it have any impact on quality?
DN6
approved these changes
Feb 20, 2026
Collaborator
DN6
left a comment
There was a problem hiding this comment.
Good catch! Thanks @anijain2305 👍🏽
|
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. |
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.
Once
dequantize_gguf_tensorfetches 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