[torchao]: fix how FqnConfig is resolved and handled - #14686
Open
sayakpaul wants to merge 3 commits into
Open
Conversation
sayakpaul
force-pushed
the
resolve-fqn-config-torchao
branch
from
September 2, 2026 04:10
0e34e7d to
a2b9a5f
Compare
sayakpaul
commented
Sep 2, 2026
| import torch | ||
| import torch.nn as nn | ||
|
|
||
| if is_torch_version(">=", "2.5"): |
sayakpaul
commented
Sep 2, 2026
| return None | ||
|
|
||
|
|
||
| def _fqn_to_config_weight_sizes(config: "FqnToConfig") -> tuple[set[str | None], bool]: |
Member
Author
There was a problem hiding this comment.
Needed to determine CUDA warmup factor from FqnConfig.
sayakpaul
commented
Sep 2, 2026
| return size_digits, leaves_modules_unquantized | ||
|
|
||
|
|
||
| def _resolve_fqn_to_config(config: "FqnToConfig", module_fqn: str, param_fqn: str): |
Member
Author
There was a problem hiding this comment.
Needed so that we can properly resolve config for a single linear layer because that is how we create the quantized params, i.e., iterating over the modules and calling quantize_() over them individually.
sayakpaul
commented
Sep 2, 2026
Comment on lines
-239
to
-249
| if isinstance(target_dtype, SUPPORTED_TORCH_DTYPES_FOR_QUANTIZATION): | ||
| return target_dtype | ||
|
|
||
| # We need one of the supported dtypes to be selected in order for accelerate to determine | ||
| # the total size of modules/parameters for auto device placement. | ||
| possible_device_maps = ["auto", "balanced", "balanced_low_0", "sequential"] | ||
| raise ValueError( | ||
| f"You have set `device_map` as one of {possible_device_maps} on a TorchAO quantized model but a suitable target dtype " | ||
| f"could not be inferred. The supported target_dtypes are: {SUPPORTED_TORCH_DTYPES_FOR_QUANTIZATION}. If you think the " | ||
| f"dtype you are using should be supported, please open an issue at https://github.com/huggingface/diffusers/issues." | ||
| ) |
|
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.
Fixes #14667. It surfaced additional issues which I have fixed as well.
I have run the TorchAO test suite and it's green.