sa-bench: update sa bench serving to upstream InferenceMAX code#138
sa-bench: update sa bench serving to upstream InferenceMAX code#138cquil11 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughConsolidates warmup handling by removing the separate pre-run warmup invocation in the shell script and adding a built-in warmup phase to the main benchmarking tool via a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/srtctl/benchmarks/scripts/sa-bench/benchmark_serving.py (2)
109-118:⚠️ Potential issue | 🟡 MinorGuard against negative input lengths when applying chat templates.
If
input_lenis smaller than the chat template overhead, this will yield negative lengths and crashnp.random.randint.🛡️ Suggested guard
tokenized_chat_template_dummy = tokenizer.encode(chat_template_dummy, add_special_tokens=False) chat_template_len = len(tokenized_chat_template_dummy) - 1 - input_len = input_len - chat_template_len + if input_len <= chat_template_len: + raise ValueError("random_input_len must exceed chat template length.") + input_len = input_len - chat_template_len
626-684:⚠️ Potential issue | 🟡 MinorValidate
request_rateat startup to prevent divide-by-zero.
request_rate == 0causes a ZeroDivisionError when calculatingtheta = 1.0 / (request_rate * burstiness)inget_request(). The code already safely handlesmax_concurrency == 0via truthiness checks, so validation is only needed forrequest_rate.✅ Suggested validation
def main(args: argparse.Namespace): print(args) random.seed(args.seed) np.random.seed(args.seed) + if args.request_rate != float("inf") and args.request_rate <= 0: + raise ValueError("--request-rate must be positive or 'inf'.")
🧹 Nitpick comments (2)
src/srtctl/benchmarks/scripts/sa-bench/benchmark_serving.py (2)
98-160: Fix request tuple typing and add missing type hints to keeptyhappy.
sample_random_requestsnow returns a 4‑tuple (extraNone), but the return type and downstream annotations still imply a 3‑tuple. Also,sample_uniformlacks type hints. This will likely failty/Ruff typing and makes the API inconsistent.✅ Suggested typing update
-def sample_random_requests( +def sample_random_requests( prefix_len: int, input_len: int, output_len: int, num_prompts: int, range_ratio: float, tokenizer: PreTrainedTokenizerBase, use_chat_template: bool = False, -) -> list[tuple[str, int, int]]: +) -> list[tuple[str, int, int, Any | None]]: @@ - def sample_uniform(seq_len): + def sample_uniform(seq_len: int) -> list[int]: lower = int(seq_len * range_ratio) upper = seq_len seq_lens = np.random.randint(lower, upper + 1, size=num_prompts).tolist() return seq_lensPlease also align
input_requeststype hints inget_request(...)andbenchmark(...)to match the 4‑tuple shape.As per coding guidelines, include type hints everywhere and use
tyfor type checking.Also applies to: 181-185, 322-330
1052-1052: Add help text for--num-warmupsto match other CLI flags.This improves discoverability and makes CLI usage consistent with surrounding options.
✍️ Suggested tweak
- parser.add_argument("--num-warmups", type=int, default=0) + parser.add_argument( + "--num-warmups", + type=int, + default=0, + help="Number of warmup requests to run before the main benchmark.", + )
bench_serving.pyto be consistent with InferenceMAX/InferenceMAX as of 6eecc0e660c7a695240732b35a2bc2c8f1210ccd (see here)bench.shto remove separate warmupNote: I tried to remove superfluous diffs (whitespace, newline, ie any non functional changes) but couldn't get all of them
Summary by CodeRabbit
New Features
--num-warmupsparameter to specify the number of warmup prompts during benchmarking.Refactor