# Vector Quantization Math: FP32 vs halfvec FP16 vs INT8 vs Binary Oversampling & CUDA AMQ

> Ten million 3,072-dimension FP32 embeddings require 122.88 GB of raw vector payload (~147 GB resident with HNSW graph edges), forcing costly high-memory database instances. Switching to FP16 halfvec halves payload RAM to 61.44 GB with 99.8% recall retention, while 1-bit binary quantization shrinks index RAM 32x to 3.84 GB using 4x oversampled rescoring. Voxell Forge pairs compact vectors with 64-bit CUDA AMQ filtering.

Canonical URL: https://voxell.ai/optimize/vector-quantization-fp32-halfvec-int8-binary-amq/


## Exact Byte-Level HNSW Sizing Math (`10,000,000` Vectors)

Most cloud vector cost blowups stem from confusing **raw vector payload bytes** with **resident HNSW memory**. For $N$ vectors of dimension $D$ at $b$ bytes per coordinate and HNSW degree $m = 16$:

$$\text{RAM}_{\text{resident}} \approx 1.20 \times N \times \left(D \cdot b + 16 \cdot m_{\text{links}} + \text{header}\right)$$

Here is the exact breakdown for `10,000,000` chunks on `3,072d` (`text-embedding-3-large` / `gemini-embedding-001`) vs `2,560d` (`Forge Pro`) and `1,024d` (`Forge Turbo`):

| Precision / Quantization | Bytes / Dim | `10M x 3072d` Raw Payload | `10M x 3072d` Resident HNSW | Relative Recall Retention | `pgvector 0.7/0.8` Type |
| :--- | :--- | :--- | :--- | :--- | :--- |
| **`FP32` (IEEE-754 single)** | `4.0 B` | `122.88 GB` | `~151.3 GB` *(Blocked >2000d in pgvector)* | `100.0%` baseline | `vector(D)` (`D <= 2000`) |
| **`FP16` (`halfvec`)** | `2.0 B` | `61.44 GB` | `~77.6 GB` | `99.8% - 99.95%` | `halfvec(D)` (`D <= 4000`) |
| **`INT8` Scalar (`SQ8`)** | `1.0 B` | `30.72 GB` | `~40.7 GB` | `98.8% - 99.5%` | Qdrant / Milvus / Lucene `int8` |
| **`1-Bit` Binary + `4x` FP16 Rescore** | `0.125 B` (index) | `3.84 GB` (HNSW) + `61.4 GB` NVMe | `~8.4 GB` RAM + NVMe page reads | `96.8% - 98.4%` (`3072d`) | `bit(D)` + `halfvec(D)` heap |
| **Voxell Forge `Turbo` (`1024d` `FP16`)** | `2.0 B` | `20.48 GB` | **`~28.4 GB`** | **Native `1024d` (**$0** tokens)** | `vector(1024)` / `halfvec(1024)` |
| **Voxell Forge `Pro` (`2560d`) + 64b CUDA AMQ** | `2.0 B` + `8 B` AMQ | `51.20 GB` | **`< 14 GB` VRAM (Forge Local VPC)** | **`99.04% Recall@20` / `0.8849` w/ `Max`** | Managed Cloud or 1x 24GB GPU |

*(Model your exact vector count from `100k` to `100M` interactively in the **[Vector RAM & TCO Calculator](/tools/vector-calculator/)**.)*

## Runnable SQL: Two-Phase Binary HNSW + `4x` `halfvec` Rescoring in `pgvector`

In `pgvector 0.7.0+`, `binary_quantize(halfvec)` maps positive floats to `1` and non-positive floats to `0` (which **requires zero-centered, L2-normalized embeddings**; see [Guide 02](/optimize/gemini-embedding-001-mrl-l2-normalization/) and [Guide 06](/optimize/embedding-anisotropy-mean-centering-domain-drift/)). You keep the compact `bit(3072)` HNSW index pinned in RAM (`3.84 GB` payload at `10M` rows) while `halfvec(3072)` sits on fast NVMe SSD, fetched only for the top `80` (`4 * 20`) finalists:

```sql
-- 1. Store halfvec(3072) on NVMe heap; build tiny RAM-resident 1-bit Hamming HNSW index
CREATE TABLE corpus_vectors (
  id BIGSERIAL PRIMARY KEY,
  doc_id TEXT NOT NULL,
  embedding halfvec(3072) NOT NULL
);

CREATE INDEX idx_corpus_bin_hnsw
  ON corpus_vectors
  USING hnsw ((binary_quantize(embedding)::bit(3072)) bit_hamming_ops)
  WITH (m = 16, ef_construction = 128);

-- 2. Query-time 4x oversampled POPCNT scan -> exact FP16 cosine rescore
SET LOCAL hnsw.ef_search = 100;

WITH binary_candidates AS MATERIALIZED (
  SELECT id, doc_id, embedding
  FROM corpus_vectors
  ORDER BY binary_quantize(embedding)::bit(3072) <~> binary_quantize($1::halfvec(3072))
  LIMIT 80  -- 4x oversample for final top-20
)
SELECT id, doc_id,
       1 - (embedding <=> $1::halfvec(3072)) AS cosine_similarity
FROM binary_candidates
ORDER BY embedding <=> $1::halfvec(3072)
LIMIT 20;
```

## Beyond Sign-Bit Clipping: Play 1 64-Bit CUDA Cuckoo AMQ + Single-GPU VPC

Sign-bit binary quantization degrades sharply when corpus embeddings exhibit narrow-cone anisotropy (where `70%+` of coordinates share the same sign across documents) or when tenant/ACL filters force thousands of random NVMe heap fetches per query.

Voxell Forge eliminates multi-node RAM sprawl at the hardware and kernel level:
1. **Play 1 64-Bit CUDA Cuckoo AMQ:** Sub-millisecond GPU-resident approximate membership filtering prunes non-matching tenant, ACL, and lexical fingerprint candidates *before* distance evaluation.
2. **Single-24GB-GPU Sovereign VPC (`Forge Local`):** Packs all five stages (document AST parsing, `C_corpus` zero-LLM conditioning, dense + AMQ search, `Max` cross-encoder reranking at `0.8849 nDCG@10`, and Streamable HTTP `/mcp`) into **`< 14 GB` VRAM** on one `g6.xlarge` / L4 GPU (**$9,995/yr** Dev/PoC; **$29,995/yr** Production) atop plain `$0.02/GB` object storage.

Run a keyless retrieval verification right now:

```bash
curl -sS -X POST https://api.voxell.ai/api/v1/agent/bakeoff \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"name": "quant-bin.md", "text": "1-bit binary quantization shrinks 10M x 3072d payloads to 3.84 GB and requires 4x oversampled FP16 rescoring."},
      {"name": "forge-vpc.md", "text": "Forge Local executes 5-stage retrieval and cross-encoder reranking in under 14 GB VRAM on a single 24 GB GPU."}
    ],
    "queries": ["How much VRAM does Forge Local require for 5-stage retrieval and reranking?"]
  }'
```

Plug your workload into the **[Vector RAM & TCO Calculator](/tools/vector-calculator/)**, compare **[Single-GPU VPC vs Multi-GPU Clusters](/compare/single-gpu-vpc-rag/)**, or review **[v4.0 Pricing](/pricing/)** and open the **[Forge Console](https://dash.voxell.ai/home)**.

## Frequently Asked Questions

### How much RAM do 10 million 3072-dimension vectors actually consume in HNSW?

Raw float32 vector payloads take 10,000,000 * 3,072 * 4 bytes = 122.88 GB (114.44 GiB). Adding HNSW m=16 bidirectional graph edges (~256 to 320 bytes per vector) plus 20% PostgreSQL or vector-engine memory headroom brings resident RAM to ~150+ GB.

### Why does 1-bit binary quantization require 4x oversampled rescoring?

Sign-thresholding float32 coordinates into 1-bit Hamming codes discards magnitude nuances inside each orthant, dropping raw top-k recall to 82%-89% at 3072d. Fetching 4*k candidates via ultra-fast POPCNT Hamming distance and rescoring those 4*k rows against disk-backed halfvec FP16 restores ~97%-98.5% of float32 recall.

### How does Voxell Forge achieve < 14 GB VRAM in Forge Local Sovereign VPC?

Voxell Forge combines compact 1024d/2560d representations, Play 1 64-bit CUDA Cuckoo Approximate Membership Query (AMQ) pre-filtering, and fused two-stage GPU execution so the entire 5-stage retrieval, reranking, and MCP stack runs in under 14 GB VRAM on a single 24 GB GPU ($9,995/yr Dev, $29,995/yr Production).

---

## Zero-Install Model Context Protocol (MCP) & Keyless Agent Verification

```bash
claude mcp add --transport http voxell-forge https://api.voxell.ai/mcp/try
```

- Keyless Retrieval Bake-Off: `POST https://api.voxell.ai/api/v1/agent/bakeoff`
- Keyless Contradiction X-Ray: `POST https://api.voxell.ai/api/v1/agent/xray`
- Machine-Readable Pricing JSON: `https://voxell.ai/api/v1/agent/pricing.json`
- Full LLM Authority Map: `https://voxell.ai/llms-full.txt`
