1.  [](/)
2.  [Diagrams](/diagrams)
3.  The Memory Math of Quantization

[Back to Diagrams](/diagrams)IR Foundations

# The Memory Math of Quantization

Every compression method is a discount on one term of vectors x dimensions x bytes.

![Vector memory is one multiplication: bytes equals vectors times dimensions times bytes per dimension. At 1,024 dimensions in float32 that is 4,096 bytes per vector, so 10 million vectors is 40.96 GB and a billion is 4.1 TB. The relationship is linear, which means there are exactly three levers and every compression technique is a discount on one of them. int8 quantization scales each dimension into a byte for a 4x cut, binary quantization keeps only the sign of each dimension for 32x, product quantization splits the vector into subvectors and replaces each with a centroid id for arbitrary ratios, and Matryoshka truncates dimensions because the model was trained so the first d dimensions are themselves a valid embedding. The rescore cascade is what makes any of it survivable: retrieve wide with the cheap representation, then re-rank the shortlist with a more precise one.](/diagrams/embedding-quantization.webp)Full screen

Every compression method is a discount on one term of vectors x dimensions x bytes.

Vector memory is not a mystery line item. It is one multiplication: bytes equals vectors times dimensions times bytes per dimension. At 1,024 dimensions in float32 that is 4,096 bytes per vector, so 10 million vectors is about 41 GB and a billion is about 4.1 TB.

The relationship is linear, which is the useful part: there are exactly three levers, and every compression technique is a discount on one of them.

Bytes per dimension is the first. int8 quantization scales each dimension into a single byte, a straight 4x cut, and for most retrieval workloads it costs a point or two of recall. Binary quantization keeps only the sign of each dimension, 32x, at which point the distance metric becomes a Hamming distance and the arithmetic gets very cheap.

Dimensions is the second, and Matryoshka is what makes it free when your model supports it. Matryoshka models are trained so that the first d dimensions of an n-dimensional vector are themselves a valid embedding, so truncating is a slice rather than a re-encode. Models without that training lose far more quality when truncated, because their dimensions are not ordered by importance.

Vectors is the third, and it is the one nobody wants to pull, because it means indexing less of your corpus.

Product quantization sits slightly outside that framing: it splits the vector into subvectors and replaces each with the id of its nearest centroid, so the ratio is tunable rather than fixed. PQ-64 lands a 1,024-dimension float32 vector at 64 bytes, which is 64x.

The thing that makes any of this survivable is the rescore cascade. Retrieve wide with the cheap representation, then re-rank that shortlist with a more precise one you kept elsewhere. The compression only ever has to be good enough to keep the right answer inside the shortlist, not good enough to rank it first. That is why stacking works: Matryoshka truncation, then a binary first pass, then a PQ rescore, then full precision on the final handful.

## Where this diagram appears

*   [Guide: Embedding Quantization and Compression →](/guides/embedding-quantization-compression)

Run this on your own data

Mixpeek turns video, images, audio, and documents in your object storage into searchable, timestamped results through one API.

[Search your own data](https://studio.mixpeek.com/namespaces/create?mode=managed&utm_source=homepage&utm_medium=diagram_detail&utm_campaign=mvs_onramp)

## Related diagrams

[

![An ordinary embedding model spreads information across all dimensions with no ordering guarantee, so dimension 900 may carry as much signal as dimension 5 and truncating the vector discards random pieces of meaning. Matryoshka Representation Learning changes the objective so the model packs the most general information into the front of the vector and progressively finer detail toward the back, which makes every prefix a complete usable coordinate. The nesting is drawn as five bars that all start at dimension 0 and grow: the first 64 dimensions carry coarse semantics, enough to tell a cat photo from a car photo; 128 is the prefix the retrieval cascade indexes the whole corpus at; 256 gives mid resolution, enough to separate breeds of cat or a refund request from a refund confirmation; and the full 1024 gives fine resolution for ranking near-duplicates. The mechanism is a modified loss rather than a special architecture: one forward pass produces one d-dimensional output, the training loss is computed independently at each prefix size in the set 64, 128, 256, 512, 1024, and those losses are summed, so the front of the vector has to work on its own. What it buys is a retrieve-coarse, rerank-fine cascade: index 10,000,000 items at a 128-dimension truncation costing 5.1 GB instead of the full 41 GB, retrieve a top-200 shortlist with the truncated query, fetch the full 1024-dimension vectors for those 200 candidates only, and return a final top 10.](/diagrams/matryoshka-representation-learning.webp)

Matryoshka Representation Learning: One Vector, Five Resolutions



](/diagrams/matryoshka-representation-learning)