Description
Found on main @ 4b65923, RTX 4090 (sm89), torch 2.15 + CUDA 13.2, triton 3.9.
What is wrong
docs/kernel-config.md ("Lifetime and serialization") and docs/backend-selection.md say that each quantized linear owns a snapshot of its policy (BaseQuantLinear.kernel = snapshot_kernel_config(...)), and that "Later loads, configure_kernel calls ... do not change those modules." Two inference dispatch sites ignore the module snapshot and read the process-wide get_kernel_config() on every forward. That process-wide policy is replaced by every GPTQModel.load(...) / from_quantized(...) (_install_kernel_policy -> configure_kernel).
- bitsandbytes 4-bit Triton path.
gptqmodel/nn_modules/qlinear/bitsandbytes_triton.py:109(available_for):forced = get_kernel_config().bitsandbytes_triton.BitsAndBytesLinear.forward(bitsandbytes.py:901) callsshould_use(...)without passingself.kernel. The typedBitsAndBytesConfig(triton=True)added in fix(backend): keep resolved policy out of QuantizeConfig.kernel; apply every pool setting (#4446, #4448, #4449) #4497 therefore only applies until the next load. On ROCm the opposite happens: a model loaded withtriton=Falseis switched back to Triton. - ParoQuant Triton fused GEMM accumulation.
quantization/paroquant/modules/triton/gemm.py:476,501:paroquant_gemm_triton_decode/prefillpassfp32_accum=get_kernel_config().fp32_accum.ParoQuantTritonLinear._forward_triton_decode/_prefill(paroquant_triton.py:144-150) never forward the module's ownself.fp32_accum/self.kernel.fp32_accum. SoParoQuantTritonConfig(fp32_accum=False)(orTrue) is ignored whenever the process policy differs. That is the case right after any other load, and also when the module is built with an explicitkernel=.
This is the per-model leak that #4446/#4448/#4497 set out to remove. These two sites were missed.
Repro 1: bnb, public API, two loads in one process
Checkpoint: Qwen2.5-0.5B-Instruct quantized with BitsAndBytesConfig(bits=4) and saved.
import torch
from gptqmodel import GPTQModel
from gptqmodel.utils.backend_config import BitsAndBytesConfig
from gptqmodel.nn_modules.qlinear import bitsandbytes_triton as bt
calls = {"n": 0}; orig = bt.matmul_4bit
def spy(*a, **k): calls["n"] += 1; return orig(*a, **k)
bt.matmul_4bit = spy
a = GPTQModel.load(ckpt, backend=BitsAndBytesConfig(triton=True), dtype=torch.float16)
x = torch.randint(100, 2000, (1, 64), device="cuda")
with torch.inference_mode(): la = a.model(x).logits.float()
print("model A, after its own load: triton calls =", calls["n"])
b = GPTQModel.load(ckpt, dtype=torch.float16) # another model, default policy
calls["n"] = 0
with torch.inference_mode(): la2 = a.model(x).logits.float()
print("model A, after loading model B: triton calls =", calls["n"])
print("module A snapshot bitsandbytes_triton =",
next(m for m in a.model.modules() if type(m).__name__ == "BitsAndBytesLinear").kernel.bitsandbytes_triton)
print("max |logits A before - after| =", (la - la2).abs().max().item())Output:
model A, after its own load: triton calls = 168
model A, after loading model B: triton calls = 0
module A snapshot bitsandbytes_triton = True
max |logits A before - after| = 0.078125
Repro 2: ParoQuant Triton
import torch
from gptqmodel.utils.kernel import KernelConfig, configure_kernel
from gptqmodel.nn_modules.qlinear.paroquant_triton import ParoQuantTritonLinear
import gptqmodel.quantization.paroquant.modules.triton.gemm as g
seen = []; orig = g._paroquant_gemm_triton
def spy(*a, **k): seen.append(k.get("fp32_accum")); return orig(*a, **k)
g._paroquant_gemm_triton = spy
m = ParoQuantTritonLinear(bits=4, group_size=128, sym=True, desc_act=False, in_features=256, out_features=256,
bias=False, register_buffers=True, kernel=KernelConfig(fp32_accum=False)).cuda()
print(m.kernel.fp32_accum, m.fp32_accum) # False False
configure_kernel(None) # what any later GPTQModel.load() does
x = torch.randn(64, 256, device="cuda", dtype=torch.float16)
m._forward_triton_prefill(x); m._forward_triton_decode(x[:1])
print(seen) # [True, True] <- module asked for FalseThe reverse also happens: a module built with fp32_accum=True while the process policy is False gets fp32_accum=False.
Suggested fix
bitsandbytes_triton.available_for/should_use: take akernel(orforced) argument.BitsAndBytesLinear.forwardpassesself.kernel.bitsandbytes_triton.paroquant_gemm_triton_decode/prefill: add anfp32_accumparameter.ParoQuantTritonLinearpassesself.fp32_accum, asParoLinearalready does atparoquant.py:479.- Add a guard test: grep
nn_modules/qlinear/**and the GEMM helpers they call forget_kernel_config()reachable fromforward. The remaining hits (gemm_awq_triton.py:86,utils/tt_blockfloat_cuda.py:226,utils/swordfish.py:361) are only fallbacks when the caller passesNone. Today the module callers do pass their own values there, but nothing pins that.
Test that should have caught it
tests/test_backend_config_reuse_4446.py / tests/test_runtime_config_4448.py check module snapshots, not the value that reaches the dispatch site. A "load A with policy X, load B with defaults, forward A, assert the path/flag" test per kernel with a typed config would catch both.
Severity
Medium. A model silently changes kernel path and numerics (logit deltas up to 0.08 in the bnb repro) depending on what else was loaded in the process. This breaks the documented isolation contract and the new typed BitsAndBytesConfig(triton=...) / ParoQuantTritonConfig(fp32_accum=...) options.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Claimed. This issue is now owned by a dedicated worker; a fix PR referencing it will follow.
fix(kernels): read the module kernel snapshot at forward dispatch (#4555