test(loader): isolate optional quantization dependency

This commit is contained in:
Joseph Magly
2026-08-22 10:09:41 -04:00
parent 3390fe551b
commit feda78fbbb
+2
View File
@@ -651,6 +651,7 @@ def test_cuda_quantization_builds_explicit_config(loader_boundary, monkeypatch,
monkeypatch.setattr(loader.dev, "get_device", lambda _preference="auto": "cuda")
monkeypatch.setattr(loader.dev, "supports_bitsandbytes", lambda _device=None: True)
monkeypatch.setitem(sys.modules, "bitsandbytes", ModuleType("bitsandbytes"))
monkeypatch.setattr("transformers.BitsAndBytesConfig", fake_bnb)
handle = loader.load_model("x", quantization=quantization, skip_snapshot=True)
kwargs = loader_boundary.model_class.from_pretrained.call_args.kwargs
@@ -743,6 +744,7 @@ def _enable_cuda_quantization(monkeypatch, estimate_gb: float) -> None:
"get_device_properties",
lambda _index: SimpleNamespace(total_memory=16 * gib),
)
monkeypatch.setitem(sys.modules, "bitsandbytes", ModuleType("bitsandbytes"))
monkeypatch.setattr("transformers.BitsAndBytesConfig", lambda **kwargs: kwargs)