Sub-byte unsigned integer: quantization packing and nibble-level data
A 4-bit unsigned integer (also called a nibble) uses all 4 bits for magnitude, giving a range of 0 to 15 (24 - 1). Two UINT4 values pack into a single byte, and each corresponds to one hexadecimal digit (0–F).
UINT4 is a sub-byte format primarily used as a packing container for quantized ML weights. While INT4 (signed) is more common in quantization schemes like GPTQ and AWQ, UINT4 appears in frameworks that use asymmetric quantization with a non-zero zero-point offset.
With only 16 possible values (0–15), UINT4 achieves the same 8× compression over FP32 as INT4. Two UINT4 values are packed into a single byte, with the first element in the least-significant nibble.
In asymmetric quantization, the float-to-integer mapping includes a zero point:
The zero point shifts the mapping so that zero maps to a non-zero integer, allowing the full 0–15 range to cover an asymmetric distribution of float values.
| Property | Value |
|---|---|
| Total Bits | 4 |
| Minimum Value | 0 |
| Maximum Value | 15 |
| Representable Values | 16 |
With only 16 possible bit patterns, here is the complete set:
| Value | Bit Pattern | Signed | Unsigned |
|---|---|---|---|
| Zero | 0000 | 0 | 0 |
| One | 0001 | 1 | 1 |
| Max Unsigned | 1111 | -1 | 15 |
| Max Signed | 0111 | 7 | 7 |
| All Ones (-1) | 1111 | -1 | 15 |
| Min Signed (-8) | 1000 | -8 | 8 |
With only 4 bits, you can click through every possible value. Each nibble corresponds to one hex digit.
| Property | UINT4 | UINT8 | UINT16 | UINT32 |
|---|---|---|---|---|
| Total Bits | 4 | 8 | 16 | 32 |
| Signed Min | -8 | -128 | -32,768 | -2,147,483,648 |
| Signed Max | 7 | 127 | 32,767 | 2,147,483,647 |
| Unsigned Max | 15 | 255 | 65,535 | 4,294,967,295 |
| Step (ULP) | 1 | 1 | 1 | 1 |
| Values | 16 | 256 | 65,536 | 4,294,967,296 |
UINT4 in TensorProto.DataType with a packing rule of two 4-bit elements per byte (first element in LSB). This is used for asymmetric quantization with unsigned zero-point offsets.uint4 as a narrow integer NumPy extension (4-bit, stored in a byte, with defined cast behavior)..u4 packed types for unsigned 4-bit MMA instructions on Turing/Ampere. The MLIR AMDGPU dialect supports unsigned i4 via udot8 instructions on gfx906+.