From 5c5e4024909686a5b577541b1c04e3ef18247f16 Mon Sep 17 00:00:00 2001 From: "Feng, Jiqing" Date: Wed, 25 Nov 2026 03:31:50 +0000 Subject: [PATCH 1/2] Remove unused import-time NF4/FP4 tables allocated on XPU --- bitsandbytes/backends/utils.py | 50 ---------------------------------- 1 file changed, 50 deletions(-) diff --git a/bitsandbytes/backends/utils.py b/bitsandbytes/backends/utils.py index a63e59a99..2db1fb278 100644 --- a/bitsandbytes/backends/utils.py +++ b/bitsandbytes/backends/utils.py @@ -12,56 +12,6 @@ triton_available = False -_NF4_QUANT_TABLE = torch.tensor( - [ - -1.0, - -0.6961928009986877, - -0.5250730514526367, - -0.39491748809814453, - -0.28444138169288635, - -0.18477343022823334, - -0.09105003625154495, - 0.0, - 0.07958029955625534, - 0.16093020141124725, - 0.24611230194568634, - 0.33791524171829224, - 0.44070982933044434, - 0.5626170039176941, - 0.7229568362236023, - 1.0, - ], - dtype=torch.float32, - device="xpu" - if hasattr(torch, "xpu") and torch.xpu.is_available() - else "cpu", # Only cpu/xpu use this table for now. -) -_FP4_QUANT_TABLE = torch.tensor( - [ - 0.0000, - 0.0052, - 0.6667, - 1.0000, - 0.3333, - 0.5000, - 0.1667, - 0.2500, - 0.0000, - -0.0052, - -0.6667, - -1.0000, - -0.3333, - -0.5000, - -0.1667, - -0.2500, - ], - dtype=torch.float32, - device="xpu" - if hasattr(torch, "xpu") and torch.xpu.is_available() - else "cpu", # Only cpu/xpu use this table for now. -) -CODE = {"nf4": _NF4_QUANT_TABLE, "fp4": _FP4_QUANT_TABLE} - # Cache 4-bit dequantization code tensors per (quant_type, device). _code_4bit_cache: dict[tuple[str, torch.device], torch.Tensor] = {} From c574bc09ec1e09889b914276784faed4e238941a Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Wed, 25 Nov 2026 07:10:28 +0000 Subject: [PATCH 2/2] Remove stale commented-out quant table code in triton backend --- bitsandbytes/backends/triton/ops.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bitsandbytes/backends/triton/ops.py b/bitsandbytes/backends/triton/ops.py index 2940371d4..8628afb5b 100644 --- a/bitsandbytes/backends/triton/ops.py +++ b/bitsandbytes/backends/triton/ops.py @@ -5,11 +5,6 @@ from . import kernels_4bit, kernels_8bit_quant, kernels_optim -# currently codes unused, kept for reference -# Should be the same for quant/dequant -# from bitsandbytes.functional import get_4bit_type -# _FP4_QUANT_TABLE = get_4bit_type("fp4", device="xpu") -# _NF4_QUANT_TABLE = get_4bit_type("nf4", device="xpu") device_type = torch.accelerator.current_accelerator().type if hasattr(torch, "accelerator") else "cuda" torch_accelerator_module = getattr(torch, device_type, torch.cuda)