MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / test_hf_clone

Method test_hf_clone

tests/unit/linear/test_quant_param.py:49–60  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

47 assert qp.dtype == quantization_config.q_dtype
48
49 def test_hf_clone(self):
50 device = get_accelerator().current_device_name()
51 data = torch.rand(5, 5, device=device, dtype=torch.bfloat16)
52
53 quantization_config = QuantizationConfig(q_bits=6)
54 qp = QuantizedParameter(data, quantization_config=quantization_config)
55
56 # should be able to clone parameter via dict, HF expects this to work
57 qp_copy = QuantizedParameter(qp.data, **qp.__dict__)
58
59 assert all(qp.data == qp_copy.data)
60 assert qp.quantization_config == qp_copy.quantization_config

Callers

nothing calls this directly

Calls 4

get_acceleratorFunction · 0.90
QuantizationConfigClass · 0.90
QuantizedParameterClass · 0.90
current_device_nameMethod · 0.45

Tested by

no test coverage detected