Skip to content

Commit f4d7ec6

Browse files
committed
update docstring
Signed-off-by: Kyle Sayers <[email protected]>
1 parent 7a52b71 commit f4d7ec6

File tree

1 file changed

+18
-14
lines changed
  • src/llmcompressor/modifiers/transform/spinquant

1 file changed

+18
-14
lines changed

src/llmcompressor/modifiers/transform/spinquant/base.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,34 @@ class SpinQuantModifier(Modifier, use_enum_values=True):
5555
A mapping will be inferred if None is provided
5656
:param norm_mappings: Specifies layers within a model to target for norm fusing.
5757
A mapping will be inferred if None is provided
58-
:param transform_config: Optional transform config which overrides `mappings`
58+
:param transform_config: Optional transform config for overriding provided arguments
5959
"""
6060

61-
rotations: List[SpinquantRotation] = Field(default_factory=lambda: ["R1", "R2"])
61+
rotations: List[SpinquantRotation] = Field(
62+
default_factory=lambda: ["R1", "R2"], exclude=True
63+
)
6264
transform_type: Literal["hadamard", "random-hadamard", "random-matrix"] = Field(
63-
default="hadamard"
65+
default="hadamard", exclude=True
6466
)
65-
randomize: bool = Field(default=False)
66-
learnable: bool = Field(default=False)
67+
randomize: bool = Field(default=False, exclude=True)
68+
learnable: bool = Field(default=False, exclude=True)
6769

6870
# norm mappings separate from spinquant mappings to allow users to
6971
# override spinquant mappings with transform_config without overriding norms
70-
mappings: Optional[SpinQuantMapping] = Field(default=None, exclude=True)
71-
norm_mappings: Optional[List[NormMapping]] = Field(default=None, exclude=True)
72+
mappings: Optional[SpinQuantMapping] = Field(
73+
default=None,
74+
repr=False,
75+
exclude=True,
76+
)
77+
norm_mappings: Optional[List[NormMapping]] = Field(
78+
default=None,
79+
repr=False,
80+
exclude=True,
81+
)
7282

7383
# optional override for more fine-grained control
7484
# also included in recipe serialization
75-
transform_config: Optional[TransformConfig] = Field(default=None)
85+
transform_config: Optional[TransformConfig] = Field(default=None, repr=False)
7686

7787
@field_validator("randomize", "learnable", mode="before")
7888
def validate_not_implemented(cls, value, info: ValidationInfo):
@@ -86,12 +96,6 @@ def validate_rotations(cls, value):
8696

8797
def on_initialize(self, state: State, **kwargs) -> bool:
8898
if self.transform_config is not None:
89-
if self.mappings is not None:
90-
raise ValueError(
91-
"Please provide either `transform_config` or `mappings` "
92-
"but not both"
93-
)
94-
9599
return True
96100

97101
self.mappings = infer_mapping_from_model(state.model)

0 commit comments

Comments
 (0)