Skip to main content

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:

  1. Pipeline Structure: Divides the cache into three blocks (FIFO, ALRU, Cost-Aware LFU)
  2. Dynamic Adaptation: Periodically evaluates alternative configurations using "ghost caches"
  3. Quantum-Based Resizing: Moves chunks of items between blocks based on performance metrics
  4. 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

adaptive_pipeline-0.1.4.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

adaptive_pipeline-0.1.4-cp313-cp313-win_amd64.whl (107.2 kB view details)

Uploaded CPython 3.13Windows x86-64

adaptive_pipeline-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (305.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (215.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp313-cp313-macosx_10_15_x86_64.whl (205.9 kB view details)

Uploaded CPython 3.13macOS 10.15+ x86-64

adaptive_pipeline-0.1.4-cp312-cp312-win_amd64.whl (107.3 kB view details)

Uploaded CPython 3.12Windows x86-64

adaptive_pipeline-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (305.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (215.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp312-cp312-macosx_10_15_x86_64.whl (205.8 kB view details)

Uploaded CPython 3.12macOS 10.15+ x86-64

adaptive_pipeline-0.1.4-cp311-cp311-win_amd64.whl (106.2 kB view details)

Uploaded CPython 3.11Windows x86-64

adaptive_pipeline-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (303.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (214.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp311-cp311-macosx_10_15_x86_64.whl (204.8 kB view details)

Uploaded CPython 3.11macOS 10.15+ x86-64

adaptive_pipeline-0.1.4-cp310-cp310-win_amd64.whl (105.3 kB view details)

Uploaded CPython 3.10Windows x86-64

adaptive_pipeline-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (302.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (213.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp310-cp310-macosx_10_15_x86_64.whl (204.0 kB view details)

Uploaded CPython 3.10macOS 10.15+ x86-64

adaptive_pipeline-0.1.4-cp39-cp39-win_amd64.whl (107.3 kB view details)

Uploaded CPython 3.9Windows x86-64

adaptive_pipeline-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (303.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp39-cp39-macosx_11_0_arm64.whl (213.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp39-cp39-macosx_10_15_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

adaptive_pipeline-0.1.4-cp38-cp38-win_amd64.whl (105.3 kB view details)

Uploaded CPython 3.8Windows x86-64

adaptive_pipeline-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (302.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

adaptive_pipeline-0.1.4-cp38-cp38-macosx_11_0_arm64.whl (213.4 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

adaptive_pipeline-0.1.4-cp38-cp38-macosx_10_15_x86_64.whl (204.1 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

File details

Details for the file adaptive_pipeline-0.1.4.tar.gz.

File metadata

  • Download URL: adaptive_pipeline-0.1.4.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

Hashes for adaptive_pipeline-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8875599d0ca5651f3ac1f38b53516ff73c1b36337d0523fcc9f160ef200b0bae
MD5 e8acc97be4e135f1a16eeeab2664394c
BLAKE2b-256 8fbf8ef8ffcb20a7296036a39172b430940c6f1f4e1c6629a02f119eea2ea00f

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 026188222f1a4072eb9f4fbf93efd28637bb506c1cc64ba5c7408dc5ddcb332f
MD5 a8714aca056b1e886ff59285f0850ac6
BLAKE2b-256 4821e18bd23e49fa4fb757d40b224f41b74f9c981494d5578b7647d3ea509ef0

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 001189beb3d8148b38d99c5c84734a6f8a84e1456b35ceeeaa1e66d870a1721a
MD5 3ec7718ecb31593577107e86f4ee6f9d
BLAKE2b-256 0ad6757f9722117a2ed8a76abd0ee7cec7c5a40a452175fa1f967b5c8a01bd02

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6fa1ca5f5c06e1a7d3cc6563a8478c6e35e6586f088849ecd4907b1328ffc60
MD5 41d3f3af69b3ce01dccb41ff6c8dc5d1
BLAKE2b-256 06aab6217e8e6d8958bcaf4c0133065b62a42d55a627cfcd36863da3c71193c4

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp313-cp313-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b6ca4b10b95cd8cb2476b03b4a7d3b4c4c4576ec573a5db607f49f09dba5d910
MD5 c1a4670d630412744312ce4c869c634f
BLAKE2b-256 fbf8c6425008341f3f597bf3140305246b4ddd85715fa2dee11f5c9ac5a32fc5

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 33fd7f29372234af4b5c4b9e00a313c6ceac17a8e3ec61c478cba018c7e94f7d
MD5 fb7519ad993e6f62029b4b83d9c5cdc2
BLAKE2b-256 e186e8d5103604b73189616961a913641b6d568f4c30bbd37204e7a29f679afd

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09357e4cb09f5f36234051c245e22acd76befb4ec09ed53c3e7d5123d69ff3ad
MD5 f20ea74879cf8de1347ede8e3fbff998
BLAKE2b-256 8a73e2255935d6e8c3b17b202f64a2b311f9f04505be92d38d17edd2efb306b9

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d1ad970e08b9e82ee71e1a73d79c99c6c2c9e7d1700f27347124903190a5805
MD5 c69df8b4646fd5a84c556ac4d9d909a0
BLAKE2b-256 16218bfb6c35234003ba665509c1f03224e3421b427aa8ee782c8779ecb22104

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 453735ca10be1e2fc40a56467e6892c5952dca9a3183471d5294974b18da4a99
MD5 142402589d3865dcadd5ff94dab4575a
BLAKE2b-256 8ac8881a0311a6364c26f1b635706ef29ce7c5b891b9aaaceef85341aa353273

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 96e83effe7ac1b07a08ce5b2bf15229343492fb191a406cf839c33fd64306f18
MD5 9f19d8021175595ef01e2f40ac90a80e
BLAKE2b-256 1efac49f1542b180176c84f70e6abd4e2838b02577c4c1d2a46549a31cc30cc5

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 94d38dd6c4e1f78f295c513a5d8e421b09499c1abcb76a531b8fd617e20f4871
MD5 0739c71506fac336a9df5a6d0f033345
BLAKE2b-256 4632fbb40f8ff51db4e0c842b5c936fc9e33eed63b3cb01daa0fd140964ccd9d

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 56d53eeda6f5a8de2302af5ad24729090faa733099919bc95898510e1d3ec005
MD5 d2201b594f3c0a8302e1fb0a3f7f08e2
BLAKE2b-256 950bfe7c7ba677cb08d26ab70be27ef94ede30e7496bc00a1c5cb4debba93d9d

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 244b463d68c3e4dc7b577088464f55865e7161972626e4783ee095ca9e979152
MD5 c77d1b6d531c36e3052fcdc4cecdf7bb
BLAKE2b-256 6fe48ba080419f08e9036f8bac471521e969d2adc63cd6cd37c0de18108c9c4c

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c153faacd89f25914a107c1a0fad883d09480921d7d26caa074b01160d37478d
MD5 92a5ec670eb56af3bc082c5d65a51c25
BLAKE2b-256 e4bf4d5a70d1090d431867a7a3e69eb03c222db7d1db8ea28a4fda15040ba004

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0c6b918c3db7e430a79752271f43f1112e6f6f8e21742642be1f6d6e5c38e7af
MD5 5298e3382415f0ea4aee3d4a9277f88c
BLAKE2b-256 d8b7a8a2c719a5f7fd4b5d123bcde17e1ccc872cbb507b896456a1d84e8bc78e

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 813ea620bd327f24910038ad6be3b2efac62b169a77fa818705117f5175712e0
MD5 c3f037d0fd3f89178aeccbb3b2b2051d
BLAKE2b-256 070ce5327dfe4e85885da83fca87819e903e14779bea540478a2132041f27236

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b511ee9a75a69310bf2e3bc3af608e6cda4f67cf10792e74c76b96e9837f2827
MD5 e354b595289dba9158b8fd98724d527d
BLAKE2b-256 67af36da279b55717b4ef8dc41abba2f70923ee3f8d2fac4512f54ecc41a7dbb

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5a7babf6dc995bb51418114f083c237f9f1f5092fca2bdb907759369624c6d5a
MD5 3ea20b241292a03809ef7378d3d2f992
BLAKE2b-256 86346aaaa4e487bb0b060eadd3d5c8c6d6e5665e04b5f2168b443a6d11568ed1

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c3baa2680ef211ccf077c9cb0448de8e83c929e422235d8f2e3d804f17eecd52
MD5 5ce62004794c6c1dfe8b10443cc7bcc3
BLAKE2b-256 827a88d801803b953007c72fe0da20ee01cef7e6dfa4570a46d253aa5e737231

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6a8868a323370dc380d358b97c2da9f3fd7b03ce6e8ef0aad173eb3c3a375c5
MD5 afe7886db6db428e96a791f1303d8803
BLAKE2b-256 8d281ff0d95d210487c911f0fcea5e6b48d404aa20956aefa8e40c64352e4035

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e62f1416abcb85f655137818962eb25834ced15290589e1ae2216b921383f5f7
MD5 54e178844fbfbc20b54169cc012d1e9b
BLAKE2b-256 8523fbd97e9c8177dca85660c3d1604ae1558a60d63e596273e9f40ec54586c6

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2e3b1c8900fc7a37169a846e50234a9c64ebd02146b8e9c0f0fe826ba63bff66
MD5 d3f3057ef56963dfc7b047650ff0da7d
BLAKE2b-256 2c93aca3085ad925d77036a8e58cb4c3466fcdeeedee729aa99dae7078f58cb7

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32a963adcf7a0972691a7597d9e7bf39ebf6a4f9e6052792001c33002acd0ceb
MD5 1d0c4e6ffa9793ed23f6aa98f005bf9e
BLAKE2b-256 4a8c7afe7ac89608b2e2dbab2565e76e9072be1163c9a1f7da2b443619155b8a

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b95eabc68ddef13ec9fb77ec7f734645cbe5f563437d47daa22cf59ac3b4e2ae
MD5 25cc72cdd08efd6e612f6c90db621930
BLAKE2b-256 dcc198f6285c933d4c547fa4e992afa407af4975a61240e681509815e7ef5b34

See more details on using hashes here.

File details

Details for the file adaptive_pipeline-0.1.4-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for adaptive_pipeline-0.1.4-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 02d442a855318f55c70b95fead868bf62ca8787e245acadc7effb269889244bc
MD5 dea20db5442847589583ddb8b45c66ae
BLAKE2b-256 1a8acbfd7b4a9845a93d2c898366877ceb0505ff33303e59bbb210772a2059ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page