Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

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

🔬 The 5 Core Schedulers

Scheduler Architecture & Policy Key Trade-Off
FCFS First-Come First-Served continuous batching with atomic prefills. Simple, but large prompts cause Head-of-Line blocking and decode starvation.
SJF Shortest-Job-First (shortest prompt first). Minimizes average waiting time and mean TTFT, but starves heavy RAG 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.

🛠️ 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

📄 License

Apache 2.0. See LICENSE for details.

Metadata

Release files for sched-sim 0.1.0

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

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Built distribution (wheel)

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

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

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL sched_sim-0.1.0-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57abc2b67e94f40075496e0d8e9250ad2d2f4ade9288b6cdddad3540f4df52a2
BLAKE2b-256 checksum
How to use checksums
a4a742a70e585ea8935936d3e43b127eec7ff57862dd465e5d7e07c93e28331d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sched-sim 0.1.0

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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.2.1 2 files With provenance
  • Added 0.1.0 1 file Without provenance

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.

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