Repository navigation
Changelog
All notable changes to AdapTQ are documented in this file.
Format follows Keep a Changelog.
Unreleased
0.2.3 — 2026-10-04 — V2.3: PyPI Release Unblocker
Fixed
- PyPI Release: Bumped version to
0.2.3to bypass PyPI's 14-day lock on modifying existing release versions, allowing the0.2.2stabilization and streaming fixes to be successfully published.
0.2.2 — 2026-10-04 — Stabilization, Streaming & Release Hygiene
Added
- Ollama Streaming Generation: Implemented
generate_streaming()inOllamaAdapter
using chunked NDJSON streaming via/api/generatewithstream: True. Resolves the
issue where the Ollama adapter yielded no tokens becausedecode_next()returnsNone
for REST-only backends. - Ollama Demo Streaming Flag: Added
--streamoption toexamples/ollama_demo.py
to demonstrate real-time token streaming. - Unit Tests (
tests/test_ollama_streaming.py): Offline mock suite validating ordered
fragment delivery, malformed-chunk skipping, HTTP error reporting, and post-exhaustion
metric capture. - Integration test:
integration_tests/test_llama_cpp_python_tracking.py— unit
coverage for llama-cpp-python KV tracking without serializing llama state. adaptq/paged_cache.py:PagedKVCachewith block allocator, copy-on-write prefix
sharing, and sequence block-table management.
Fixed
- Production → research dependency:
adaptq/runtime_py/backends/transformers_hf.py
previously importedadaptq.research.packed_kv_pt. Fixed to import from
adaptq.reference.packed_kv_pt(production reference module). - Max-Lloyd Codebook Boundaries (Issue #16): Resolved potential floating-point
exceptions and undefined behaviour when constructing centroids from vectors containing
NaNs, infinite outliers, or pure-zero sequences. - Snapshot Storage Validations: Added bound checks to
SessionSnapshot::load()
preventing illegal dimensions, token counts, and bit widths from causing malformed
buffer allocations. - Optional-dependency test skip:
test_llama_cpp_python_availableand
test_transformers_backend_availablenow skip cleanly viapytest.skip()when the
optional backend package is absent, instead of failing withAssertionError.
Portability
- AVX2 Dynamic Dispatch (Issue #7): Refactored away from global
-mavx2flags and
#ifdef __AVX2__guards. Uses__builtin_cpu_supportswith function-level
#pragma GCC target. Binary wheels fall back to scalar on older CPUs instead of
crashing withSIGILL.
Documentation
- README: Removed unsupported performance image, corrected API Quick Start examples
to match V2.1create_adapter()/ModelConfigAPI. - Backend accuracy:
vllmandmlxdocumented as stubs (planned V3);ollama
documented as REST-only (no internal KV interception). - Docs: Replaced all stale
build_v2CLI references withbuild_releaseacross
docs/testing.md,docs/v2.1_integration.md,docs/v2_replay.md.
CI
ci.yml: Pytest step now uses-m "not gpu_required and not slow"to reliably
skip GPU-only and long-running tests on standard runners.integration.yml: Replaced stalebuild_v2CMake build directory with
build_releasethroughout.publish.yml: Build step now produces both wheel and sdist (python -m build).
Tests (v0.2.2)
- pytest: 94 collected — 84 passed, 10 skipped (optional deps), 0 failed
- Skips: all
test_llama_cpp_python.*skip whenllama-cpp-pythonnot installed - C++ CTest: 67/67 pass on Linux CI (not runnable natively on Windows)
0.2.1 — 2026-07-22 — V2.1: Real Runtime Integration & Validation
Added
Python — Multi-Backend Adapter Layer
adaptq/runtime_py/—IRuntimeAdapterPython ABC + backend registrycreate_adapter(backend)factory for all supported backendsbackend_available(backend)/list_available_backends()discovery helpersIRuntimeAdapter.generate_streaming(): Added metrics tracking (wall time, tokens/sec, token IDs, KV stats) and lifecycle guarantees viageneration_result()
adaptq/runtime_py/backends/transformers_hf.py— HuggingFace Transformers adapter (Priority 1)- Hooks into
DynamicCache.update()to intercept K/V per layer - Supports any CausalLM: Qwen, LLaMA, Mistral, Gemma, GPT-2, …
- CPU and GPU; auto-detects device
- Hooks into
adaptq/runtime_py/backends/llama_cpp_python.py— llama-cpp-python adapter (Priority 1)- Hooks into
Llama.eval()+Llama.sample()token loop - Full generate() pipeline with save/restore llama context state
- KV stats via size estimation (approximate)
- Hooks into
adaptq/runtime_py/backends/ollama.py— Ollama REST adapter (Priority 2)- POST /api/generate with streaming JSON
- No internal KV access; captures timing and token counts
adaptq/runtime_py/backends/vllm.py— vLLM stub (Priority 3, CUDA required)adaptq/runtime_py/backends/mlx.py— MLX stub (Priority 5, Apple Silicon)adaptq/runtime_py/backends/llama_cpp.py— llama.cpp C++ stub (Priority 6, source build)
C++ — IRuntimeAdapter Interface
runtime/adapters/adapter.h—IRuntimeAdapterpure C++ interface (9 virtual methods)runtime/adapters/runtime_metadata.h—ModelConfig,SessionConfig,KVCacheView,RuntimeMetadata,GenerationResult
Examples (6 demos)
examples/transformers_demo.py— full Transformers pipeline demoexamples/llama_demo.py— full llama-cpp-python pipeline + context save/restoreexamples/ollama_demo.py— Ollama REST generation demoexamples/snapshot_demo.py— standalone snapshot pipeline (no model required)examples/branch_replay_demo.py— branch replay at midpointexamples/compare_backends.py— cross-backend comparison table
Benchmarks
benchmarks/bench_all.py— unified benchmark runner (KV memory, latency, snapshot size)- Output formats: JSON, CSV, Markdown
Integration Tests
integration_tests/conftest.py— shared fixtures, markers,--model-hf,--model-ggufCLI argsintegration_tests/test_adapter_contract.py— 25 backend-agnostic contract testsintegration_tests/test_transformers.py— 15 end-to-end transformers testsintegration_tests/test_llama_cpp_python.py— 10 end-to-end llama-cpp-python tests
CI
.github/workflows/integration.yml— 4-job CI: C++ tests, adapter contracts, transformers integration, Python validation
Documentation
docs/v2.1_integration.md— backend integration guide + "how to add a new backend"
Changed
adaptq/__init__.py— exportscreate_adapter(),list_available_backends()pyproject.toml— version0.2.1; optional deps for each backendpyproject.toml—[tool.pytest.ini_options]now coversintegration_tests/CLAUDE.md— V2.1 architecture notes
Fixed (Pre-Release Audit)
- CRITICAL: Fixed
SyntaxErrorinadaptq/__init__.py(duplicate docstring) that prevented the package from being imported. - Fixed
adaptq/__init__.pymissing__version__. - Fixed
adaptq/replay.pystale binary path (build_v2→build_release), duplicate--formatflag, and namespace pollution. - Fixed
adaptq/runtime_py/backends/transformers_hf.pytorch_dtypedeprecation warning (changed todtype). - Expanded
.gitignoreto cover all build directories (build_release,build_debug, etc.). - Made
validate_*.sh,replay.py, andrun_tests.pyfully cross-platform (removed hardcoded WSL paths).
Test Results (V2.1)
- C++: 67/67 tests pass (unchanged)
- Integration contract: 25/25 pass (no model required)
- Transformers integration: 15/15 pass (Qwen2-0.5B, CPU, 167s)
- Backends available:
transformers,llama_cpp_python,ollama
0.2.0 — 2026-07-22 — V2: Replay + Compare
Added
C++ (Core)
runtime/runtime_context.h/cpp—RuntimeContextorchestration class- Full wire-up:
IPolicy → IKVStrategy → IStorageBackend → IKernelBackend - Token log (
log_tokens=true) for FP32 K/V capture used by snapshot replay StrategyFactory/StorageFactorytypedefs; runtime strategy registrystrategy_factory_by_name()andstrategy_names()registry functionsmake_contiguous()public factory forContiguousSlabStorage
- Full wire-up:
replay/session_snapshot.h/cpp—SessionSnapshotversioned binary format- Magic
0x41515353("AQSS"), version 2, little-endian self-describing header - Per-head K/V slab data, scales, format tags capture
- Optional strategy state serialization via
IReplayHooks - Optional token log for deterministic replay
capture(),save(),load()API
- Magic
replay/replay_engine.h/cpp—ReplayEnginereplay()— full deterministic replay from token 0branch(from_token)— warm-up replay then return ready contextreplay_with(strategy_name)— cross-strategy replayReplayReportwith per-tokenComputeMetrics
cli/cmd_replay.cpp—adaptq replay <snapshot.aqss> [options]--strategy har_fixed|fp_passthrough— override strategy--from-token N— branch mode--metrics— collect per-token metrics--output <file>— file output--format json|csv|md|tex— output format
cli/cmd_compare.cpp—adaptq compare <snapshot.aqss> --strategies A,B- JSON/CSV/Markdown/LaTeX output
- Aggregated per-strategy summary: wall time, avg latency, avg quality, avg bits/dim
cli/cmd_create_strategy.cpp—adaptq create-strategy <Name>- Scaffolds full
IKVStrategydirectory understrategies/<name>/
- Scaffolds full
Tests (C++)
tests/unit/test_runtime_context.cpp— 10 tests for RuntimeContexttests/unit/test_session_snapshot.cpp— 8 tests for SessionSnapshottests/unit/test_replay_engine.cpp— 9 tests for ReplayEngine
Python
adaptq/replay.py—ReplayEngine,ReplayResult,CompareResult,snapshot_info- Thin subprocess wrappers around
adaptq replay/compareCLI CompareResult.to_markdown(),best_quality(),fastest()
- Thin subprocess wrappers around
Changed
adaptq/__init__.py— exportsReplayEngine,ReplayResult,CompareResult,snapshot_infopyproject.toml— version0.2.0, Python>=3.8, proper classifiers and extrasREADME.md— full V2 documentation with replay/compare usage, CLI reference, snapshot format, changelog
Fixed
cli/cmd_create_strategy.cpp— missingadaptq::namespace wrapper caused linker errorreplay/session_snapshot.cpp—cache_sizewas set fromcsb->size()(total K+V slots) instead ofcsb->size()/2(K/V pairs)tests/unit/test_session_snapshot.cpp— non-copyableRuntimeContextreturned by value; fixed tounique_ptr; added missing#include <fstream>tests/unit/test_runtime_context.cpp— inlineextern IStorageBackend *make_contiguous()declaration inside lambda didn't resolveadaptq::namespace; fixed toadaptq::make_contiguous()
Test Results
- C++: 67/67 tests pass (V1: 38, V2: 29)
- Python: 5/5 validation stages pass
0.1.0 — Initial Release — V1: Plugin Architecture
Added
- Plugin interfaces:
IKVStrategy,IPolicy,IStorageBackend,IKernelBackend,ICostFunction,IQualityOracle - Strategies:
HARFixedStrategy(4-bit HAR quantization),FPPassthroughStrategy(FP32 passthrough) - Policy:
UniformPolicy - Storage backends:
ContiguousSlabStorage,SegmentedSlabStorage - Quality oracle: default ensemble oracle
- Cost optimizer:
ICostFunction-based budget management - C API:
adaptq_create,adaptq_append,adaptq_compute,adaptq_destroy, MHA context - Python bindings: pybind11
MHAContext→adaptq.Engine - PyTorch adapter:
AdaptQAttentiondrop-in module - 38/38 C++ tests pass
- 5/5 Python validation stages pass