Per-channel INT8 weight quantization
Implement symmetric per-output-channel quantization and a dequantized linear forward pass.
What’s going wrong
Original LLM Architecture lab. Implement the missing behavior in solve(data) and keep the supplied JSON interface. Use Python’s standard library.
Input weights is D×O and x is a batch of width D. Use each weight column’s max absolute value / 127 as scale, or 1 for a zero column. Round weight/scale to the nearest integer with ties to even, clamp to [−127,127], and compute output using the dequantized weights. Return scales, integers (D×O) and output. Accumulate before rounding JSON results.
Small, well-formed JSON inputs and standard-library Python arithmetic. Keep full precision during computation. The supplied output wrapper rounds results to six decimal places.
Expected behavior
Implement symmetric per-output-channel quantization and a dequantized linear forward pass.
Reproduction
{"weights":[[100,1],[70,0.3]],"x":[[1,2]]}{"scales":[0.787402,0.007874],"integers":[[127,127],[89,38]],"output":[[240.15748,1.598425]]}{"weights":[[0],[0]],"x":[[1,2]]}{"scales":[1],"integers":[[0],[0]],"output":[[0]]}{"weights":[[-2],[3]],"x":[[1,0]]}{"scales":[0.023622],"integers":[[-85],[127]],"output":[[-2.007874]]}Before you begin
- Python functions, lists and dictionaries
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.