Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference
Official implementation of "Cascading Speculative Acceleration: Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference" by Marco Durán Cabobianco and the Distributed Systems Research Team at Anachroni s.coop.
This repository contains a 3-stage speculative decoding system optimized for Google Cloud TPU v5e Pods that achieves 4.2× speedup over baseline autoregressive decoding and 1.8× over standard speculative decoding.
jax.pmap with HBM-aware scheduling| Method | Throughput (tok/s) | Latency (ms/tok) | Speedup |
|---|---|---|---|
| Autoregressive | 35.2 | 28.4 | 1.00× |
| Standard Speculative | 66.8 | 14.9 | 1.90× |
| EAGLE | 94.7 | 10.6 | 2.69× |
| Cascade (Ours) | 147.2 | 6.8 | 4.18× |
# Clone the repository
git clone https://github.com/anacronic-io/speculative-cascade.git
cd speculative-cascade
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
For TPU access, you'll need Google Cloud credentials with TPU v5e access.
from speculative_cascade import CascadeInference
from speculative_cascade.models import TinyModel, DraftModel, TargetModel
# Initialize models
tiny_model = TinyModel.from_pretrained("anachroni/gemma-tiny-10m")
draft_model = DraftModel.from_pretrained("google/gemma-2b", quantize_int8=True)
target_model = TargetModel.from_pretrained("google/gemma-7b")
# Create cascade
cascade = CascadeInference(
tiny_model=tiny_model,
draft_model=draft_model,
target_model=target_model,
speculation_horizon=8
)
# Run inference
prompt = "The future of AI is"
outputs = cascade.generate(prompt, max_tokens=100)
print(outputs)
Context → [Stage 0: Tiny (VMEM)] → K₀ candidates
↓ ↓
→ [Stage 1: Draft (HBM)] → K₁ filtered
↓ ↓
→ [Stage 2: Target (HBM)] → Verified tokens
# Run full benchmark suite
python -m speculative_cascade.benchmarks.run_benchmarks \
--dataset pg19 \
--hardware tpu-v5e \
--output results/
# Compare against baselines
python -m speculative_cascade.benchmarks.compare_methods \
--methods cascade,standard,medusa,eagle \
--sequences 1000
@article{duran2025cascading,
title={Cascading Speculative Acceleration: Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference},
author={Durán Cabobianco, Marco and Distributed Systems Research Team},
journal={arXiv preprint},
year={2025},
organization={Anachroni s.coop}
}
MIT License - see LICENSE file for details.
Python
100.0%
Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference
Official implementation of "Cascading Speculative Acceleration: Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference" by Marco Durán Cabobianco and the Distributed Systems Research Team at Anachroni s.coop.
This repository contains a 3-stage speculative decoding system optimized for Google Cloud TPU v5e Pods that achieves 4.2× speedup over baseline autoregressive decoding and 1.8× over standard speculative decoding.
jax.pmap with HBM-aware scheduling| Method | Throughput (tok/s) | Latency (ms/tok) | Speedup |
|---|---|---|---|
| Autoregressive | 35.2 | 28.4 | 1.00× |
| Standard Speculative | 66.8 | 14.9 | 1.90× |
| EAGLE | 94.7 | 10.6 | 2.69× |
| Cascade (Ours) | 147.2 | 6.8 | 4.18× |
# Clone the repository
git clone https://github.com/anacronic-io/speculative-cascade.git
cd speculative-cascade
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
For TPU access, you'll need Google Cloud credentials with TPU v5e access.
from speculative_cascade import CascadeInference
from speculative_cascade.models import TinyModel, DraftModel, TargetModel
# Initialize models
tiny_model = TinyModel.from_pretrained("anachroni/gemma-tiny-10m")
draft_model = DraftModel.from_pretrained("google/gemma-2b", quantize_int8=True)
target_model = TargetModel.from_pretrained("google/gemma-7b")
# Create cascade
cascade = CascadeInference(
tiny_model=tiny_model,
draft_model=draft_model,
target_model=target_model,
speculation_horizon=8
)
# Run inference
prompt = "The future of AI is"
outputs = cascade.generate(prompt, max_tokens=100)
print(outputs)
Context → [Stage 0: Tiny (VMEM)] → K₀ candidates
↓ ↓
→ [Stage 1: Draft (HBM)] → K₁ filtered
↓ ↓
→ [Stage 2: Target (HBM)] → Verified tokens
# Run full benchmark suite
python -m speculative_cascade.benchmarks.run_benchmarks \
--dataset pg19 \
--hardware tpu-v5e \
--output results/
# Compare against baselines
python -m speculative_cascade.benchmarks.compare_methods \
--methods cascade,standard,medusa,eagle \
--sequences 1000
@article{duran2025cascading,
title={Cascading Speculative Acceleration: Breaking the Memory Hierarchy Bottleneck in Multi-Model LLM Inference},
author={Durán Cabobianco, Marco and Distributed Systems Research Team},
journal={arXiv preprint},
year={2025},
organization={Anachroni s.coop}
}
MIT License - see LICENSE file for details.
Python
100.0%