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

Function test_copy_param

tests/test_linear4bit.py:199–214  ·  view source on GitHub ↗
(device, quant_type, blocksize, compress_statistics)

Source from the content-addressed store, hash-verified

197@pytest.mark.parametrize("blocksize", [32, 64, 128])
198@pytest.mark.parametrize("compress_statistics", TRUE_FALSE, ids=id_formatter("compress_statistics"))
199def test_copy_param(device, quant_type, blocksize, compress_statistics):
200 if device == "hpu" and not is_supported_on_hpu(quant_type):
201 pytest.skip("This configuration is not supported on HPU.")
202
203 tensor = torch.randn(300, 400)
204 param = bnb.nn.Params4bit(
205 data=tensor,
206 quant_type=quant_type,
207 blocksize=blocksize,
208 compress_statistics=compress_statistics,
209 requires_grad=False,
210 ).to(device)
211
212 shallow_copy_param = copy.copy(param)
213 assert param.quant_state is shallow_copy_param.quant_state
214 assert param.data.data_ptr() == shallow_copy_param.data.data_ptr()
215
216
217@pytest.mark.parametrize("device", get_available_devices())

Callers

nothing calls this directly

Calls 2

is_supported_on_hpuFunction · 0.90
toMethod · 0.45

Tested by

no test coverage detected