(self, base_weight_sharding, q_bits)
| 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) |
nothing calls this directly
no test coverage detected