feat(sim): profiled replay - #1047
Mrtroll486 wants to merge 9 commits into
Conversation
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
3948054 to
a915220
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a91522033c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let mut duration_us = if decode_reqs > 0 && prefill_tokens == 0 && sum_decode_ctx_tokens == 0 { | ||
| base_us as f64 | ||
| } else { | ||
| decode_request_us * f64::from(decode_reqs) |
There was a problem hiding this comment.
Keep legacy TPOT independent of batch width
When the CLI runs without --profile, build_runtime still attaches this generated profile, so concurrent requests share one decode step. Multiplying the duration by decode_reqs makes each token interval N * tpot_ms for a batch of N requests, whereas the previous legacy scheduler advanced every ready request after the same fixed TPOT. Consequently, existing vllm bench workloads with concurrency greater than one report artificially increasing TPOT and latency; retain the legacy scheduler for this mode or make its decode-step duration batch-invariant.
Useful? React with 👍 / 👎.
| log::warn!( | ||
| "timing profile '{}' does not cover step shape {shape:?}; using parametric fallback outside grid domain {domain:?}", | ||
| self.profile_id | ||
| ); |
There was a problem hiding this comment.
Install a logger before promising fallback warnings
In the pegainfer-sim executable, neither main.rs nor pegainfer-frontend installs a logger for the log facade, so this warning is discarded. Whenever the default WarnAndFallback policy encounters a shape outside the measured grid, the run silently switches to parametric timing and the benchmark operator cannot tell that results are no longer profile-backed; initialize logging or surface this warning through the executable's configured stderr/reporting path.
Useful? React with 👍 / 👎.
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
|
2 review suggestions provided by codex has been fixed, regression test added. |
|
The overall online worker implementation looks reasonable. I ran the existing library/HTTP tests and exercised the unchanged head with The main design question is the JSON contract. Please post a proposal in a comment for discussion before implementing further schema/model changes. We should first establish the minimum useful inputs and how we will obtain their values. Some thoughts for that discussion:
A small proposed JSON example, a purpose for each retained field, and a calibration/validation outline would be enough to start the discussion. We can agree on that before expanding the implementation. Separately, there is one reproduced correctness issue on |
Signed-off-by: Mr_troll863 <restart486666@gmail.com>
|
The correctness issue mentioned above has been fixed. The proposal follows: Prediction ContractThe timing predictor should answer one question: The initial shape is: These values come from the simulated worker scheduler after admission and The returned duration represents target-engine execution time for that When target-engine step telemetry is available, it can provide the shape and Work In This PR vs. PR2This PR will validate the runtime contract and scheduler behavior:
PR2 will perform real timing calibration:
Candidate Timing ModelsThe initial comparison will include: A separate aggregate/mixed correction will only be added if held-out mixed
Illustrative Minimal ProfileThe exact predictor payload remains a tagged implementation choice, but the {
"schema_version": 1,
"calibration": {
"target_engine": "vllm",
"engine_version": "<version>",
"model_id": "<model>",
"model_revision": "<revision>",
"model_config_sha256": "<sha256>",
"gpu": "<gpu>",
"server_config_sha256": "<sha256>",
"source_sha256": "<sha256>"
},
"scheduler": {
"policy": "vllm_v1",
"max_num_seqs": 4,
"max_num_batched_tokens": 2048,
"max_model_len": 32768,
"prefill": {
"mode": "chunked",
"max_chunk_tokens": 512
}
},
"predictor": {
"kind": "regression_v1",
"out_of_domain": "error",
"prefill": {
"knots": [[0, 0], [512, 1800], [2048, 6100]]
},
"decode": {
"intercept_us": 100,
"request_us": 20,
"context_token_us": 0.02
},
"mixed_correction": null
}
}The numeric values above are illustrative only. Full raw benchmark inputs, Field Purpose and Current-PR Ablations
Descriptive metadata changing neither step plans nor durations is expected.
|
Summary
Pr 1/3 of issue #1039
This PR adds a runnable, deterministic offline serving simulator to
pegainfer-simand provides the versioned timing-profile and step-worker foundations needed by it.The offline simulator does not depend on GPUs, model weights, HTTP, or wall-clock time. It replays requests through a single logical event loop and produces identical event ordering and reports for the same scenario, workload, timing profile, and seed.
Background
The existing online
SimScheduleris useful for validating the OpenAI/vLLM frontend, HTTP streaming, and metrics. It is not suitable for fleet-level scheduling experiments because its results include HTTP, Tokio, operating-system scheduling, and real-time waiting overhead, and because a large HTTP run is not a simulation of a large serving fleet.This PR adds an independent logical-clock replay module instead of scaling the online simulator with threads or servers. The online simulator continues to cover protocol and integration behavior; the offline simulator focuses on scheduling, routing, and fleet A/B experiments.
Production Invariant
CompletedorRejected.max_num_seqsormax_batched_tokens.max_model_len.Main Changes
Offline logical-clock simulator
BinaryHeapevent loop.Waiting -> Prefill -> Decode -> Completed/Rejectedlifecycle.max_num_seqs,max_batched_tokens, andmax_model_len.Fleet and routing
Timing and JSON contracts
Adds separate, strict, versioned JSON contracts for:
PR1 provides an extensible tagged timing-model enum with a fixed synthetic model:
Reports include:
Standalone CLI
Adds
pegainfer-sim-replay, which runs without starting the HTTP frontend:The repository includes runnable scenario, workload, and timing-profile examples.
Online simulator foundations and hardening
The preceding commits in this branch also provide:
max_tokensrequests from causing OOM;fallback-token-idin profile mode;These facilities provide the foundation for future benchmark-driven calibration, while the PR1 offline timing model remains explicitly
synthetic.Acceptance Evidence
u32::MAXoutput request is rejected before allocation.Verification
Results:
pegainfer-simunit tests: 20/20 passed;pegainfer-frontendunit tests: 65/65 passed;Non-Goals
This PR does not include:
These capabilities are reserved for follow-up calibration and KV-aware routing work.
Type of Change
Checklist
docs/conventions/coding-style.md).CLAUDE.md).