Option-B repro kit: prebuilt SM80 binary wheel (no CUDA/calibration source, audited), build receipt, repro script, license
Browse files- .gitattributes +1 -0
- LICENSE +15 -0
- README.md +61 -0
- fraqtl_repro_receipts.py +303 -0
- fraqtl_runtime-0.2.0+sm80-py3-none-any.whl +3 -0
- wheel_build_receipt.json +59 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
fraqtl_runtime-0.2.0+sm80-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fraQtl Verification License (v1, 2026-07-02)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Samuel Salfati / fraQtl. All rights reserved.
|
| 4 |
+
|
| 5 |
+
Permission is granted, free of charge, to download, install, and execute this
|
| 6 |
+
software solely to verify, benchmark, or evaluate the published fraQtl
|
| 7 |
+
results. Redistribution of the software, use in production systems, and
|
| 8 |
+
reverse engineering, decompilation, or disassembly of the binary components
|
| 9 |
+
are not permitted without prior written permission.
|
| 10 |
+
|
| 11 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 12 |
+
IMPLIED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 13 |
+
OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
|
| 14 |
+
|
| 15 |
+
Contact: samuelsalfati@gmail.com
|
README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: fraqtl-verification
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
tags:
|
| 6 |
+
- kv-cache
|
| 7 |
+
- kv-cache-compression
|
| 8 |
+
- vllm
|
| 9 |
+
- a100
|
| 10 |
+
- fraqtl
|
| 11 |
+
inference: false
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# fraQtl SM80 runtime — prebuilt verification wheel
|
| 15 |
+
|
| 16 |
+
Prebuilt binary wheel of the `fraqtl` vLLM runtime, published so anyone can independently reproduce the fraQtl KV-cache receipts on a rented A100 for ~$15 — **without the kernel or calibration source being distributed**.
|
| 17 |
+
|
| 18 |
+
## What's inside
|
| 19 |
+
|
| 20 |
+
- The fraQtl CUDA kernel as a compiled **SM80 (A100) binary** (`fraqtl/_native/libggml-cuda.so`). No `.cu`/`.c`/header source ships; the build hard-fails if any leaks in (see `wheel_build_receipt.json`).
|
| 21 |
+
- The runtime Python surface (vLLM attention backend, model adapters, sidecar format readers), **Cython-compiled to binary modules**. Calibration and sidecar-factory code is not in the wheel in any form.
|
| 22 |
+
- vLLM plugin auto-registration via the `vllm.general_plugins` entry point — `pip install` the wheel and vLLM's plugin loader finds the backend in every worker process.
|
| 23 |
+
|
| 24 |
+
## Scope
|
| 25 |
+
|
| 26 |
+
- **Hardware: A100 (SM80) only.** The binary will not run on H100, L4, or consumer GPUs.
|
| 27 |
+
- **vLLM 0.20.2, CUDA 12.4, Python 3.11** — the exact receipt environment. Other versions are unsupported.
|
| 28 |
+
- Purpose: verification of the published receipts. It is not a general-purpose release.
|
| 29 |
+
|
| 30 |
+
## Use it
|
| 31 |
+
|
| 32 |
+
Don't drive this by hand — use the one-command repro script (`fraqtl_repro_receipts.py`, in this repo and in the sidecar repos):
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
pip install modal && modal setup
|
| 36 |
+
modal secret create huggingface HF_TOKEN=hf_...
|
| 37 |
+
modal run fraqtl_repro_receipts.py
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
It installs this wheel, pulls the calibrated sidecars from
|
| 41 |
+
[`fraQtl/mistral-7b-instruct-v0.3-kv-sidecars`](https://huggingface.co/fraQtl/mistral-7b-instruct-v0.3-kv-sidecars),
|
| 42 |
+
runs the three-arm receipt (fraQtl D2 vs fp16 vs fp8-KV) at 8K and 32K with a
|
| 43 |
+
needle-in-a-haystack gate per arm, and prints the table.
|
| 44 |
+
|
| 45 |
+
### Honesty footnotes
|
| 46 |
+
|
| 47 |
+
- **NIAH-verified, not "lossless."**
|
| 48 |
+
- **vs-fp8 always visible** — fp8 KV is the real competitor.
|
| 49 |
+
- **Batch-1 decode** for the published speed rows.
|
| 50 |
+
|
| 51 |
+
## Files
|
| 52 |
+
|
| 53 |
+
| File | What |
|
| 54 |
+
|---|---|
|
| 55 |
+
| `fraqtl_runtime-*.whl` | The prebuilt wheel (binary-only) |
|
| 56 |
+
| `wheel_build_receipt.json` | Build provenance: sha256, source-leak audit result, module list |
|
| 57 |
+
| `fraqtl_repro_receipts.py` | The one-command repro script |
|
| 58 |
+
|
| 59 |
+
## License
|
| 60 |
+
|
| 61 |
+
Proprietary; free to install and run for verification and evaluation. No reverse engineering. Sidecars and receipts in the companion repos are Apache 2.0.
|
fraqtl_repro_receipts.py
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""fraQtl three-arm KV-cache receipt — independent reproduction script.
|
| 2 |
+
|
| 3 |
+
Reproduces the published Mistral-7B-Instruct-v0.3 numbers (A100-80GB, vLLM
|
| 4 |
+
0.20.2, CUDA graphs, batch 1, NIAH-gated) for the three arms:
|
| 5 |
+
|
| 6 |
+
D2 fraQtl compressed KV (prebuilt SM80 binary wheel + HF sidecars)
|
| 7 |
+
fp16 stock vLLM
|
| 8 |
+
fp8 vLLM with kv_cache_dtype="fp8" (the real competitor)
|
| 9 |
+
|
| 10 |
+
Published rows this script regenerates (decode tok/s | NIAH | KV pool tokens):
|
| 11 |
+
|
| 12 |
+
ctx 8K : D2 85.7 PASS 997,200 | fp16 90.39 PASS 412,544 | fp8 90.05 PASS 825,104
|
| 13 |
+
ctx 32K: D2 76.84 PASS 937,568 | fp16 77.98 PASS 407,760 | fp8 82.81 PASS 799,952
|
| 14 |
+
|
| 15 |
+
Speed numbers are hardware-run-to-run sensitive at the ±few-percent level;
|
| 16 |
+
NIAH results and KV pool sizes are deterministic.
|
| 17 |
+
|
| 18 |
+
USAGE — Modal (recommended, ~$10-15 of A100 time total):
|
| 19 |
+
pip install modal && modal setup
|
| 20 |
+
modal secret create huggingface HF_TOKEN=hf_... # your token
|
| 21 |
+
modal run fraqtl_repro_receipts.py # all arms, 8K + 32K
|
| 22 |
+
modal run fraqtl_repro_receipts.py --ctx 8k --arms D2,fp16
|
| 23 |
+
|
| 24 |
+
USAGE — Docker fallback (your own A100-80GB box):
|
| 25 |
+
docker run --gpus all -it --rm -e HF_TOKEN=hf_... \
|
| 26 |
+
nvcr.io/nvidia/cuda:12.4.1-devel-ubuntu22.04 bash
|
| 27 |
+
# inside: install python3.11, then
|
| 28 |
+
pip install vllm==0.20.2 numpy huggingface_hub
|
| 29 |
+
python fraqtl_repro_receipts.py --local --ctx 8k
|
| 30 |
+
|
| 31 |
+
Timing method (same as the published receipts): prefix caching OFF; pass A
|
| 32 |
+
generates 1 token (prefill wall), pass B generates 33 tokens; decode tok/s =
|
| 33 |
+
(output tokens - batch) / (wall_B - wall_A). NIAH gate runs per arm at the
|
| 34 |
+
same context, temperature 0, before any timing: a tok/s number on an arm
|
| 35 |
+
that drops the needle is a FAIL, not a win.
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
WHEEL_REPO = "fraQtl/fraqtl-sm80-runtime"
|
| 39 |
+
SIDECAR_REPO = "fraQtl/mistral-7b-instruct-v0.3-kv-sidecars"
|
| 40 |
+
V_SIDECAR = "sidecar_real_u_mistral-7b-instruct-v0.3.bin"
|
| 41 |
+
K_SIDECAR = "mistral-7b-instruct-v0.3-k16-int3.fraqtl-k-eigenbasis.bin"
|
| 42 |
+
K_RECEIPT = "receipts/mistral_S2_exp16_k16_int3_receipt_2026-05-26.json"
|
| 43 |
+
HF_MODEL = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 44 |
+
N_HEADS_Q = 32
|
| 45 |
+
BLOCK_SIZE = 16
|
| 46 |
+
PASSKEY = "48291"
|
| 47 |
+
GPU_MEM_UTIL = 0.85
|
| 48 |
+
DECODE_TOKENS = 32
|
| 49 |
+
CTX_POINTS = {"8k": (9216, 8192), "32k": (32768, 32000)} # (max_model_len, ctx)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _download_kit(d2: bool):
|
| 53 |
+
"""Fetch the fraQtl wheel + sidecars from Hugging Face (D2 arm only)."""
|
| 54 |
+
import subprocess
|
| 55 |
+
import sys
|
| 56 |
+
from huggingface_hub import hf_hub_download, list_repo_files
|
| 57 |
+
|
| 58 |
+
if not d2:
|
| 59 |
+
return {}
|
| 60 |
+
whl_name = next(f for f in list_repo_files(WHEEL_REPO) if f.endswith(".whl"))
|
| 61 |
+
whl = hf_hub_download(WHEEL_REPO, whl_name)
|
| 62 |
+
subprocess.run([sys.executable, "-m", "pip", "install", "-q",
|
| 63 |
+
"--no-deps", whl], check=True)
|
| 64 |
+
return {
|
| 65 |
+
"v": hf_hub_download(SIDECAR_REPO, V_SIDECAR),
|
| 66 |
+
"k": hf_hub_download(SIDECAR_REPO, K_SIDECAR),
|
| 67 |
+
"k_receipt": hf_hub_download(SIDECAR_REPO, K_RECEIPT),
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _set_d2_env(paths, max_model_len):
|
| 72 |
+
"""The exact runtime configuration recorded in the published receipts
|
| 73 |
+
(recipe: K 16 protected + INT4 tail, V 32 protected + INT4 tail,
|
| 74 |
+
logical rank 128; reader warptile_v32; split target 256)."""
|
| 75 |
+
import os
|
| 76 |
+
env = {
|
| 77 |
+
"FRAQTL_K_SIDECAR": paths["k"],
|
| 78 |
+
"FRAQTL_K_SIDECAR_RECEIPT": paths["k_receipt"],
|
| 79 |
+
"FRAQTL_V_SIDECAR": paths["v"],
|
| 80 |
+
"FRAQTL_N_HEADS_Q": str(N_HEADS_Q),
|
| 81 |
+
"FRAQTL_BLOCK_SIZE": str(BLOCK_SIZE),
|
| 82 |
+
"FRAQTL_MAX_N_TOKENS": str(max_model_len),
|
| 83 |
+
"FRAQTL_K_TAIL_BITS": "4",
|
| 84 |
+
"FRAQTL_V_TAIL_BITS": "3",
|
| 85 |
+
"FRAQTL_SINK_N": "8",
|
| 86 |
+
"FRAQTL_RESIDUAL_N": "1024",
|
| 87 |
+
"FRAQTL_ATTENTION_IMPL": "sm80_membrane",
|
| 88 |
+
"FRAQTL_DENSE_RANKSPACE_ATTENTION": "0",
|
| 89 |
+
"FRAQTL_SM80_MEMBRANE_PRODUCT_MODE": "1",
|
| 90 |
+
"FRAQTL_SM80_MEMBRANE_K16_PROD": "1",
|
| 91 |
+
"FRAQTL_SM80_MEMBRANE_WMMA_STAGED": "0",
|
| 92 |
+
"FRAQTL_SM80_MEMBRANE_DEBUG_SCALAR": "0",
|
| 93 |
+
"FRAQTL_SM80_KTAIL_FP16_RESCUE": "0",
|
| 94 |
+
"FRAQTL_SM80_V_THEOREM_PACKED": "1",
|
| 95 |
+
"FRAQTL_SM80_V_THEOREM_PROTECT": "32",
|
| 96 |
+
"FRAQTL_SM80_MEMBRANE_FLOAT_PV": "0",
|
| 97 |
+
"FRAQTL_SM80_MEMBRANE_FLOAT_QK": "0",
|
| 98 |
+
"FRAQTL_SM80_MEMBRANE_READER": "warptile_v32",
|
| 99 |
+
"FRAQTL_SM80_MEMBRANE_V32_VEC_STAGE": "0",
|
| 100 |
+
"FRAQTL_SM80_DEBUG_OUTPUT_SENTINEL": "0",
|
| 101 |
+
"FRAQTL_SM80_PROFILE_KERNELS": "0",
|
| 102 |
+
"FRAQTL_SM80_MEMBRANE_SPLIT_TARGET": "256",
|
| 103 |
+
"FRAQTL_SM80_PAIRDOT_FRAGMENT_REALPAGE_WITNESS": "0",
|
| 104 |
+
"FRAQTL_SM80_VTAIL_FRAGMENT_NATIVE": "0",
|
| 105 |
+
"FRAQTL_SM80_RETURN_DENSE_RV128": "0",
|
| 106 |
+
"FRAQTL_SM80_CHECK_SLOT_TABLE": "0",
|
| 107 |
+
"FRAQTL_SM80_COMPARE_PREFILL_PAGE": "0",
|
| 108 |
+
"FRAQTL_SM80_COMPARE_PREFILL_PAGE_LAYERS": "0",
|
| 109 |
+
"FRAQTL_SM80_DECODE_RV64_PARITY": "0",
|
| 110 |
+
"FRAQTL_SM80_DECODE_RV64_PARITY_LAYER": "31",
|
| 111 |
+
"FRAQTL_RANKSPACE_RK": "128",
|
| 112 |
+
"FRAQTL_RANKSPACE_RV": "128",
|
| 113 |
+
"FRAQTL_RANKSPACE_TAIL_MODE": "truncate",
|
| 114 |
+
"FRAQTL_RANKSPACE_K_PROTECT": "16",
|
| 115 |
+
"FRAQTL_RANKSPACE_V_PROTECT": "32",
|
| 116 |
+
"FRAQTL_RANKSPACE_FUSE_Q": "0",
|
| 117 |
+
"FRAQTL_RANKSPACE_FUSE_Q_UV": "0",
|
| 118 |
+
"FRAQTL_RANKSPACE_FUSE_WRITE_QUANT": "0",
|
| 119 |
+
"FRAQTL_RANKSPACE_UV_BLOCK_D": "32",
|
| 120 |
+
"FRAQTL_PACKED_PREPROJECT_Q": "1",
|
| 121 |
+
"FRAQTL_PACKED_DECODE_BN": "64",
|
| 122 |
+
"FRAQTL_PACKED_DECODE_SPLITS": "1",
|
| 123 |
+
"FRAQTL_PACKED_WRITER_FUSED_DOT": "0",
|
| 124 |
+
"FRAQTL_PACKED_PREFILL_WRITER_FUSED_DOT": "0",
|
| 125 |
+
"FRAQTL_PACKED_DECODE_WRITER_FUSED_DOT": "0",
|
| 126 |
+
"FRAQTL_PACKED_DECODE_WRITER_MODE": "prepack",
|
| 127 |
+
"FRAQTL_PACKED_V_LAYOUT": "dense3",
|
| 128 |
+
"FRAQTL_PACKED_DECODE_LANE": "pairk",
|
| 129 |
+
"FRAQTL_PACKED_DECODE_WORKSPACE_REUSE": "0",
|
| 130 |
+
"FRAQTL_FOLD_O_PROJ": "1",
|
| 131 |
+
"FRAQTL_FOLD_O_PROJ_DUAL": "0",
|
| 132 |
+
"FRAQTL_FOLD_O_PROJ_DUAL_SHADOW": "0",
|
| 133 |
+
"FRAQTL_FOLD_O_PROJ_DUAL_RANK_WEIGHT_DTYPE": "fp16",
|
| 134 |
+
"FRAQTL_FOLD_O_PROJ_PARITY": "0",
|
| 135 |
+
"FRAQTL_FOLD_O_PROJ_PARITY_LAYER": "0",
|
| 136 |
+
"FRAQTL_FOLD_O_PROJ_PARITY_MAX": "8",
|
| 137 |
+
"FRAQTL_D2_RANK_FP16_FASTPATH": "1",
|
| 138 |
+
"FRAQTL_D2_RANK_FP16_SYMMETRIC": "1",
|
| 139 |
+
"FRAQTL_PACKED_STAGE_TIMING": "0",
|
| 140 |
+
"FRAQTL_PACKED_STAGE_TIMING_LIMIT": "64",
|
| 141 |
+
"FRAQTL_PACKED_STAGE_TIMING_SKIP": "0",
|
| 142 |
+
}
|
| 143 |
+
os.environ.update(env)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
def _build_niah_prompt(tokenizer, target_tokens, passkey):
|
| 147 |
+
"""Needle-in-a-haystack prompt, identical to the published receipts."""
|
| 148 |
+
filler = ("The grass is green. The sky is blue. The sun is bright. "
|
| 149 |
+
"We walk in the park every day. ")
|
| 150 |
+
needle = f" The pass key is {passkey}. Remember it. "
|
| 151 |
+
half = filler * max(1, target_tokens // (len(tokenizer(filler)["input_ids"]) * 2 or 1))
|
| 152 |
+
body = half + needle + half
|
| 153 |
+
q = "\n\nWhat is the pass key? The pass key is"
|
| 154 |
+
ids = tokenizer(body)["input_ids"]
|
| 155 |
+
if len(ids) > target_tokens - 64:
|
| 156 |
+
ids = ids[: target_tokens - 64]
|
| 157 |
+
body = tokenizer.decode(ids)
|
| 158 |
+
mid = len(body) // 2
|
| 159 |
+
body = body[:mid] + needle + body[mid:]
|
| 160 |
+
return body + q
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def _build_timing_prompt(tokenizer, target_tokens):
|
| 164 |
+
filler = ("The grass is green. The sky is blue. We walk in the park "
|
| 165 |
+
"every day and discuss the weather at length. ")
|
| 166 |
+
ids = tokenizer(filler)["input_ids"]
|
| 167 |
+
reps = max(1, (target_tokens - 64) // max(1, len(ids)))
|
| 168 |
+
ids = tokenizer(filler * reps)["input_ids"][: max(16, target_tokens - 64)]
|
| 169 |
+
return tokenizer.decode(ids) + "\n\nSummarize the above in one sentence:"
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def run_arm(mode: str, ctx_key: str) -> dict:
|
| 173 |
+
"""One arm at one context point: engine init -> NIAH gate -> timing."""
|
| 174 |
+
import json
|
| 175 |
+
import re
|
| 176 |
+
import time
|
| 177 |
+
|
| 178 |
+
max_model_len, ctx_tokens = CTX_POINTS[ctx_key]
|
| 179 |
+
rep = {"mode": mode, "ctx": ctx_key, "model": HF_MODEL,
|
| 180 |
+
"max_model_len": max_model_len, "ctx_tokens": ctx_tokens,
|
| 181 |
+
"cuda_graphs": True, "prefix_caching": False, "batch": 1,
|
| 182 |
+
"gpu_memory_utilization": GPU_MEM_UTIL}
|
| 183 |
+
|
| 184 |
+
paths = _download_kit(d2=(mode == "D2"))
|
| 185 |
+
if mode == "D2":
|
| 186 |
+
_set_d2_env(paths, max_model_len)
|
| 187 |
+
from fraqtl.integrations.vllm_attention import register
|
| 188 |
+
register()
|
| 189 |
+
|
| 190 |
+
from vllm import LLM, SamplingParams
|
| 191 |
+
|
| 192 |
+
llm_kwargs = dict(model=HF_MODEL, dtype="float16",
|
| 193 |
+
max_model_len=max_model_len, enforce_eager=False,
|
| 194 |
+
gpu_memory_utilization=GPU_MEM_UTIL,
|
| 195 |
+
enable_prefix_caching=False,
|
| 196 |
+
enable_chunked_prefill=False)
|
| 197 |
+
if mode == "D2":
|
| 198 |
+
from vllm.config.attention import AttentionConfig
|
| 199 |
+
llm_kwargs["attention_config"] = AttentionConfig(backend="CUSTOM")
|
| 200 |
+
elif mode == "fp8":
|
| 201 |
+
llm_kwargs["kv_cache_dtype"] = "fp8"
|
| 202 |
+
elif mode != "fp16":
|
| 203 |
+
raise ValueError(f"unknown arm {mode!r}")
|
| 204 |
+
|
| 205 |
+
llm = LLM(**llm_kwargs)
|
| 206 |
+
num_blocks = int(llm.llm_engine.vllm_config.cache_config.num_gpu_blocks)
|
| 207 |
+
rep["kv_pool_tokens"] = num_blocks * BLOCK_SIZE
|
| 208 |
+
tok = llm.get_tokenizer()
|
| 209 |
+
|
| 210 |
+
# NIAH gate first — it gates the speed number.
|
| 211 |
+
niah = _build_niah_prompt(tok, ctx_tokens, PASSKEY)
|
| 212 |
+
out = llm.generate([niah], SamplingParams(max_tokens=16, temperature=0.0))
|
| 213 |
+
gen = out[0].outputs[0].text
|
| 214 |
+
rep["niah_generated"] = gen[:80]
|
| 215 |
+
rep["needle_found"] = re.search(rf"\b{PASSKEY}\b", gen) is not None
|
| 216 |
+
print(f"NIAH[{mode}/{ctx_key}] found={rep['needle_found']} gen={gen[:50]!r}",
|
| 217 |
+
flush=True)
|
| 218 |
+
|
| 219 |
+
# Two-pass prefill/decode split, batch 1.
|
| 220 |
+
prompt = _build_timing_prompt(tok, ctx_tokens)
|
| 221 |
+
n_prompt_tok = len(tok(prompt)["input_ids"])
|
| 222 |
+
sp_one = SamplingParams(max_tokens=1, temperature=0.0, ignore_eos=True)
|
| 223 |
+
sp_full = SamplingParams(max_tokens=DECODE_TOKENS + 1, temperature=0.0,
|
| 224 |
+
ignore_eos=True)
|
| 225 |
+
t_a = time.time()
|
| 226 |
+
llm.generate([prompt], sp_one)
|
| 227 |
+
wall_prefill = time.time() - t_a
|
| 228 |
+
t_b = time.time()
|
| 229 |
+
outs = llm.generate([prompt], sp_full)
|
| 230 |
+
wall_total = time.time() - t_b
|
| 231 |
+
out_toks = sum(len(o.outputs[0].token_ids) for o in outs)
|
| 232 |
+
wall_decode = max(wall_total - wall_prefill, 1e-9)
|
| 233 |
+
rep.update({
|
| 234 |
+
"prefill_tok_s": round(n_prompt_tok / wall_prefill, 2),
|
| 235 |
+
"decode_tok_s": round((out_toks - 1) / wall_decode, 2),
|
| 236 |
+
"timing_design": ("two-pass subtractive; prefix cache disabled, "
|
| 237 |
+
"decode ~= wall_full_decode - wall_one_token"),
|
| 238 |
+
})
|
| 239 |
+
print(f"ARM[{mode}/{ctx_key}] {json.dumps(rep, default=str)}", flush=True)
|
| 240 |
+
return rep
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def print_table(rows):
|
| 244 |
+
print("\narm ctx NIAH decode_tok_s prefill_tok_s kv_pool_tokens")
|
| 245 |
+
for r in rows:
|
| 246 |
+
if "error" in r:
|
| 247 |
+
print(f"{r['mode']:<6} {r['ctx']:<4} ERROR {r['error'][:60]}")
|
| 248 |
+
continue
|
| 249 |
+
niah = "PASS" if r.get("needle_found") else "FAIL"
|
| 250 |
+
print(f"{r['mode']:<6} {r['ctx']:<4} {niah:<5} "
|
| 251 |
+
f"{r.get('decode_tok_s', ''):<13} {r.get('prefill_tok_s', ''):<14} "
|
| 252 |
+
f"{r.get('kv_pool_tokens', ''):,}")
|
| 253 |
+
print("\nNIAH-verified, not lossless. fp8 arm shown always. Batch-1 decode.")
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
# ---------------------------------------------------------------- Modal path
|
| 257 |
+
try:
|
| 258 |
+
import modal
|
| 259 |
+
|
| 260 |
+
app = modal.App("fraqtl-option-b-repro")
|
| 261 |
+
image = (
|
| 262 |
+
modal.Image.from_registry("nvidia/cuda:12.4.1-devel-ubuntu22.04",
|
| 263 |
+
add_python="3.11")
|
| 264 |
+
.pip_install("vllm==0.20.2", "numpy", "huggingface_hub",
|
| 265 |
+
extra_options="--no-cache-dir")
|
| 266 |
+
.add_local_file(__file__, "/root/fraqtl_repro_receipts.py")
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
@app.function(image=image, gpu="A100-80GB", timeout=7200,
|
| 270 |
+
secrets=[modal.Secret.from_name("huggingface")])
|
| 271 |
+
def modal_arm(mode: str, ctx_key: str) -> dict:
|
| 272 |
+
import sys
|
| 273 |
+
sys.path.insert(0, "/root")
|
| 274 |
+
from fraqtl_repro_receipts import run_arm
|
| 275 |
+
return run_arm(mode, ctx_key)
|
| 276 |
+
|
| 277 |
+
@app.local_entrypoint()
|
| 278 |
+
def main(arms: str = "D2,fp16,fp8", ctx: str = "8k,32k"):
|
| 279 |
+
rows = []
|
| 280 |
+
for ck in [c.strip().lower() for c in ctx.split(",") if c.strip()]:
|
| 281 |
+
for mode in [a.strip() for a in arms.split(",") if a.strip()]:
|
| 282 |
+
try:
|
| 283 |
+
rows.append(modal_arm.remote(mode, ck))
|
| 284 |
+
except Exception as e: # keep going; partial table still useful
|
| 285 |
+
rows.append({"mode": mode, "ctx": ck, "error": str(e)[:200]})
|
| 286 |
+
print_table(rows)
|
| 287 |
+
except ImportError:
|
| 288 |
+
pass
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
if __name__ == "__main__": # Docker / bare-metal fallback (--local)
|
| 292 |
+
import argparse
|
| 293 |
+
|
| 294 |
+
ap = argparse.ArgumentParser()
|
| 295 |
+
ap.add_argument("--local", action="store_true", required=True)
|
| 296 |
+
ap.add_argument("--arms", default="D2,fp16,fp8")
|
| 297 |
+
ap.add_argument("--ctx", default="8k,32k")
|
| 298 |
+
a = ap.parse_args()
|
| 299 |
+
rows = []
|
| 300 |
+
for ck in [c.strip().lower() for c in a.ctx.split(",") if c.strip()]:
|
| 301 |
+
for mode in [m.strip() for m in a.arms.split(",") if m.strip()]:
|
| 302 |
+
rows.append(run_arm(mode, ck))
|
| 303 |
+
print_table(rows)
|
fraqtl_runtime-0.2.0+sm80-py3-none-any.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:898853a871bb63b78db77515f664110e0575d66a1f3620486fc9d67043b8916c
|
| 3 |
+
size 249494500
|
wheel_build_receipt.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"arch": "80",
|
| 3 |
+
"version": "0.2.0+sm80",
|
| 4 |
+
"so": "/cache/prebuilt_so/ac84206530d0ffc6_sm80/libggml-cuda.so",
|
| 5 |
+
"so_size_mb": 227.0,
|
| 6 |
+
"staged_modules": [
|
| 7 |
+
"fraqtl/__init__.py",
|
| 8 |
+
"fraqtl/auth.py",
|
| 9 |
+
"fraqtl/integrations/__init__.py",
|
| 10 |
+
"fraqtl/integrations/cuda_bridge.py",
|
| 11 |
+
"fraqtl/integrations/kv_cache_spec.py",
|
| 12 |
+
"fraqtl/integrations/memory_proof.py",
|
| 13 |
+
"fraqtl/integrations/packed_rankspace_cache.py",
|
| 14 |
+
"fraqtl/integrations/paged_layout.py",
|
| 15 |
+
"fraqtl/integrations/rankspace_o_proj_runtime_parity.py",
|
| 16 |
+
"fraqtl/integrations/rankspace_output_fold.py",
|
| 17 |
+
"fraqtl/integrations/stack_identity.py",
|
| 18 |
+
"fraqtl/integrations/triton_flashdecode_paged_rankspace.py",
|
| 19 |
+
"fraqtl/integrations/triton_flashdecode_rankspace.py",
|
| 20 |
+
"fraqtl/integrations/triton_packed_rankspace_vllm.py",
|
| 21 |
+
"fraqtl/integrations/triton_rankspace_postprocess.py",
|
| 22 |
+
"fraqtl/integrations/triton_rankspace_query.py",
|
| 23 |
+
"fraqtl/integrations/triton_rankspace_vllm.py",
|
| 24 |
+
"fraqtl/integrations/triton_rankspace_writer.py",
|
| 25 |
+
"fraqtl/integrations/triton_vllm_decode.py",
|
| 26 |
+
"fraqtl/integrations/vllm_asym_flash_attn.py",
|
| 27 |
+
"fraqtl/integrations/vllm_attention.py",
|
| 28 |
+
"fraqtl/integrations/vllm_model_adapters.py",
|
| 29 |
+
"fraqtl/integrations/vllm_plugin.py",
|
| 30 |
+
"fraqtl/integrations/vllm_runtime_init.py",
|
| 31 |
+
"fraqtl/sidecar_factory/__init__.py",
|
| 32 |
+
"fraqtl/sidecar_factory/formats.py",
|
| 33 |
+
"fraqtl/sidecar_factory/manifest.py",
|
| 34 |
+
"fraqtl/sidecar_factory/model_config.py",
|
| 35 |
+
"fraqtl/sidecar_factory/self_test.py",
|
| 36 |
+
"fraqtl/utils.py"
|
| 37 |
+
],
|
| 38 |
+
"native_libs": [
|
| 39 |
+
"libggml-base.so",
|
| 40 |
+
"libggml-base.so.0",
|
| 41 |
+
"libggml-base.so.0.10.0",
|
| 42 |
+
"libggml-cuda.so",
|
| 43 |
+
"libggml-cuda.so.0",
|
| 44 |
+
"libggml-cuda.so.0.10.0"
|
| 45 |
+
],
|
| 46 |
+
"wheel": "fraqtl_runtime-0.2.0+sm80-py3-none-any.whl",
|
| 47 |
+
"wheel_size_mb": 249.5,
|
| 48 |
+
"files_in_wheel": 41,
|
| 49 |
+
"py_files_in_wheel": [
|
| 50 |
+
"fraqtl/__init__.py",
|
| 51 |
+
"fraqtl/integrations/__init__.py",
|
| 52 |
+
"fraqtl/sidecar_factory/__init__.py"
|
| 53 |
+
],
|
| 54 |
+
"source_leaks": 0,
|
| 55 |
+
"resolved_so": "/usr/local/lib/python3.11/site-packages/fraqtl/_native/libggml-cuda.so",
|
| 56 |
+
"sha256": "898853a871bb63b78db77515f664110e0575d66a1f3620486fc9d67043b8916c",
|
| 57 |
+
"volume_path": "/cache/repro_kit/fraqtl_runtime-0.2.0+sm80-py3-none-any.whl",
|
| 58 |
+
"wall_s": 212.7
|
| 59 |
+
}
|