Skip to content

Commit 04e3511

Browse files
committed
Create self-contained typer app, update README with new commands to run it
1 parent 64ee0b5 commit 04e3511

File tree

3 files changed

+61
-35
lines changed

3 files changed

+61
-35
lines changed

aiperf/README.md

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,36 @@ Instead of manually running AIPerf multiple times with different parameters, you
2121

2222
These steps have been tested with Python 3.11.11.
2323
To use the provided configurations, you need to create accounts at https://build.nvidia.com/ and [Huggingface](https://huggingface.co/).
24-
The provided configurations use models hosted at https://build.nvidia.com/, you'll need to create a Personal API Key to access the models.
25-
AIperf requires the [Meta Llama 3.3 70B Instruct tokenizer](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) to calculate token-counts.
24+
* The provided configurations use models hosted at https://build.nvidia.com/, you'll need to create a Personal API Key to access the models.
25+
* The provided AIperf configurations require the [Meta Llama 3.3 70B Instruct tokenizer](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) to calculate token-counts.
2626

27-
1. **Install NeMo Guardrails with developer tooling:**
27+
1. **Create a virtual environment in which to install AIPerf**
2828

2929
```bash
30-
poetry install --with dev
30+
$ mkdir ~/env
31+
$ python -m venv ~/env/aiperf
3132
```
3233

33-
2. **Install AIPerf and NVIDIA AI Endpoints:**
34+
2. **Install dependencies in the virtual environment**
3435

3536
```bash
36-
poetry run pip install aiperf langchain-nvidia-ai-endpoints
37+
$ pip install aiperf huggingface_hub typer
3738
```
3839

39-
3. ** Install/upgrade Hugging Face Hub:**
40-
41-
AIPerf needs a tokenizer to run and will download one from Hugging Face if available. If you have the tokenizer locally, you can point to that directory and not log into Huggingface.
42-
43-
```bash
44-
poetry run pip install --upgrade huggingface_hub
45-
```
46-
47-
4. ** Login to Hugging Face:**
40+
3. ** Login to Hugging Face:**
4841

4942
```bash
5043
huggingface-cli login
5144
```
5245

53-
5. ** Set NVIDIA API Key:**
46+
4. ** Set NVIDIA API Key:**
5447

55-
To use models hosted on [build.nvidia.com](https://build.nvidia.com/), set your API key:
48+
The provided configs use models hosted on [build.nvidia.com](https://build.nvidia.com/).
49+
To access these, [create an account](https://build.nvidia.com/), and create a Personal API Key.
50+
After creating a Personal API key, set the `NVIDIA_API_KEY` variable as below.
5651

5752
```bash
58-
export NVIDIA_API_KEY="your-api-key-here"
53+
$ export NVIDIA_API_KEY="your-api-key-here"
5954
```
6055

6156
## Running Benchmarks
@@ -70,39 +65,39 @@ There are two example configs included which can be extended for your use-cases.
7065
To run a benchmark, use the following command:
7166

7267
```bash
73-
poetry run nemoguardrails aiperf run --config-file <path-to-config.yaml>
68+
$ python -m aiperf --config-file <path-to-config.yaml>
7469
```
7570

7671
### Running a Single Benchmark
7772

7873
To run a single benchmark with fixed parameters, use the `single_concurrency.yaml` configuration:
7974

8075
```bash
81-
poetry run nemoguardrails aiperf run --config-file nemoguardrails/benchmark/aiperf/aiperf_configs/single_concurrency.yaml
76+
$ python -m aiperf --config-file aiperf/configs/single_concurrency.yaml
8277
```
8378

8479
**Example output:**
8580

8681
```text
87-
2025-11-14 13:58:21 INFO: Running AIPerf with configuration: nemoguardrails/benchmark/aiperf/aiperf_configs/single_concurrency.yaml
88-
2025-11-14 13:58:21 INFO: Results root directory: aiperf_results/single_concurrency/20251114_135821
89-
2025-11-14 13:58:21 INFO: Sweeping parameters: None
90-
2025-11-14 13:58:21 INFO: Running AIPerf with configuration: nemoguardrails/benchmark/aiperf/aiperf_configs/single_concurrency.yaml
91-
2025-11-14 13:58:21 INFO: Output directory: aiperf_results/single_concurrency/20251114_135821
92-
2025-11-14 13:58:21 INFO: Single Run
93-
2025-11-14 13:59:58 INFO: Run completed successfully
94-
2025-11-14 13:59:58 INFO: SUMMARY
95-
2025-11-14 13:59:58 INFO: Total runs : 1
96-
2025-11-14 13:59:58 INFO: Completed : 1
97-
2025-11-14 13:59:58 INFO: Failed : 0
82+
2025-12-01 10:35:17 INFO: Running AIPerf with configuration: aiperf/configs/single_concurrency.yaml
83+
2025-12-01 10:35:17 INFO: Results root directory: aiperf_results/single_concurrency/20251201_103517
84+
2025-12-01 10:35:17 INFO: Sweeping parameters: None
85+
2025-12-01 10:35:17 INFO: Running AIPerf with configuration: aiperf/configs/single_concurrency.yaml
86+
2025-12-01 10:35:17 INFO: Output directory: aiperf_results/single_concurrency/20251201_103517
87+
2025-12-01 10:35:17 INFO: Single Run
88+
2025-12-01 10:36:54 INFO: Run completed successfully
89+
2025-12-01 10:36:54 INFO: SUMMARY
90+
2025-12-01 10:36:54 INFO: Total runs : 1
91+
2025-12-01 10:36:54 INFO: Completed : 1
92+
2025-12-01 10:36:54 INFO: Failed : 0
9893
```
9994

10095
### Running a Concurrency Sweep
10196

102-
To run multiple benchmarks with different concurrency levels, use the `sweep_concurrency.yaml` configuration:
97+
To run multiple benchmarks with different concurrency levels, use the `sweep_concurrency.yaml` configuration as below:
10398

10499
```bash
105-
poetry run nemoguardrails aiperf run --config-file nemoguardrails/benchmark/aiperf/aiperf_configs/sweep_concurrency.yaml
100+
$ python -m aiperf --config-file aiperf/configs/sweep_concurrency.yaml
106101
```
107102

108103
**Example output:**
@@ -139,7 +134,7 @@ The `--dry-run` option allows you to preview all benchmark commands without exec
139134
- Debugging configuration issues
140135

141136
```bash
142-
poetry run nemoguardrails aiperf run --config-file <config.yaml> --dry-run
137+
$ python -m aiperf --config-file aiperf/configs/sweep_concurrency.yaml --dry-run
143138
```
144139

145140
When in dry-run mode, the script will:
@@ -155,7 +150,7 @@ When in dry-run mode, the script will:
155150
The `--verbose` option outputs more detailed debugging information to understand each step of the benchmarking process.
156151

157152
```bash
158-
poetry run nemoguardrails aiperf run --config-file <config.yaml> --verbose
153+
$ python -m aiperf --config-file <config.yaml> --verbose
159154
```
160155

161156
Verbose mode provides:

aiperf/__main__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
# SPDX-FileCopyrightText: 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+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
18+
# SPDX-License-Identifier: Apache-2.0
19+
20+
"""Entry point for running aiperf as a module: python -m aiperf"""
21+
22+
from aiperf.run_aiperf import app
23+
24+
if __name__ == "__main__":
25+
app()

aiperf/run_aiperf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
log.addHandler(console_handler)
4848

49+
app = typer.Typer()
50+
4951

5052
@dataclass
5153
class AIPerfSummary:
@@ -486,3 +488,7 @@ def run(
486488
exit_code = runner.run(dry_run=dry_run)
487489

488490
raise typer.Exit(code=exit_code)
491+
492+
493+
if __name__ == "__main__":
494+
app()

0 commit comments

Comments
 (0)