(device, quant_type, blocksize, compress_statistics)
| 197 | @pytest.mark.parametrize("blocksize", [32, 64, 128]) |
| 198 | @pytest.mark.parametrize("compress_statistics", TRUE_FALSE, ids=id_formatter("compress_statistics")) |
| 199 | def 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()) |
nothing calls this directly
no test coverage detected