[Bugfix] hadacore_transform: respect inplace parameter to fix garbage outputs with QuIP transforms (#43462)
Signed-off-by: Gilles Turpin <turpingilles15@gmail.com> Co-authored-by: Wentao Ye <44945378+yewentao256@users.noreply.github.com>
Gilles Turpin committed
Sep 22, 2026 at 18:48 UTC
74370a0e3044c16b6ba58f9c144b02ab733cd73a
2 files changed
+3
-3
csrc/libtorch_stable/quantization/hadamard/hadacore/hadamard_transform_cuda.cu
+1
-1
@@ -796,7 +796,7 @@ torch::stable::Tensor hadacore_transform(torch::stable::Tensor& x, bool inplace)
796
797
VLLM_STABLE_DISPATCH_HALF_TYPES(x.scalar_type(), "hadacore_transform_runfht", [&] {
798
auto constexpr SCALAR_TYPE = torch::headeronly::CppTypeToScalarType<scalar_t>::value;
799
- hadacore::run_fht<SCALAR_TYPE>(x.data_ptr(), x.data_ptr(), x.numel(), had_size, stream);
799
+ hadacore::run_fht<SCALAR_TYPE>(x.data_ptr(), out.data_ptr(), x.numel(), had_size, stream);
800
});
801
802
if (numel % 256 != 0) {
vllm/model_executor/layers/quantization/compressed_tensors/transform/module.py
+2
-2
@@ -95,13 +95,13 @@ class HadamardTransform(torch.nn.Module):
95
if self.transforms[part_id].scheme.head_dim is not None:
96
weight_size = self.transforms[part_id].scheme.head_dim
97
value = value.unflatten(-1, (-1, weight_size))
98
- value = ops.hadacore_transform(value)
98
+ value = ops.hadacore_transform(value, inplace=False)
99
value = value.flatten(-2, -1)
100
101
return value
102
103
# sylvester transforms are symmetric, inv => transpose => original
104
- return ops.hadacore_transform(value)
104
+ return ops.hadacore_transform(value, inplace=False)
105
106
# fall back to dense
107
else: