if input_ids.dim() == 1:
input_ids_length = input_ids.shape[0]
else:
raise ValueError("Expected a 1-dimensional tensor for 'input_ids', but got a tensor with {0} dimensions.".format(input_ids.dim()))
and raising exception:
ValueError: Expected a 1-dimensional tensor for 'input_ids', but got a tensor with 2 dimensions.
$ CUDA_VISIBLE_DEVICES=1 python examples/quantization/basic_usage_wikitext2.py
/home/ubuntu/GPTQModel/.venv/lib/python3.10/site-packages/gptqmodel/nn_modules/triton_utils/dequant.py:123: FutureWarning: `torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.
def forward(ctx, input, qweight, scales, qzeros, g_idx, bits, maxq):
/home/ubuntu/GPTQModel/.venv/lib/python3.10/site-packages/gptqmodel/nn_modules/triton_utils/dequant.py:131: FutureWarning: `torch.cuda.amp.custom_bwd(args...)` is deprecated. Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead.
def backward(ctx, grad_output):
tokenizer_config.json: 100%|██████████████████████████████████████████████████████| 685/685 [00:00<00:00, 8.05MB/s]
config.json: 100%|████████████████████████████████████████████████████████████████| 651/651 [00:00<00:00, 9.10MB/s]
vocab.json: 100%|███████████████████████████████████████████████████████████████| 899k/899k [00:00<00:00, 7.29MB/s]
merges.txt: 100%|███████████████████████████████████████████████████████████████| 456k/456k [00:00<00:00, 13.1MB/s]
special_tokens_map.json: 100%|████████████████████████████████████████████████████| 441/441 [00:00<00:00, 6.31MB/s]
pytorch_model.bin: 100%|█████████████████████████████████████████████████████████| 251M/251M [00:00<00:00, 422MB/s]
generation_config.json: 100%|█████████████████████████████████████████████████████| 137/137 [00:00<00:00, 1.89MB/s]
WARNING - Calibration dataset size should be greater than 256. Current size: 128.
Traceback (most recent call last):
File "/home/ubuntu/GPTQModel/examples/quantization/basic_usage_wikitext2.py", line 171, in <module>
main()
File "/home/ubuntu/GPTQModel/examples/quantization/basic_usage_wikitext2.py", line 148, in main
model.quantize(traindataset)
File "/home/ubuntu/GPTQModel/.venv/lib/python3.10/site-packages/gptqmodel/models/base.py", line 219, in quantize
raise ValueError("Expected a 1-dimensional tensor for 'input_ids', but got a tensor with {0} dimensions.".format(input_ids.dim()))
ValueError: Expected a 1-dimensional tensor for 'input_ids', but got a tensor with 2 dimensions.
Additional context
Seems like the example was taken directly from AutoGPTQ. However seems like AutoGPTQ is capable of handling 2 dimensional tensor, while GPTQModel asserts 1 dimensional tensor.
Examples should generate 1 dimensional tensor as input_ids to be correctly passed over to model.quantize().
Describe the bug
basic_usage_wikitext2.py
example is broken.examples/quantization/basic_usage_wikitext2.py#L36:
is colliding with dimension assertion in gptqmodel/models/base.py#L216-L219:
and raising exception:
I think the example should be fixed to:
GPU Info
unrelated but:
Software Info
To Reproduce
Expected behavior
Does not raise ValueError exception.
Model/Datasets
are hardcoded in the example.
Screenshots
Additional context
Seems like the example was taken directly from AutoGPTQ. However seems like AutoGPTQ is capable of handling 2 dimensional tensor, while GPTQModel asserts 1 dimensional tensor.
Examples should generate 1 dimensional tensor as
input_ids
to be correctly passed over tomodel.quantize()
.