Current collected state Current
Observed since 20 Oct, 19:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Continuous batching & thermal-aware scheduling for LLM inference on edge devices (llama.cpp)
A production-ready research framework for low-latency LLM inference on edge devices, featuring iteration-level continuous batching, in-flight request preemption, and power-aware thermal scheduling over llama.cpp.
| Capability | Description |
|---|---|
| Continuous Batching | Token-level iteration loop via the llama.cpp low-level API — new requests are injected between decode steps, not between batches. |
| In-Flight Preemption | Realtime (interactive) requests instantly preempt background tasks without waiting for a batch to finish. |
| Power-Aware Thermal Scheduling | A hardware monitor feeds thermal pressure and battery level into the scheduler, which throttles background work under thermal stress. |
| Real Baseline Suite | Built-in Fixed-Batch, Throughput-First, and Single-Request baselines for empirical evaluation. |
┌─────────────────────────────────────────────────────┐
│ EdgeBatchingService │
│ ┌───────────┐ ┌──────────────────────────────┐ │
│ │ Hardware │──▶│ AdaptiveBatchScheduler │ │
│ │ Monitor │ │ │ │
│ │ (thermal, │ │ ┌─────────┐ ┌──────────┐ │ │
│ │ battery) │ │ │Realtime │ │Background│ │ │
│ │ plugged │ │ │ Queue │ │ Queue │ │ │
│ └───────────┘ │ └────┬────┘ └────┬─────┘ │ │
│ │ │ Preemption│ │ │
│ │ ▼ ▼ │ │
│ │ ┌──────────────────────┐ │ │
│ │ │ Active Batch │ │ │
│ │ │ (token-level step) │ │ │
│ │ └──────────┬───────────┘ │ │
│ └─────────────┼───────────────┘ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ LlamaCppIterationEngine │ │
│ │ (llama_decode per token) │ │
│ └─────────────────────────┘ │
└─────────────────────────────────────────────────────┘
edge_batching/
├── models.py # Data models — GenerationRequest, DeviceProfile, WorkloadType
├── engine.py # Production engine — LlamaCppIterationEngine (100% Real)
├── scheduler.py # Core scheduler — continuous batching + preemption logic
├── service.py # Async service layer — Future-based API + hardware monitor
├── hardware_monitor.py # Cross-platform thermal pressure & battery monitoring
├── policies.py # Real baseline schedulers — Fixed, Throughput-First, Single
├── benchmark.py # Real-time workload generator + policy comparison framework
├── research.py # Empirical experiment runner with CSV/Markdown output
└── simulation.py # Interactive CLI simulation for live validation
download_model.py # Downloads Qwen-0.5B GGUF for local testing
RESULTS.md # Empirical results with raw metrics
pip install llama-cpp-python numpy huggingface-hub
python download_model.py
python -m edge_batching.research --model models/qwen1_5-0_5b-chat-q4_k_m.gguf
This generates:
research_outputs/real_benchmark_results.csv — raw metrics from real inferenceresearch_outputs/real_findings.md — formatted comparison tablespython -m edge_batching.simulation --model models/qwen1_5-0_5b-chat-q4_k_m.gguf
from edge_batching import (
AdaptiveBatchScheduler,
DeviceProfile,
EdgeBatchingService,
GenerationRequest,
LlamaCppIterationEngine,
WorkloadType,
)
# 1. Initialize real engine
engine = LlamaCppIterationEngine(model_path="models/qwen1_5-0_5b-chat-q4_k_m.gguf")
# 2. Define hardware profile
device = DeviceProfile(
name="macbook-m2",
memory_gb=16.0,
compute_score=5.0,
max_batch_size=4,
target_realtime_latency_ms=250.0,
background_weight=0.30,
)
# 3. Setup scheduler and service
scheduler = AdaptiveBatchScheduler(device=device, engine=engine)
service = EdgeBatchingService(scheduler)
service.start()
# 4. Submit a realtime request
future = service.submit(
GenerationRequest(
request_id="chat-1",
prompt="What is the capital of France?",
prompt_tokens=8,
max_new_tokens=32,
workload=WorkloadType.REALTIME,
)
)
result = future.result(timeout=10.0)
print(result.output_text)
service.stop()
Apache 2.0 — see LICENSE.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.1.0 | 4 May 2026 | 5 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 19:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d3a1ef2fefdb37e4f052a61de02a280e04a98bd5f18594f3c8bd29b53159b9f5