Catalog PyPI
PACKAGE EXPLORERView in registry

adaptive-pipeline

PyPI

An adaptive Pipeline Cache composed of FIFO and upgraded TinyLFU with cost-awareness

adaptivecachecppfifolfulruperformancepipeline
Versions collected1
Direct dependencies1From release 0.1.5
Last observed20 Oct, 19:07 UTC

README

Version 0.1.5 documentation

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)

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.514 Nov 20251

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
nadavkeren/python-adaptive-pipeline-cache

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:07 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:203edd9af3f6c96a21fef592a885914c5329ea337ab3edbb90e34cf03ba04477