Skip to content

Conversation

@andrewor14
Copy link
Contributor

Summary: FqnToConfig does not handle module swap configs like QATConfig today because it does not reassign the replaced modules, but instead assumes there is no need to do so because the underlying tensors are swapped. This breaks when the user tries to use FqnToConfig with QATConfig, which does not rely on tensor subclasses. This commit fixes this by making the replacement logic in FqnToConfig more general.

Fixes #3490.

Test Plan:

python test/quantization/test_quant_api.py -k test_fqn_config_quantized_nested_module_module_swap

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3492

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 8bfc239 with merge base ff6d9e2 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@andrewor14 andrewor14 requested a review from jcaip December 15, 2025 22:22
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 15, 2025
@andrewor14 andrewor14 added the topic: bug fix Use this tag for PRs that fix bugs label Dec 15, 2025
**Summary:** `FqnToConfig` does not handle module swap configs
like `QATConfig` today because it does not reassign the replaced
modules, but instead assumes there is no need to do so because
the underlying tensors are swapped. This breaks when the user
tries to use `FqnToConfig` with `QATConfig`, which does not
rely on tensor subclasses. This commit fixes this by making
the replacement logic in `FqnToConfig` more general.

Fixes #3490.

**Test Plan:**
```
python test/quantization/test_quant_api.py -k test_fqn_config_quantized_nested_module_module_swap
```
module.to(device=device)
return
if isinstance(config, AOBaseConfig):
_fqn_to_config_replace(config, model, device=device)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is hard to follow, would it be cleaner to use iteration instead of recursion here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: bug fix Use this tag for PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FqnToConfig doesn't handle module swaps

3 participants