All problems
Activation Int8 Calibration
Problem
Calibrate an activation clipping threshold with the nearest-rank percentile: sort the observed activations and take index ceil(percentile / 100 * n) - 1, clamped to the valid range.
The signature is activation_calibration(activations, percentile). Return the threshold value.
Hint
Percentile clipping removes extreme outliers that would waste int8 dynamic range.
Test cases
case 1
in: [[1,2,3,4,5],90]
expected: 5
case 2
in: [[0.1,0.2],50]
expected: 0.1
case 3
in: [[10],99]
expected: 10
case 4
in: [[-1,0,1],50]
expected: 0
Starter codePython
import math
def activation_calibration(activations, percentile):
# Your code here
pass4 test cases · run your code against them in the editor