Back to Prompt Library
implementation
Build the application
Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.
Linked challenge: Build a Continuous Batching Prompt Interruption and Rescheduling Replayer
Format
Code-aware
Lines
82
Sections
11
Linked challenge
Build a Continuous Batching Prompt Interruption and Rescheduling Replayer
Prompt source
Original prompt text with formatting preserved for inspection.
82 lines
11 sections
No variables
1 code block
## Build
Simulate client request preemption in open-weight continuous batching runtimes like vLLM. Hosted Claude analyzes prompt arrival bursts and calculates optimal rescheduling queues.
## User
AI Serving Systems Engineer
## Workflow
1. Simulate bursty incoming prompt arrival streams and sudden inference worker preemption signals.
2. Evaluate interrupted continuous batching states to measure evicted prompt prefixes and chunked prefills.
3. Send normalized batch execution metrics to hosted Claude to optimize queue re-insertion priorities.
4. Render a simulated scheduling queue highlighting predicted completion latency and service-level violations.
## Interface
Terminal dashboard showing active continuous batch slots, queue re-prioritizations, and latency gauges.
## Data
Generate synthetic JSON request logs containing arrival timestamps, prompt token counts, and simulated preemption events.
Starter examples below are synthetic. They are not downloaded records.
## Source
[vLLM open-model serving](https://raw.githubusercontent.com/vllm-project/vllm/main/README.md)
Adopts continuous batching, chunked prefill, and prefix caching principles from vLLM runtime documentation.
## Tools
dspy, anthropic, pydantic, pandas.
DSPy compiles robust prompt optimization pipelines for structured continuous batch queue scheduling decisions.
Hosted Claude API for prompt scheduling optimization and reasoning over request priorities.
## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.
## Acceptance
- Computes prefix caching token reuse for re-queued prompts without loss.
- Generates rescheduling order that prioritizes near-completion batches within simulated SLA boundaries.
- Detects request starvation for low-priority long-context jobs after three consecutive preemption cycles.
## Starter Examples
```json
[
{
"input": {
"batch_capacity": 4,
"interrupted_requests": [
{
"req_id": "req-101",
"tokens_processed": 512,
"tokens_remaining": 16,
"sla_budget_ms": 150
},
{
"req_id": "req-102",
"tokens_processed": 64,
"tokens_remaining": 400,
"sla_budget_ms": 1200
}
]
},
"expected_output": {
"rescheduled_queue": [
"req-101",
"req-102"
],
"prefix_cache_savings_tokens": 576,
"sla_violation_projected": false
}
},
{
"input": {
"batch_capacity": 1,
"interrupted_requests": [
{
"req_id": "req-201",
"tokens_processed": 4096,
"tokens_remaining": 2048,
"sla_budget_ms": 100
}
]
},
"expected_output": {
"rescheduled_queue": [
"req-201"
],
"prefix_cache_savings_tokens": 4096,
"sla_violation_projected": true
}
}
]
```
## Safety
Simulation harness only. Operates purely on synthetic workload records without modifying production serving instances.
Use mock external writes. Require human review before any real deployment.Adaptation plan
Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.
Keep stable
Hold the task contract and output shape stable so generated implementations remain comparable.
Tune next
Update libraries, interfaces, and environment assumptions to match the stack you actually run.
Verify after
Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.