[Migration] Migrate bitsandbytes support to OOT plugin (#43529)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>
Signed-off-by: Isotr0py <Isotr0py@outlook.com>
This commit is contained in:
Isotr0py
2026-08-09 10:27:31 +08:00
committed by GitHub
parent dedbf6be8b
commit 073c510c91
31 changed files with 187 additions and 1895 deletions
@@ -343,40 +343,6 @@ class TestWeightLoadingWithPaddedHiddenSize:
torch.zeros(original_hidden, padded_intermediate - original_intermediate),
)
def test_bnb_shape_mismatch_raises(self):
"""BnB + padded hidden_size should raise via weight_loader."""
from unittest.mock import MagicMock
num_experts = 1
padded_packed = 3072 # padded packed size
original_packed = 2688 # original packed size
# Build a param that looks like a BnB 4-bit MoE weight.
param_data = torch.zeros(num_experts, padded_packed, 1, dtype=torch.uint8)
param = torch.nn.Parameter(param_data, requires_grad=False)
param.use_bitsandbytes_4bit = True
loaded_weight = torch.randint(0, 255, (original_packed, 1), dtype=torch.uint8)
# Minimal RoutedExperts mock so weight_loader reaches the BnB path.
moe = MagicMock(spec=RoutedExperts)
moe.quant_config = None
moe.quant_method = MagicMock()
moe.quant_method.__class__.__name__ = "BitsAndBytesMethod"
moe._expert_map = None
moe.tp_rank = 0
# Call the real weight_loader (unbound) with our mock as self.
with pytest.raises(ValueError, match="BitsAndBytes"):
RoutedExperts.weight_loader(
moe,
param,
loaded_weight,
weight_name="w2",
shard_id="w2",
expert_id=0,
)
class TestLoadWeightsExpertBias:
"""Some quantized exports (e.g. GPTQ, llm-compressor NVFP4) materialize