[pat] Fix SVD class leakage into nn.Linear from #4587 - #4613
Merged
Conversation
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.
🔗 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. |
_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
force-pushed
the
lvj/patch-svd-class
branch
from
July 26, 2026 05:19
1dd2297 to
544fbe2
Compare
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.
From #4587:
insert_svd_modules_patched the SVD descriptor ontomodule.__class__, mutating the shared class process-wide. Downstream.weightaccesses then hitlatent_svdand raised:breaking
torch.compiletests 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.