Developer Guide¶
This guide focuses on changing the code without confusing diagnostic behavior with serving behavior.
Setup¶
Test Commands¶
python -m pytest tests -q
python -m pytest tests/test_vllm_recipe.py -q
python -m pytest tests/test_hf_dynamic_cache.py -q
Documentation Commands¶
Development Rules¶
- Keep diagnostic and serving paths separate.
- Count all metadata and workspace bytes.
- Do not report speed gains without a named baseline.
- Do not use random-tensor tests as model-quality evidence.
- Keep reference implementations outside runtime imports.
- Add tests for byte layout, shape, and failure behavior.
Review Checklist¶
Before merging a runtime change:
- Does the changed path reconstruct dense historical K/V?
- Does the report label diagnostic reconstruction?
- Are all byte categories represented?
- Is the baseline named?
- Are unsupported formats rejected?
- Are shape and dtype assumptions tested?
- Does the code avoid importing from
other_implemnetations/?
Adding A KV Format¶
- Add format description in
turboquant.kv.formats. - Add packing/unpacking helpers if needed.
- Add byte accounting in
turboquant.kv.memory. - Add cache policy mapping.
- Add attention reference behavior.
- Add Triton path only after reference tests pass.
- Add quality and byte-report tests.
Adding A Metadata Field¶
- Add the field to the dataclass.
- Add JSON serialization and parsing.
- Add validation in the loader or runtime resolver.
- Add a round-trip test.
- Add a compatibility note if older files omit the field.
Adding A vLLM Route¶
- Define cache dtype and gate behavior.
- Define page shape and slot byte math.
- Add packed update contract.
- Add packed decode contract.
- Add kernel wrapper and tests.
- Add runtime selection and fallback errors.
- Update vLLM Audit.
Test Tiers¶
| Tier | Example |
|---|---|
| Byte layout | tests/test_packing_bits.py, tests/test_vllm_page_cache.py |
| Math | tests/test_core_codebook.py, tests/test_core_mse.py |
| Runtime contract | tests/test_vllm_tq4_update.py, tests/test_vllm_tq4_decode.py |
| Integration | tests/test_hf_dynamic_cache.py, tests/test_integration_phase7.py |
| Quality | tests/test_quality_metrics.py, retrieval and trajectory tests |
Run the narrow test first, then the suite: