Skip to content

Conversation

brian-dellabetta
Copy link
Collaborator

SUMMARY:
Fixes #1906

This refactors QuantizationMixin to not update any pydantic fields during validation. Rather than modifying them in order to make them the source of truth, this adds properties resolved_config & resolved_targets that all modifiers should instead use as source of truth. These are resolved once, when needed, and not serialized, which should fix the bug in #1906

TEST PLAN:
"please outline how the changes were tested"

Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Copy link

github-actions bot commented Oct 9, 2025

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>

config_groups: Optional[Dict[str, QuantizationScheme]] = None
targets: Union[str, List[str]] = Field(default_factory=list)
targets: Union[str, List[str]] = Field(default_factory=lambda: ["Linear"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this returns to the default behavior. the setting to ["Linear"] was part of the validation layer that is now removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to conflict with plans to use AWQ without quantization targets? You could also potentially set the AWQ subclass default to be None

Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding a comment encouraging use of resolved_targets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Regarding AWQ, I think we can get by with this default, but allowing the type to be Optional so that a user can set it to None. I wanted to do that with an example in a follow-up PR.
Regarding a comment, I did so in the docstring. If changing the field name to unresolved_targets is preferable, I can do that at as well. WDYT? It can still be serialized as targets by setting alias="targets" in the pydantic Field inputs

Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
"""
if self._resolved_targets is None:
targets = []
for config_group in self.resolved_config.config_groups.values():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider using a set

return (
    set(cg.targets for cg in self.resolved_config.config_groups.values())
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, i wasn't sure about order, but it looks like match_named_modules doesn't care about order. will switch to set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Switched to set, but that for comprehension doesn't work. set([1,2,3,4]) is acceptable but set([[1,2],[3,4]]) is not


config_groups: Optional[Dict[str, QuantizationScheme]] = None
targets: Union[str, List[str]] = Field(default_factory=list)
targets: Union[str, List[str]] = Field(default_factory=lambda: ["Linear"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to conflict with plans to use AWQ without quantization targets? You could also potentially set the AWQ subclass default to be None


config_groups: Optional[Dict[str, QuantizationScheme]] = None
targets: Union[str, List[str]] = Field(default_factory=list)
targets: Union[str, List[str]] = Field(default_factory=lambda: ["Linear"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding a comment encouraging use of resolved_targets

Signed-off-by: Brian Dellabetta <bdellabe@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Serialized QuantizationMixin subclasses fail to load

2 participants