bugger.
All challenges/Pythonmediumllm-int8-quantization-v1
THE INVESTIGATION

Per-channel INT8 weight quantization

Implement symmetric per-output-channel quantization and a dequantized linear forward pass.

LLM ArchitectureML systems

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

01 Columns have radically different scales
{"weights":[[100,1],[70,0.3]],"x":[[1,2]]}
{"scales":[0.787402,0.007874],"integers":[[127,127],[89,38]],"output":[[240.15748,1.598425]]}
02 All-zero channel uses unit scale
{"weights":[[0],[0]],"x":[[1,2]]}
{"scales":[1],"integers":[[0],[0]],"output":[[0]]}
03 Negative weights preserve the sign
{"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.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.