Skip to content

Commit bf4bdf3

Browse files
authored
Merge pull request #668 from NVIDIA/am/nixl-output
Support two NIXL bench output formats
2 parents 4ed3be3 + 412e7d0 commit bf4bdf3

File tree

2 files changed

+68
-9
lines changed

2 files changed

+68
-9
lines changed

src/cloudai/workloads/nixl_bench/report_generation_strategy.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,22 @@ def extract_data(stdout_file: Path) -> pd.DataFrame:
3737

3838
header_present, data = False, []
3939
for line in stdout_file.read_text().splitlines():
40-
if "Block Size (B) Batch Size Avg Lat. (us) B/W (MiB/Sec) B/W (GiB/Sec) B/W (GB/Sec)" in line:
40+
if not header_present and (
41+
"Block Size (B) Batch Size " in line and "Avg Lat. (us)" in line and "B/W (GB/Sec)" in line
42+
):
4143
header_present = True
4244
continue
43-
if header_present and len(line.split()) == 6:
44-
data.append(line.split())
45-
46-
df = lazy.pd.DataFrame(
47-
data, columns=["block_size", "batch_size", "avg_lat", "bw_mib_sec", "bw_gib_sec", "bw_gb_sec"]
48-
)
45+
parts = line.split()
46+
if header_present and (len(parts) == 6 or len(parts) == 10):
47+
if len(parts) == 6:
48+
data.append([parts[0], parts[1], parts[2], parts[-1]])
49+
else:
50+
data.append([parts[0], parts[1], parts[3], parts[2]])
51+
52+
df = lazy.pd.DataFrame(data, columns=["block_size", "batch_size", "avg_lat", "bw_gb_sec"])
4953
df["block_size"] = df["block_size"].astype(int)
5054
df["batch_size"] = df["batch_size"].astype(int)
5155
df["avg_lat"] = df["avg_lat"].astype(float)
52-
df["bw_mib_sec"] = df["bw_mib_sec"].astype(float)
53-
df["bw_gib_sec"] = df["bw_gib_sec"].astype(float)
5456
df["bw_gb_sec"] = df["bw_gb_sec"].astype(float)
5557

5658
return df
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2+
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
from pathlib import Path
18+
19+
import pytest
20+
21+
from cloudai.workloads.nixl_bench.report_generation_strategy import extract_data
22+
23+
LEGACY_FORMAT = """
24+
Block Size (B) Batch Size Avg Lat. (us) B/W (MiB/Sec) B/W (GiB/Sec) B/W (GB/Sec)
25+
--------------------------------------------------------------------------------
26+
4096 1 21.1726 184.495 0.180171 0.193457
27+
8192 1 21.7391 359.376 0.350953 0.376833
28+
33554432 1 24.6508 1.29813e+06 1267.71 1361.19
29+
67108864 1 39.746 1.61022e+06 1572.48 1688.44
30+
"""
31+
32+
NEW_FORMAT = """
33+
Block Size (B) Batch Size B/W (GB/Sec) Avg Lat. (us) Avg Prep (us) P99 Prep (us) Avg Post (us) P99 Post (us) Avg Tx (us) P99 Tx (us)
34+
----------------------------------------------------------------------------------------------------------------------------------------------------------------
35+
4096 1 0.958841 4.3 11.0 11.0 0.8 1.0 3.5 4.0
36+
8192 1 1.745779 4.7 13.0 13.0 0.8 1.0 3.8 5.0
37+
33554432 1 23.506385 1427.5 13.0 13.0 1.0 9.0 1426.0 1446.0
38+
67108864 1 23.582432 2845.7 13.0 13.0 0.9 9.0 2844.5 2851.0
39+
""" # noqa: E501
40+
41+
42+
@pytest.mark.parametrize(
43+
"sample,exp_latency,exp_bw",
44+
[
45+
(LEGACY_FORMAT, [21.1726, 21.7391, 24.6508, 39.746], [0.193457, 0.376833, 1361.19, 1688.44]),
46+
(NEW_FORMAT, [4.3, 4.7, 1427.5, 2845.7], [0.958841, 1.745779, 23.506385, 23.582432]),
47+
],
48+
ids=["LegacyFormat", "NewFormat"],
49+
)
50+
def test_nixl_bench_report_parsing(tmp_path: Path, sample: str, exp_latency: list[float], exp_bw: list[float]):
51+
(tmp_path / "nixl_bench.log").write_text(sample)
52+
df = extract_data(tmp_path / "nixl_bench.log")
53+
assert df.shape == (4, 4)
54+
assert df["block_size"].tolist() == [4096, 8192, 33554432, 67108864]
55+
assert df["batch_size"].tolist() == [1, 1, 1, 1]
56+
assert df["avg_lat"].tolist() == exp_latency
57+
assert df["bw_gb_sec"].tolist() == exp_bw

0 commit comments

Comments
 (0)