Skip to content

[pat] Fix SVD class leakage into nn.Linear from #4587 - #4613

Merged
lisjin merged 2 commits into
mainfrom
lvj/patch-svd-class
Jul 26, 2026
Merged

[pat] Fix SVD class leakage into nn.Linear from #4587#4613
lisjin merged 2 commits into
mainfrom
lvj/patch-svd-class

Conversation

@lisjin

@lisjin lisjin commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

From #4587: insert_svd_modules_ patched the SVD descriptor onto module.__class__, mutating the shared class process-wide. Downstream .weight accesses then hit latent_svd and raised:

AttributeError("'Linear' object has no attribute 'weight_U'")

breaking torch.compile tests across the int4/int8/float8 workflows.

Fix: patch a private per-instance subclass instead. Also skips global prox types in through-heal to avoid a TypeError.

insert_svd_modules_ installed the SVD-reconstruction descriptor on
module.__class__, mutating the shared class (e.g. nn.Linear) for every
module in the process. After any pat SVD test ran, unrelated modules'
weight access routed through latent_svd and raised
AttributeError("'Linear' object has no attribute 'weight_U'") -- breaking
downstream tests in the same process (notably torch.compile paths across
the int4/int8/float8 quantization workflows).

Install the descriptor on a private per-instance subclass instead so the
patch no longer leaks onto the shared class.
@lisjin lisjin added the module: not user facing Use this tag if you don't want this PR to show up in release notes label Jul 26, 2026
@lisjin
lisjin requested review from jerryzh168 and vkuzo as code owners July 26, 2026 03:38
@pytorch-bot

pytorch-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

@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 Jul 26, 2026
_apply_prox_to_through_heal_groups always used the per-param
_build_prox_artifacts path, which cannot build GlobalMinSparsityConstraint
(built per-batch in step()) and would raise a confusing TypeError if it
were combined with an SVD grouper and prox_through_heal. Add an early
continue for global prox types, matching the reviewer fix from the qpat
mirror.
@lisjin
lisjin force-pushed the lvj/patch-svd-class branch from 1dd2297 to 544fbe2 Compare July 26, 2026 05:19
@lisjin
lisjin merged commit 5efd55f into main Jul 26, 2026
11 of 13 checks passed
@lisjin
lisjin deleted the lvj/patch-svd-class branch July 26, 2026 05:20
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. module: not user facing Use this tag if you don't want this PR to show up in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant