mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
feat: make the last layer over 7 bits
This commit is contained in:
@@ -88,7 +88,12 @@ class PostTrainingAffineQuantization:
|
||||
# Create a QuantizedLinear layer
|
||||
q_weights = self.quant_params[f"{name}.weight"]
|
||||
q_bias = self.quant_params[f"{name}.bias"]
|
||||
q_layer = QuantizedLinear(self.n_bits, q_weights, q_bias)
|
||||
# Check if layer is last layer from the model
|
||||
if name == list(self.numpy_model.torch_model.named_children())[-1][0]:
|
||||
# If last layer, we can use 7 bits (maximum allowed) of precision.
|
||||
q_layer = QuantizedLinear(7, q_weights, q_bias)
|
||||
else:
|
||||
q_layer = QuantizedLinear(self.n_bits, q_weights, q_bias)
|
||||
# Calibrate and get new calibration_data for next layer/activation
|
||||
calibration_data = self._calibrate_layers_activation(
|
||||
name, q_layer, calibration_data
|
||||
|
||||
Reference in New Issue
Block a user