You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
quantize_blockwise (CPU) occurs Segmentation fault when all block elements are zero #1744
Hi guys, I have the same issue in Intel i7-10750H.
t=torch.randn([64, 64], dtype=dtype, device=device, requires_grad=requires_grad)
# make_nf4 has the same steps like this postq=make_nf4(t) # workq2=make_nf4(torch.empty_like(t)) # workq3=make_nf4(torch.zeros_like(t)) # SEG FAULTq4=make_nf4(torch.zeros_like(t), device="cuda") # work
This is the last call stack:
Fatal Python error: Segmentation fault
Thread 0x000072f184fbc140 (most recent call first):
/site-packages/bitsandbytes/backends/cpu/ops.py", line 41 in _...
So the problem maybe in the get_ptr or .
Also, the same problem, raise at the exactly above line, that when try to quantize the tensor that has numel()<256
t=torch.randn([16, 16], device=device, dtype=dtype, requires_grad=requires_grad)
nf4=make_nf4(t) # work t=torch.randn([8, 8], device=device, dtype=dtype, requires_grad=requires_grad)
nf4=make_nf4(t) # SEG FAULT, BUT at line 40, ``lib.cquantize_blockwise_cpu_fp32`...`# And again, error occurs only in cpu, this code works.t=torch.randn([8, 8], device="cuda", dtype=dtype, requires_grad=requires_grad)
nf4=make_nf4(t)
Actually i don't need the fix right now, I just hope to know all the case that can cause the problem, so i can do validation before quantization.
Thank you guys.
Hi, I found the problem, all above cases fail because of this:
So that, when all elements in one block are zeros, the absmax_block also be zeros, and div zeros return nan and cause segmentation fault in bin_searcher.
Also, the case that Tensor.numel()<blocksize leading to len(absmax.shape)==1 and the A (offset) ==absmax_block==0.
changed the title [-]quantize_flockwise (CPU) occurs Segmentation fault when all block elements are zero[/-][+]quantize_blockwise (CPU) occurs Segmentation fault when all block elements are zero[/+]on Sep 15, 2025
Activity
hieubnt235 commentedon Sep 12, 2025
Hi guys, I have the same issue in Intel i7-10750H.
This is the last call stack:
Line 40-47 in cpu/ops.py is :
So the problem maybe in the
get_ptror .Also, the same problem, raise at the exactly above line, that when try to quantize the tensor that has
numel()<256System Info
Python: 3.12.3
bitsandbytes: 0.47.0
CPU: Intel i7-10750H (12) @ 5.000GHzSystem: centos 7
OS: Kubuntu 24.04.2 LTS x86_64
More info
This is the implementations of
make_nf4above:Actually i don't need the fix right now, I just hope to know all the case that can cause the problem, so i can do validation before quantization.
Thank you guys.
hieubnt235 commentedon Sep 12, 2025
Hi, I found the problem, all above cases fail because of this:
So that, when all elements in one block are zeros, the
absmax_blockalso be zeros, and div zeros returnnanand causesegmentation faultinbin_searcher.Also, the case that
Tensor.numel()<blocksizeleading tolen(absmax.shape)==1and theA (offset) ==absmax_block==0.Hope the fix soon.
[-]quantize_flockwise (CPU) occurs Segmentation fault when all block elements are zero[/-][+]quantize_blockwise (CPU) occurs Segmentation fault when all block elements are zero[/+]matthewdouglas commentedon Dec 11, 2025
This is fixed by #1804.