MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / test_4bit_linear_warnings

Function test_4bit_linear_warnings

tests/test_modules.py:417–433  ·  view source on GitHub ↗
(device, caplog)

Source from the content-addressed store, hash-verified

415
416@pytest.mark.parametrize("device", get_available_devices())
417def test_4bit_linear_warnings(device, caplog):
418 dim1 = 64
419
420 with caplog_at_level(caplog, logging.WARNING, "bitsandbytes.nn.modules"):
421 net = nn.Sequential(*[bnb.nn.Linear4bit(dim1, dim1, quant_type="nf4") for i in range(10)])
422 net = net.to(device)
423 inp = torch.rand(10, dim1, device=device, dtype=torch.float16)
424 net(inp)
425 assert any("inference or training" in msg for msg in caplog.messages)
426
427 caplog.clear()
428 with caplog_at_level(caplog, logging.WARNING, "bitsandbytes.nn.modules"):
429 net = nn.Sequential(*[bnb.nn.Linear4bit(dim1, dim1, quant_type="nf4") for i in range(10)])
430 net = net.to(device)
431 inp = torch.rand(1, dim1, device=device, dtype=torch.float16)
432 net(inp)
433 assert any("inference." in msg for msg in caplog.messages)
434
435
436@pytest.mark.parametrize("device", get_available_devices())

Callers

nothing calls this directly

Calls 2

caplog_at_levelFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected