Skip to content

Conversation

@kylesayrs
Copy link
Contributor

@kylesayrs kylesayrs commented Aug 8, 2025

Online Hadamard Rotations

Screenshot 2025-08-26 at 20 22 12

Purpose

  • Support online linear transforms for models compressed with CompressedTensors

Changes

Added Transforms Weight Loading

  • Implemented SharedWeightParameter
    • This class implements a registry where tensors can be shared. Loading with shared tensors is required for models with many transforms such as QuIP
  • Before weight loading, a HadamardTransform module is attached to linear layers to load transform weights which utilizes SharedWeightParameter in order to load weight partitions as separate tensors

Added Transforms Apply

  • Add CompressedTensorsLinearTransformMethod which wraps CompressedTensorsLinearMethod and UnquantizedLinearMethod adds input and output transforms to either side of the original apply method

Misc Changes

  • Add transform config parsing to CompressedTensors
  • Define _shard_id_as_int on BasevLLMParameter. This is so that its implementation can be shared with SharedWeightParameter
  • Add test utility calculate_prompt_perplexity for checking model coherence
  • Added weight_loader_v1 to QKVCrossParallelLinear to support hack described above (and [Core] Support weight_loader_v2 for UnquantizedLinearMethod #23036)

Testing

  • Added test_compressed_tensors_transforms_perplexity tests for SpinQuantR1R2R4 and QuIP
  • Locally tested unquantized QuIP and SpinQuantR1R2R4 models

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for transforms within the compressed tensors quantization framework. The changes primarily involve updating CompressedTensorsConfig to manage transform configurations and modifying the linear method to apply these transforms during the forward pass. My review has identified two critical issues that need to be addressed. First, the logic for creating transform factories incorrectly overwrites the factories dictionary within a loop, which will lead to incorrect behavior when multiple transform schemes are present. Second, there is a signature mismatch in the call to the newly added is_match function, which will cause a TypeError at runtime.

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify
Copy link

mergify bot commented Aug 20, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @kylesayrs.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 20, 2025
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
@kylesayrs kylesayrs force-pushed the kylesayrs/transforms branch from 496527e to 5954ccc Compare August 21, 2025 22:30
@mergify mergify bot removed the needs-rebase label Aug 21, 2025
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Copy link
Member

@yewentao256 yewentao256 left a comment

Choose a reason for hiding this comment

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

Let's run CI and see if it is correct

@yewentao256 yewentao256 added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 22, 2025
@kylesayrs kylesayrs marked this pull request as ready for review August 22, 2025 14:16
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
…s won't

Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
@mergify
Copy link

mergify bot commented Aug 27, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @kylesayrs.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 27, 2025
@mergify mergify bot removed the needs-rebase label Aug 27, 2025
kylesayrs added a commit to vllm-project/llm-compressor that referenced this pull request Aug 27, 2025
## Purpose ##
* Support R4 transforms before R3. R3 requires hooking into the
attention module, where as R4 does not

## Prerequisites ##
* vllm-project/vllm#22486

## Testing ##
* Performed sanity checks with HF and vLLM

---------

Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
@mgoin mgoin merged commit 22feac8 into vllm-project:main Aug 28, 2025
43 checks passed
@kylesayrs kylesayrs deleted the kylesayrs/transforms branch August 28, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build llama Related to Llama models ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants