How to use the Quantization group size Calculator tool
- Enter the total number of weights to be split in the Number of weights field.
- Enter the block length, such as 32, 64 or 128, in the Weights per group field.
- Select Calculate. Select Example to split 1048576 weights into groups of 128.
- Read the Groups line for the group count and the Final group line for the size of the last, possibly partial, group.
- Select Copy to copy both lines.
What quantization group size means
A single scale for a whole weight matrix is cheap but coarse: one large weight stretches the step size for all the others. Group-wise quantization cuts the weights into consecutive blocks of a fixed length and computes quantization parameters for each block. Smaller groups follow the local range of the weights more closely and reduce error. Larger groups store fewer parameters.
The group size is therefore a trade between accuracy and overhead, and the group count is what turns it into bytes. Every group carries metadata, typically a scale and sometimes an offset, so total overhead is groups x metadata size.
How the group count and final group are calculated
The tool divides the weight count by the group size and rounds up. If the division is exact, the final group is full. Otherwise the final group holds the remainder. With 1,000 weights and groups of 128, seven full groups cover 896 weights and an eighth group holds the remaining 104.
Both inputs are handled as exact integers of up to 24 digits, so very large counts do not suffer floating-point rounding. The division is done by a script in your browser.
Number of weights: 1000, Weights per group: 128
Groups: 8
Final group: 104 weights
Number of weights: 1048576, Weights per group: 128
Groups: 8192
Final group: 128 weightsFrom group count to bits per weight
Suppose each group stores one 16-bit scale. With groups of 128, that is 16 / 128 = 0.125 extra bits per weight. With groups of 32 it is 0.5 bits, so nominal 4-bit weights cost 4.5 bits each. Multiply the Groups line by your metadata size to get the overhead in bytes: 8,192 groups with 2 bytes each add 16,384 bytes to the 1,048,576-weight example.
A partial final group still needs a full set of parameters, which is why the count is rounded up.
Grouping per row instead of per tensor
Many quantizers form groups along each row of a weight matrix and never let a group span two rows. In that case, calculate one row and multiply. A row of 4,096 weights with groups of 128 gives 32 groups, so a matrix of 4,096 rows has 131,072.
If the row length is not a multiple of the group size, every row ends with its own short group. A row of 1,000 weights needs 8 groups of 128, so 1,000 rows need 8,000. Entering the total of 1,000,000 weights returns 7,813 groups, which undercounts that layout.
Frequently asked questions
How do I calculate the number of quantization groups?
Divide the number of weights by the group size and round up to the next whole number. For 3,000,000 weights in groups of 128 the answer is 23,438, and the last group contains 64 weights.
What happens if the group size is larger than the weight count?
You get a single group that contains every weight. For example, 100 weights with a group size of 128 returns Groups: 1 and Final group: 100 weights.
What group size should I use?
The tool does not recommend one. Sizes of 32, 64 and 128 are common in 4-bit weight quantization. Halving the group size doubles the metadata and usually lowers error a little, so measure accuracy on your own model.
Why does the tool reject my number?
Both fields take positive whole numbers written with digits only, up to 24 digits long. Zero, negative values, decimals, commas and exponent notation produce an error that names the field, Weight count or Group size.
Does the calculator estimate the memory of the groups?
No. It returns the group count and the size of the final group. For bytes, multiply the count by your per-group metadata, or use the Grouped quantization memory Calculator, which combines packed weights and metadata in one result.