Skip to main content

sched-sim ⏱️

CI Docs License Python Hardware Calibrated

A high-fidelity, CPU-first discrete-event simulator (DES) for LLM serving schedulers.

In modern inference clusters (vLLM, TGI, TensorRT-LLM, SGLang, DistServe), the scheduling policy is the single largest determinant of cluster throughput, latency, and hardware cost. While continuous batching and Paged KV-caching provide the mechanism for dynamic execution, the scheduler determines:

  1. Which requests enter the next forward iteration.
  2. How large prompt prefills are chunked to prevent decode starvation.
  3. What happens when the physical KV-cache runs out of memory (swapping to CPU DRAM vs eviction and recomputation).
  4. When to disaggregate prefill and decode phases onto specialized GPU worker pools (Splitwise / DistServe architecture).

Testing these policies on real GPU clusters (e.g. 8x H100 nodes) is slow, noisy, and expensive ($20–$50/hr). sched-sim simulates hours of multi-GPU serving traffic in seconds on any standard CPU, using validated analytical performance models calibrated against empirical silicon measurements from servebench and mini-infer.


⚡ Core Architecture

                          ┌────────────────────────────────────────────────────────┐
                          │                   Arrival Process                      │
                          │   (Poisson, Bursty Gamma, LMSYS / ShareGPT Traces)    │
                          └───────────────────────────┬────────────────────────────┘
                                                      │ Request arrives (prompt_len, output_len)
                                                      ▼
                                       ┌─────────────────────────────┐
                                       │       Waiting Queue         │
                                       │  (FCFS, SJF, Priority, SLO) │
                                       └──────────────┬──────────────┘
                                                      │ Iteration Scheduler
                                                      ▼
                       ┌──────────────────────────────────────────────────────────────┐
                       │               Continuous Batching Step (Iteration)           │
                       │  ┌────────────────────────────┐ ┌──────────────────────────┐ │
                       │  │   Prefill Tokens (Chunked) │ │ Decode Tokens (1/req)    │ │
                       │  └────────────────────────────┘ └──────────────────────────┘ │
                       │       ▲                                      ▲               │
                       │       │ Paged KV Allocator                   │ Memory Check  │
                       │       │                                      │               │
                       │       ▼                                      ▼               │
                       │  ┌──────────────────────────┐   ┌──────────────────────────┐ │
                       │  │   Paged KV-Cache Pool    │   │   Preemption Subsystem   │ │
                       │  │ (Physical 16-tok Blocks) │   │ (Recompute vs CPU Swap)  │ │
                       │  └──────────────────────────┘   └──────────────────────────┘ │
                       └──────────────────────────────────────────────────────────────┘

⏱️ Quickstart in 30 Seconds

Install

# Direct from source with uv (fastest)
git clone https://github.com/Prajwal7-2002/sched-sim.git
cd sched-sim
uv sync

# Or with standard pip
pip install -e .

1. Run a Simulation Scenario

Simulate Chunked Prefill serving a long-context RAG workload on an NVIDIA A100 SXM4 (80GB) cluster running Llama-3-8B:

sched-sim run --scheduler chunked --workload rag --hardware a100 --duration 10

Runs 100% on your CPU: You do not need an A100 or any GPU to run sched-sim. It simulates hours of multi-GPU serving traffic in seconds on any standard CPU. The --hardware flag tells the discrete-event engine which cluster architecture to mathematically simulate (a100, h100, t4, rtx3050, or a custom JSON profile).

2. Compare Schedulers Side-by-Side (Identical Trace)

Benchmark all 5 scheduling policies on the exact same Poisson arrival trace:

sched-sim compare --schedulers fcfs,sjf,chunked,slo,disaggregated --workload rag --hardware a100

3. Replay Real-World Conversation Traces

Replay Chatbot Arena conversation traces through the simulator:

sched-sim trace ./traces/lmsys_sample.json --scheduler chunked

4. Sweep Load to Discover Saturation Knees

Discover the exact request rate where each scheduler hits its Goodput cliff:

sched-sim sweep --schedulers fcfs,chunked,slo,disaggregated --workload rag --min-rate 2 --max-rate 18 --step 4

5. Check Silicon Hardware Presets

Inspect calibrated hardware profiles:

sched-sim info

💡 Runnable Python Examples

Explore self-contained runnable scripts under examples/:

python examples/01_radix_prefix_caching.py
python examples/02_simulate_schedulers.py
python examples/03_perfetto_trace_export.py

🔬 The 6 Core Schedulers

Scheduler Architecture & Policy Key Trade-Off
Cache-Aware Radix-Tree prefix caching (SGLang / vLLM APC). Shares physical 16-token KV blocks with LRU eviction and prefix-affinity prioritization. Near-zero TTFT for RAG, multi-turn chat, and shared system prompts.
Chunked Token budgeting (Sarathi-Serve / vLLM). Slices prompt prefills into 512-token chunks. Eliminates TPOT latency spikes and ensures steady iteration times.
SLO-Aware Dynamic deadline scheduling (EDF) with selective dropping of unrecoverable requests. Maximizes Goodput (% of requests meeting both TTFT and TPOT SLOs).
Disaggregated Splitwise / DistServe architecture: separates compute-bound Prefill workers from memory-bound Decode workers. Zero decode interference; models KV-cache interconnect transfer delay.
SJF Shortest-Job-First (shortest prompt first). Minimizes average waiting time and mean TTFT, but starves heavy RAG prompts.
FCFS First-Come First-Served continuous batching with atomic prefills. Simple, but large prompts cause Head-of-Line blocking and decode starvation.

🎨 Interactive Perfetto / Chromium Timeline Visualization

Export native Chromium / Catapult Trace Event JSON files and inspect discrete forward-pass iteration slices and per-request lifecycles in ui.perfetto.dev:

sched-sim run --scheduler cache_aware --workload rag --hardware a100 --trace-out trace.json

Drag and drop trace.json directly into Perfetto to visually analyze:

  • Prefill vs. Decode vs. Mixed Slices: Microsecond-accurate forward pass durations on the GPU accelerator.
  • Request Streams: Exact arrival, TTFT first-token timestamps, and completion times.
  • Counter Tracks: Real-time GPU KV-cache memory utilization (%) and concurrent batch stream counts.

🛠️ Hardware Calibration (Analytical Roofline Model)

sched-sim avoids arbitrary delays. It computes exact step latencies from first-principles roofline mechanics calibrated with empirical silicon data:

  1. Prefill Latency ($T_{\text{prefill}}$): Compute-bound matrix multiplication: $$T_{\text{prefill}} = \max\left(\frac{2 \cdot P \cdot N}{\text{Effective TFLOPS}}, \frac{\text{Weights}}{\text{Bandwidth}}\right) + T_{\text{launch}}$$

  2. Decode Latency ($T_{\text{decode}}$): Memory-bandwidth bound weight and KV-cache gather: $$T_{\text{decode}} = \frac{P \cdot \text{dtype} + L_{\text{total}} \cdot \text{KV_bytes_per_token}}{\text{DRAM Bandwidth (GB/s)}} + T_{\text{launch}}$$

  3. Interconnect Transfer ($T_{\text{transfer}}$): Network serialization delay for PD Disaggregation: $$T_{\text{transfer}} = \frac{L_{\text{prompt}} \cdot \text{KV_bytes_per_token}}{\text{Network Bandwidth}} + T_{\text{net_latency}}$$


🔬 Empirical Silicon Validation (AMD Ryzen 5 6600H + NVIDIA RTX 3050 6GB)

sched-sim is validated against ground-truth benchmarks collected by servebench testing Qwen 2.5 0.5B on both C++/CUDA and Python runtimes on physical silicon:

Target Serving Engine Model Metric Real Hardware (servebench) sched-sim Predicted Variance
Ollama (C++/CUDA runtime) Qwen 2.5 0.5B TTFT 44.33 ms 47.81 ms 7.9%
TPOT 4.96 ms 5.33 ms 7.5%
E2E 627.50 ms 666.73 ms 6.3%
mini-infer (PyTorch eager runtime) Qwen 2.5 0.5B TTFT 121.80 ms 140.60 ms 15.4%
TPOT 103.24 ms 106.67 ms 3.3%
E2E 3322.29 ms 3447.26 ms 3.8%

Run the reproducible validation suite yourself:

uv run python benchmarks/validate_flagships.py

Full methodology and analysis available in benchmarks/RESULTS.md.


📊 Telemetry & Reports

Every run outputs comprehensive telemetry:

  • Latency Percentiles: TTFT (p50, p90, p99 ms), TPOT (p50, p90, p99 ms/tok), End-to-End latency.
  • Goodput Ratio: Exact percentage of requests meeting both TTFT and TPOT Service Level Objectives.
  • Preemptions & Recomputations: Total memory thrashing events and discarded tokens.
  • Visual Gantt Timeline: Live ASCII/Unicode GPU iteration breakdowns.
  • Export: JSON (--output report.json) and Markdown (--output report.md).

🧪 Testing

Run the deterministic test suite:

uv run pytest

🤝 Contributing

Contributions from systems engineers and researchers are welcome! Check out the Contributing Guide for architectural invariants, testing standards, and high-impact areas where we need help (new scheduling policies, modern hardware presets, and interconnect topologies).


📄 License

Apache 2.0. See LICENSE for details.

Metadata

Release files for sched-sim 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sched-sim 0.2.1
File Size Uploaded Provenance
sched_sim-0.2.1.tar.gz 40.7 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sched-sim 0.2.1
File Interpreter ABI Platform
sched_sim-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 89.9 kB

Release files / sched_sim-0.2.1.tar.gz

Download URL sched_sim-0.2.1.tar.gz
Size 40.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fdb9bc07f39fc2624d3fc36db40fb7d17b3b617563b2eba68616b2b73e9d2067
BLAKE2b-256 checksum
How to use checksums
82b94c06033f1afe0c92dc4afb82da30d72fd0271120efe6cd39494fc0d163f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / sched_sim-0.2.1-py3-none-any.whl

Download URL sched_sim-0.2.1-py3-none-any.whl
Size 49.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5199fe16c2e909bfc5a91bec53320c685ef13d5d5c94d5216b7f086267952725
BLAKE2b-256 checksum
How to use checksums
0d9d300ed2b40fa8d9fdaef9b767836cacef06a5d11047260661d3e9aff4d89f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for sched-sim 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sched_sim-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page