|
| 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