Skip to content

Commit 630f76c

Browse files
committed
add inversion fallback
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
1 parent 8f6a0b5 commit 630f76c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/llmcompressor/modifiers/quantization/gptq/gptq_quantize.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
QuantizationStrategy,
1111
fake_quantize,
1212
)
13+
from loguru import logger
1314

1415
from llmcompressor.modifiers.utils import SPARSITY_THRESHOLD
1516
from llmcompressor.observers.base import Observer
@@ -161,11 +162,12 @@ def quantize_weight(
161162
H = torch.linalg.cholesky(H, upper=True)
162163
Hinv = H
163164
except torch._C._LinAlgError:
164-
raise torch._C._LinAlgError(
165+
logger.warning(
165166
"Failed to invert hessian due to numerical instability. Consider "
166167
"increasing GPTQModifier.dampening_frac, increasing the number "
167168
"of calibration samples, or shuffling the calibration dataset"
168169
)
170+
Hinv = H = torch.eye(num_columns, dtype=H.dtype, device=H.device)
169171

170172
# See section 3.4 of https://arxiv.org/abs/2203.07259
171173
for i1 in range(0, num_columns, blocksize):

0 commit comments

Comments
 (0)