Skip to content

Commit fc2928a

Browse files
[Benchmark] Complete pooling throughput reporting
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
1 parent 3d6013f commit fc2928a

4 files changed

Lines changed: 31 additions & 8 deletions

File tree

rust/src/bench/src/backends/pooling.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ impl PoolingBackend {
3939
input: &RequestFuncInput,
4040
client: &reqwest::Client,
4141
) -> Result<RequestFuncOutput> {
42+
let payload = self.build_payload(input);
43+
4244
// Preserve client-side prompt_len as fallback if server doesn't report usage.
4345
let mut output = RequestFuncOutput {
4446
prompt_len: input.prompt_len,
@@ -47,9 +49,10 @@ impl PoolingBackend {
4749
input.prompt_list.as_ref().map_or(1, |list| list.len())
4850
}
4951
BackendKind::OpenaiEmbeddingsChat => 1,
50-
BackendKind::VllmRerank => {
51-
input.prompt_list.as_ref().map_or(1, |list| list.len().saturating_sub(1))
52-
}
52+
BackendKind::VllmRerank => payload
53+
.get("documents")
54+
.and_then(|documents| documents.as_array())
55+
.map_or(0, |documents| documents.len()),
5356
_ => unreachable!("PoolingBackend with non-pooling kind"),
5457
},
5558
..Default::default()
@@ -61,8 +64,6 @@ impl PoolingBackend {
6164
&input.request_id,
6265
);
6366

64-
let payload = self.build_payload(input);
65-
6667
let mut request = client.post(&input.api_url);
6768
for (k, v) in &headers {
6869
request = request.header(k, v);

rust/src/bench/src/compare.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const METRICS: &[MetricDef] = &[
1616
key: "request_throughput",
1717
lower_is_better: false,
1818
},
19+
MetricDef {
20+
label: "Input throughput (inputs/s)",
21+
key: "input_sequence_throughput",
22+
lower_is_better: false,
23+
},
1924
MetricDef {
2025
label: "Output throughput (tok/s)",
2126
key: "output_throughput",

rust/src/bench/src/multi_run.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::error::Result;
77
/// Key metrics extracted from a single run's JSON result.
88
struct RunMetrics {
99
request_throughput: f64,
10+
input_sequence_throughput: Option<f64>,
1011
output_throughput: f64,
1112
total_token_throughput: f64,
1213
mean_ttft_ms: f64,
@@ -38,6 +39,7 @@ impl RunMetrics {
3839
fn from_json(json: &serde_json::Value) -> Self {
3940
Self {
4041
request_throughput: get(json, "request_throughput"),
42+
input_sequence_throughput: get_opt(json, "input_sequence_throughput"),
4143
output_throughput: get(json, "output_throughput"),
4244
total_token_throughput: get(json, "total_token_throughput"),
4345
mean_ttft_ms: get(json, "mean_ttft_ms"),
@@ -71,6 +73,10 @@ fn get(json: &serde_json::Value, key: &str) -> f64 {
7173
json.get(key).and_then(|v| v.as_f64()).unwrap_or(0.0)
7274
}
7375

76+
fn get_opt(json: &serde_json::Value, key: &str) -> Option<f64> {
77+
json.get(key).and_then(|v| v.as_f64())
78+
}
79+
7480
fn get_ss_opt(json: &serde_json::Value, key: &str) -> Option<f64> {
7581
json.get("steady_state")
7682
.and_then(|ss| if ss.is_null() { None } else { Some(ss) })
@@ -119,8 +125,15 @@ fn print_multi_run_summary(runs: &[RunMetrics]) {
119125
let n = runs.len();
120126

121127
// Collect each metric into a series, compute stats
122-
let stats = vec![
123-
compute_stats("Request throughput (req/s)", runs, |r| r.request_throughput),
128+
let mut stats = vec![compute_stats("Request throughput (req/s)", runs, |r| {
129+
r.request_throughput
130+
})];
131+
if runs.iter().all(|r| r.input_sequence_throughput.is_some()) {
132+
stats.push(compute_stats("Input throughput (inputs/s)", runs, |r| {
133+
r.input_sequence_throughput.unwrap_or_default()
134+
}));
135+
}
136+
stats.extend([
124137
compute_stats("Output throughput (tok/s)", runs, |r| r.output_throughput),
125138
compute_stats("Total token throughput (tok/s)", runs, |r| {
126139
r.total_token_throughput
@@ -138,7 +151,7 @@ fn print_multi_run_summary(runs: &[RunMetrics]) {
138151
compute_stats("Completed requests", runs, |r| r.completed),
139152
compute_stats("Failed requests", runs, |r| r.failed),
140153
compute_stats("Duration (s)", runs, |r| r.duration),
141-
];
154+
]);
142155

143156
println!("{:=^80}", format!(" Multi-Run Summary ({n} runs) "));
144157
println!(
@@ -307,6 +320,7 @@ mod tests {
307320
fn mk_run(ss: Option<f64>) -> RunMetrics {
308321
RunMetrics {
309322
request_throughput: 0.0,
323+
input_sequence_throughput: None,
310324
output_throughput: 0.0,
311325
total_token_throughput: 0.0,
312326
mean_ttft_ms: 0.0,

rust/src/bench/src/sweep.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ fn print_sweep_summary(param_name: &str, points: &[SweepPoint], summary_percenti
295295
fn build_summary_columns(summary_percentiles: &[f64]) -> Vec<SummaryColumn> {
296296
let mut columns = vec![
297297
SummaryColumn::new("Req/s", "request_throughput", 10),
298+
SummaryColumn::new("Inputs/s", "input_sequence_throughput", 10),
298299
SummaryColumn::new("Tok/s", "output_throughput", 10),
299300
SummaryColumn::new("Total tok/s", "total_token_throughput", 12),
300301
SummaryColumn::new("SS req/s", SS_REQUEST_THROUGHPUT_KEY, 10),
@@ -452,6 +453,7 @@ mod tests {
452453
headers,
453454
vec![
454455
"Req/s",
456+
"Inputs/s",
455457
"Tok/s",
456458
"Total tok/s",
457459
"SS req/s",
@@ -495,6 +497,7 @@ mod tests {
495497
headers,
496498
vec![
497499
"Req/s",
500+
"Inputs/s",
498501
"Tok/s",
499502
"Total tok/s",
500503
"SS req/s",

0 commit comments

Comments
 (0)