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

Function test_linear8bitlt_inference

tests/test_modules.py:65–75  ·  view source on GitHub ↗
(device, threshold)

Source from the content-addressed store, hash-verified

63@pytest.mark.parametrize("device", get_available_devices())
64@pytest.mark.parametrize("threshold", [0.0, 3.0], ids=id_formatter("threshold"))
65def test_linear8bitlt_inference(device, threshold):
66 l1 = bnb.nn.Linear8bitLt(32, 64, threshold=threshold, has_fp16_weights=False).to(device).half()
67 assert l1.weight.device.type == device
68 assert l1.weight.dtype == torch.int8
69
70 l1.eval()
71 for i in range(100):
72 b1 = torch.randn(16, 8, 32, device=device).half()
73 o1 = l1(b1)
74 if i == 1:
75 assert l1.state.CB is not None
76
77
78@pytest.mark.parametrize("device", get_available_devices())

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected