Work

Fast, memory-efficient least-squares scalar quantization via coarsening, dynamic programming, and local exchanges

Year: 2026
Type: preprint
Abstract: Least-squares scalar quantization partitions N sorted values into k contiguous bins that minimize the squared deviations from the bin means. It is used to build quantizers, histograms, map classes, and neural-network codebooks. Table-based exact dynamic programming (DP) implementations keep information for every bin count and candidate endpoint. Their memory grows with k times the number of values. We propose LEX (local exchange), which merges adjacent values into a fixed number M of groups, solves the reduced problem exactly by DP, and then exchanges values between neighboring bins to lower the error. The exchange step jointly scores single and paired boundary moves in each window of three bins. Its DP table is bounded in advance, at most 8.4 MB for k ≤ 512 at M = 4,096. With at most M distinct values, the DP stage solves the full problem exactly. On simulated unweighted continuous data with up to N = 1,048,576 values, the relative excess error (REE) over the optimum stayed below 0.08% for all k ≤ 512 at M = 4,096. On millions of audio samples and GPT-2 weights at k = 512, LEX ran more than 50 times faster than Ckmeans.1d.dp, used less than 1% of the comparator’s peak process memory, and had REE below 0.04%.
Author: N. Sriram
Language: English
Open Access status: green
OpenAlex ID: W7237570251
Cites:
Cited by:
Related to: