Skip to content

[Transform] SpinQuant R4 #1746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/llmcompressor/modifiers/transform/spinquant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SpinQuantModifier(Modifier, use_enum_values=True):
@field_validator("randomize", "learnable", mode="before")
def validate_not_implemented(cls, value, info: ValidationInfo):
if value:
raise NotImplementedError(f"{info.field_name} is not supported right now")
raise NotImplementedError(f"{info.field_name} is not supported as of now")
return value

@field_validator("rotations", mode="before")
Expand Down Expand Up @@ -237,10 +237,24 @@ def _create_r2_scheme(self, model: PreTrainedModel) -> TransformScheme:

def _create_r3_scheme(self) -> TransformScheme:
raise NotImplementedError(
"SpinQuant R3 and R4 rotations will be added in a future release"
"SpinQuant R3 rotations will be added in a future release"
)

def _create_r4_scheme(self) -> TransformScheme:
raise NotImplementedError(
"SpinQuant R3 and R4 rotations will be added in a future release"
)
return TransformScheme(
type=self.transform_type,
randomize=self.randomize,
requires_grad=self.learnable,
precision=self.precision,
apply=[
TransformArgs(
targets=[*self.mappings.mlp_out],
location="input",
),
TransformArgs(
targets=[*self.mappings.mlp_out],
location="weight_input",
inverse=True,
),
],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's a good practice to end files with a newline character. This helps prevent issues with file concatenation and some version control systems. This file is missing one.

Suggested change
)
)

Loading