Add calibration-free engine_kv module for inference-engine integration (C15a)#32
Draft
jagmarques wants to merge 2 commits into
Draft
Add calibration-free engine_kv module for inference-engine integration (C15a)#32jagmarques wants to merge 2 commits into
jagmarques wants to merge 2 commits into
Conversation
- nexusquant/integrations/engine_kv.py: quantize_kv/dequantize_kv/bpe_accounting API for inference-engine (vLLM-style) KV dtype integration. E8 lattice VQ with Hadamard rotation, per-head fp16 abs-max scale, integer-scale scalar dequant (no codebook lookup, no calibration step). - experiments/kaggle/nq_engine_kv/test_engine_kv.py: CPU unit test, exits 0. Asserts round-trip error in expected range for K3V2, bpe_accounting returns 2.625 bpe, and quantization is non-vacuous (87% codes differ from identity). - experiments/kaggle/nq_engine_kv/nq_engine_kv_bench.py + kernel-metadata.json: GPU bench scaffold for T4 quant/dequant latency sweep (push deferred, quota exhausted).
Bug 1 (hard): test_engine_kv.py had four "../" in the _ROOT path, landing one directory above the repo root. Reduces to three "../" so _ROOT resolves to the repo root; `python3.11 experiments/kaggle/nq_engine_kv/test_engine_kv.py` now exits 0 with no manual PYTHONPATH. Bug 2 (soft): nq_engine_kv_bench.py used sys.path.insert(0, "/kaggle/working") which fails on Kaggle because nothing installs the package there. Replaced with a subprocess pip-install of git+https://github.com/jagmarques/nexusquant.git@main, matching the pattern used by other Kaggle kernels in this repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
nexusquant/integrations/engine_kv.py: a clean KV-quant/dequant API for vLLM-style engines, plus a CPU unit test and GPU bench scaffold.What it does
quantize_kv(k, v, k_bits=3, v_bits=2)returns aPackedKV(int8 codes + fp16 per-head scales). Hadamard rotation first, then E8 nearest-point, then pack as(lattice_point * 2).int8. No calibration, no fit step, no offline data.dequantize_kv(packed)reconstructs fp16 K/V via(code * 0.5) * scale— scalar multiply only, no codebook lookup.bpe_accounting(packed)reports logical bpe (K3V2 = 2.625 bpe, 6.1x vs fp16) and int8 storage bpe (8.125 bpe, ~2x).CPU unit test (
experiments/kaggle/nq_engine_kv/test_engine_kv.py, exit 0 verified):GPU bench scaffold queued in
experiments/kaggle/nq_engine_kv/(kernel-metadata.json pinned to same T4 docker SHA). Not pushed to Kaggle (quota exhausted).Proof of work: