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

Method test_hf_clone

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

Source from the content-addressed store, hash-verified

48 assert qp.dtype == quantization_config.q_dtype
49
50 def test_hf_clone(self):
51 device = get_accelerator().current_device_name()
52 data = torch.rand(4, 4, device=device, dtype=torch.bfloat16)
53
54 quantization_config = QuantizationConfig(q_bits=6, group_size=8)
55 qp = QuantizedParameter(data, quantization_config=quantization_config)
56
57 # should be able to clone parameter via dict, HF expects this to work
58 qp_copy = QuantizedParameter(qp.data, **qp.__dict__)
59
60 assert torch.equal(qp.data, qp_copy.data)
61 assert qp.quantization_config == qp_copy.quantization_config
62
63 @pytest.mark.parametrize("q_bits", [6, 8, 12])
64 def test_small_parameter_model_output(self, q_bits):

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