3INST
QTIP's three-instruction codebook: a multiply-add, a mask and XOR that turn each 16-bit half into an fp16 number, and one fp16 add.
How it decodes
On a GPU the mask and XOR are one LOP3 instruction, and the two halves are already an fp16 pair in
one register, so the whole decode is IMAD, LOP3, HADD2. The figure's top right shows each stage for the current
state.
| step | operation |
|---|---|
| 1 | x = (a · state + b) mod 2³², a = 89226354, b = 64248484 |
| 2 | x = (x & 0x8FFF8FFF) ^ 0x3B603B60 |
| 3 | v = fp16(x & 0xFFFF) + fp16(x >> 16) |
The result has about 10,600 distinct values, against 1MAD's 908, and a smooth bell shape.
exllamav3's mcg keeps the mask and the add and drops + b.
Things to try
- Change the XOR constant to
0x3C003C00and see the spread change. - Return only
lo: one half alone is far from Gaussian.