[01-symmetric-int8-quantization]'s single global scale for an entire weight matrix is dominated by whichever row happens to have the largest values — every OTHER row is then quantized far more coarsely than it needs to be, wasting precision. Implement per-channel (per-output-row) symmetric INT8 quantization for a weight matrix: instead of one global scale for the whole matrix, compute an independent scale for each output channel (row).
scale[o] = max(|W[o, :]|) / 127 for each output channel o
Q[o, :] = clip(round(W[o, :] / scale[o]), -127, 127)
Compute np.max(np.abs(W), axis=1) to get one max-abs value per row in a single vectorized call. Broadcast each row's scale over its own row when quantizing: W / scale[:, None], not W / scale.
Click "Run Tests" to test your implementation