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

Method test

tests/unit/linear/test_linear.py:105–123  ·  view source on GitHub ↗
(self, base_weight_sharding, q_bits)

Source from the content-addressed store, hash-verified

103 world_size = 2
104
105 def test(self, base_weight_sharding, q_bits):
106 input_features = 64 # Number of input features
107 output_features = 64 # Number of output features
108 batch_size = 5 # Number of samples in a batch
109
110 lora_config = LoRAConfig(lora_r=16, lora_alpha=16, base_weight_sharding=base_weight_sharding)
111 quantization_config = QuantizationConfig(q_bits=q_bits)
112 quantization_config.q_dtype = FPQuantizerBuilder.get_default_quant_dtype()
113
114 linear_layer = OptimizedLinear(input_dim=input_features,
115 output_dim=output_features,
116 lora_config=lora_config,
117 quantization_config=quantization_config,
118 dtype=torch.bfloat16)
119 device = get_accelerator().current_device_name()
120 linear_layer = linear_layer.to(device)
121 dummy_input = torch.rand([batch_size, input_features], device=device, dtype=torch.bfloat16)
122 output = linear_layer(dummy_input)
123 assert output.shape == (batch_size, output_features)

Callers

nothing calls this directly

Calls 7

LoRAConfigClass · 0.90
QuantizationConfigClass · 0.90
OptimizedLinearClass · 0.90
get_acceleratorFunction · 0.90
current_device_nameMethod · 0.45
toMethod · 0.45

Tested by

no test coverage detected