An adaptive Pipeline Cache composed of FIFO and upgraded TinyLFU with cost-awareness
Project description
Adaptive Pipeline Cache
A high-performance adaptive caching system implemented in C++ with Python bindings. The cache dynamically adjusts its internal structure based on workload characteristics, combining FIFO, Approximate LRU (ALRU), and Cost-Aware LFU strategies.
Features
- Adaptive Architecture: Automatically adjusts cache structure based on workload patterns
- Multiple Eviction Policies: Combines FIFO, ALRU, and Cost-Aware LFU in a pipeline
- High Performance: Implemented in C++20 with efficient memory management
- Python Integration: Clean Python API via pybind11
- Cost-Aware: Takes into account both latency and token costs for eviction decisions
Installation
pip install adaptive-pipeline
Building from Source
Requirements:
- C++20 compatible compiler
- CMake >= 3.15
- Python >= 3.7
- pybind11 >= 2.6.0
git clone <repository-url>
cd pipeline-cache
pip install -e .
Usage
Notice that for this version, the size of the cache is hard-coded to be 1024, and it ignores the size parameter.
from adaptive_pipeline import AdaptivePipelineCache
# Create a cache with capacity of 1024 items
cache = AdaptivePipelineCache(1024)
# Store items with (latency, tokens) tuple
cache[key] = (latency, tokens)
# Check if key exists
if key in cache:
latency, tokens = cache[key]
# Get cache statistics
print(f"Current size: {cache.currsize}")
print(f"Max size: {cache.maxsize}")
How It Works
The Adaptive Pipeline Cache uses a novel approach that:
- Pipeline Structure: Divides the cache into three blocks (FIFO, ALRU, Cost-Aware LFU)
- Dynamic Adaptation: Periodically evaluates alternative configurations using "ghost caches"
- Quantum-Based Resizing: Moves chunks of items between blocks based on performance metrics
- Cost-Aware Eviction: Considers both access frequency and cost (latency × tokens) for eviction decisions
The cache automatically adapts its configuration every 10,240 operations (configurable) by comparing the performance of the current configuration against alternative configurations simulated by ghost caches.
Interface Compatibility
The implementation follows the interface of cacheutils for compatibility with GPT-Cache experiments.
License
MIT License - see LICENSE file for details
Author
Nadav Keren (nadavker@pm.me)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adaptive_pipeline-0.1.0.tar.gz.
File metadata
- Download URL: adaptive_pipeline-0.1.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c080f6ecce95de6b4bc91463b95d100eb047810f94d3a485e5c9ed27960db573
|
|
| MD5 |
eb1b9b262efbccd6b275c7e4c7ee1703
|
|
| BLAKE2b-256 |
07bc299b75224d55f4d39048bd7b25037f38c23aecf66eb29d4c54bce45cfb02
|
File details
Details for the file adaptive_pipeline-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 106.8 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8a24bff2f10a246715ce3fa3af067d63276ba27e3fdb9b9ce184d0007f88d56
|
|
| MD5 |
c9d4d16938482033431bbcd56f043cdf
|
|
| BLAKE2b-256 |
895e3177b21714d054af390a18d3682835181155a34633aa86c87c4aecedf864
|
File details
Details for the file adaptive_pipeline-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 298.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9495682d863a77e624ce7db3a7d28c5925e957738f08df1757b2ed5230c869d3
|
|
| MD5 |
a914eeab78ab90f84b610ae5d34c62fc
|
|
| BLAKE2b-256 |
8da77bab6a16fe67bdb92e1f5d8dc66b442f8e8a7e9de857633eabdaba6b012b
|
File details
Details for the file adaptive_pipeline-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 210.9 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b025a0663a8a79945aa921971cefb55618aa875331bb8354d5621a5fe20288a9
|
|
| MD5 |
8be726773bd01026f0b32d94e0ac20e2
|
|
| BLAKE2b-256 |
534a5a6bd554b31b77c07f6abe0850fe2a35f371fc20a712f42c08b3d6febb4e
|
File details
Details for the file adaptive_pipeline-0.1.0-cp313-cp313-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp313-cp313-macosx_10_15_x86_64.whl
- Upload date:
- Size: 201.4 kB
- Tags: CPython 3.13, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1ce51bab4f4871cf10ac62241020846bbbe159a9593c1459c82c8e475b50436
|
|
| MD5 |
c17e7b104cb615b8182a37dd3ea39606
|
|
| BLAKE2b-256 |
f81dd413b1e6cab5be1179347e938ce680c283b218f54cc18fbfb82e0eca12b7
|
File details
Details for the file adaptive_pipeline-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 106.8 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2aad52a649f5f8a1d2a351124911f91f5c7fd2d4f962c04cfa83ff70d2e83b2
|
|
| MD5 |
b80b334c929558da810bce1ce44cff0b
|
|
| BLAKE2b-256 |
565005f68417c172daccac3f999a03b93a26e18b5e06a0844a03d983bad2a97f
|
File details
Details for the file adaptive_pipeline-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 298.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efe4951a2b1c43fc9d6029c35f864cfba66dc46319b7c65b428ecd1f70a88670
|
|
| MD5 |
c4e74828390e9e7f98e946bd7e547ad0
|
|
| BLAKE2b-256 |
73d33076dc09fd87fed348cee4ed3be4365b9fe952359589bc1343008895ca5c
|
File details
Details for the file adaptive_pipeline-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 210.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
468f2b9b4c02e8caf0562db771e5ddac143a77b671af92b936f189094696b030
|
|
| MD5 |
dbb8c2db219cb9964da1d812e1f5a232
|
|
| BLAKE2b-256 |
f643c357a39f2eb97d033877fb6763999cdaf8c316f7b5db456773f11500d094
|
File details
Details for the file adaptive_pipeline-0.1.0-cp312-cp312-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp312-cp312-macosx_10_15_x86_64.whl
- Upload date:
- Size: 201.2 kB
- Tags: CPython 3.12, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0c2f5a856e445609c6dc9eb214c914c5f5b18a46d1e9b5592378f341c52f61f
|
|
| MD5 |
3c85a4d9c2182533e23146df6659b959
|
|
| BLAKE2b-256 |
5a25d6335993ebf3301ec5a88f95c0f9fbc87782fb7fd257f40ade2ed77a4258
|
File details
Details for the file adaptive_pipeline-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 105.7 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89d04288eade4d30ef81d6c6a1cf8de0b59e1e2e24a575e675fb63b51f22b2c5
|
|
| MD5 |
e618064f19fd990b71be91ba3b9f220f
|
|
| BLAKE2b-256 |
9b8b1dc380ae3e7a58aad28a8bb7589edf0269c19f8a229ce783f3034a1af903
|
File details
Details for the file adaptive_pipeline-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 297.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f52d687c021d0dca38a39f03eb36ff033dbce522ebaf1c48cb5ea046233ad799
|
|
| MD5 |
907a64ae300f2b8705e876635ec1c6ff
|
|
| BLAKE2b-256 |
468d468c5032de44cac5b431b66cca1f1e6dee64f5f8153dc5b2d75b624f6f10
|
File details
Details for the file adaptive_pipeline-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 209.9 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96cb74a51ddd5f651b39594cf595d2366f72014520bafe3ac49bfe2824c6301b
|
|
| MD5 |
ae3f83c70a4106c3744e309ee2af0ed0
|
|
| BLAKE2b-256 |
130f14644a4e34fb6faa8ffe181005dae483c0ce16b7efbe5ae7e5ea2ccda251
|
File details
Details for the file adaptive_pipeline-0.1.0-cp311-cp311-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp311-cp311-macosx_10_15_x86_64.whl
- Upload date:
- Size: 200.1 kB
- Tags: CPython 3.11, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
186b5a62ddcba4983844748f45e42fbb761384e1296f0adee66a9990ad46252c
|
|
| MD5 |
28083a92db57006b7b9c7157097117c6
|
|
| BLAKE2b-256 |
fd89712eb2a38220f8dc0d3457e73916cda6586625a7eeb5bf88f15a68876217
|
File details
Details for the file adaptive_pipeline-0.1.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 104.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cba02212c3ec9a59aaa424dbbbcd4d385ad1927aecd1a4764e34e0543c9659c4
|
|
| MD5 |
d5263e3d714577649616f6d9ae85374a
|
|
| BLAKE2b-256 |
49c3077914e937c31b95a792807c3600c9f101ca4ab04973fba18beb6d7dbcf4
|
File details
Details for the file adaptive_pipeline-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 296.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3d5ca0c067be9896ee65ef1dab35fdec70f42669c08b42f8e0eaac473b68c71
|
|
| MD5 |
f737ec65f04fad545526ec0dc9bf342b
|
|
| BLAKE2b-256 |
5e189186fd3377fe10b2856acbd06e40064dec631076618486ae98b398300c29
|
File details
Details for the file adaptive_pipeline-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 208.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c330aa715571be5edc6ecdcc1c104ef0b17f2e82f0871e693caa0a523c92324
|
|
| MD5 |
ba0b3d2ffc271f8721b7ccfb2991e398
|
|
| BLAKE2b-256 |
b8f07df15a786eb02d4157816cb99aa918fa5a9aff06ca0021f2da948bda34f5
|
File details
Details for the file adaptive_pipeline-0.1.0-cp310-cp310-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp310-cp310-macosx_10_15_x86_64.whl
- Upload date:
- Size: 199.2 kB
- Tags: CPython 3.10, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af354f130faded3bda97319d05b9770719803aa0d8cf6f88a9d432c10ed25ebc
|
|
| MD5 |
f267cedaa2ed1328d08055001b6620b1
|
|
| BLAKE2b-256 |
a5f10211e8792b45a9213b68faf76cb9c0560449e6b3f9c22775f7ba4d4c258d
|
File details
Details for the file adaptive_pipeline-0.1.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 106.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d041881d39ca5d55e4107b33ca8179ecff24a8500f82ddbc49a41835f6246f84
|
|
| MD5 |
462e51222ae1cdebc9b4a043913ab15a
|
|
| BLAKE2b-256 |
131d583115b6362b7a611fba1fb88ecd15d07dacce5984e50abb6cb74aedfd5d
|
File details
Details for the file adaptive_pipeline-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 296.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c24db662baf55c847e9e538d3cc11b9283fa0653296fe8b23804ad879ea95965
|
|
| MD5 |
ba851e752fa028618102b28f87b3acec
|
|
| BLAKE2b-256 |
782945c8dc070b21c20067920d4b8d2916ac4946887393ced74ba7747ff56c65
|
File details
Details for the file adaptive_pipeline-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 209.0 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31cf0283ad7ba938e70a29fe355cade8c2683911be290eb2364c87a05484bc29
|
|
| MD5 |
2cc393d1b0908125e1b73c1d83dc4083
|
|
| BLAKE2b-256 |
6a7410d3b1e604197ccca9388ff46710acf17f3298a9d2a37334c8aca3bf7f66
|
File details
Details for the file adaptive_pipeline-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl
- Upload date:
- Size: 199.4 kB
- Tags: CPython 3.9, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f81c406d6fd427c3145874cdd3f0659e3fc471332f1a28de88ec447606f51cc
|
|
| MD5 |
c34cc92398e33fac93384a073b7159d6
|
|
| BLAKE2b-256 |
e673f76621879bb926c69e6b64f34f3620f5c468d4065a861268a38c786548eb
|
File details
Details for the file adaptive_pipeline-0.1.0-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 104.8 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b74e3097c0eef44ee4e9081d0d7ffd5bfdce2c5660a876996fcea6a574387c4
|
|
| MD5 |
ddcd5e8fe55c6b66c4e2c069067a96a7
|
|
| BLAKE2b-256 |
6cc41ffcb631540818daacf84474efddab51d251874b6b5f0f8fcafffeee3617
|
File details
Details for the file adaptive_pipeline-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 296.4 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f07b2ac3dd2dccfd52a8035122fd93e7155f4e5c33f6d3fec0b21c2b79ce79f
|
|
| MD5 |
fe18e67dae0d4177260aac2e1c25d2a3
|
|
| BLAKE2b-256 |
a0409dd79e4b7af04d4bedb86be8e9a46ad35f3955d8a32282addf19e27f3081
|
File details
Details for the file adaptive_pipeline-0.1.0-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 208.9 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d82d6be12a9d85e99434c3017b50e579be4d2d5cf23f5ed3ead1243de55105
|
|
| MD5 |
3260d5b45ed5cc5d621e7500f53f14b3
|
|
| BLAKE2b-256 |
79ff26623e3de6e0859e9b5c83e1ecee856b67bf40fd342da1f2e4e0c1feec93
|
File details
Details for the file adaptive_pipeline-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl.
File metadata
- Download URL: adaptive_pipeline-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 199.3 kB
- Tags: CPython 3.8, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccd31447587dfe06b4e8a427f0234665186e9b6945ce4137a13e8a2428f57312
|
|
| MD5 |
5853b7e998038109fdb83560eec84065
|
|
| BLAKE2b-256 |
acb67a17d764b435d1e54c8c100399a5fac3b5c0baae8231a68029883779c728
|