Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
89bc074
Updates env var names to match other top-level scripts, does not tag …
rlratzel Dec 13, 2025
9b64594
Updates env var for consistency
rlratzel Dec 13, 2025
34564d4
Fixes formatting of help message.
rlratzel Dec 13, 2025
7ef2bf9
Merge branch 'main' into 2602_benchmark_infra_updates
ayushdg Dec 15, 2025
0692fbb
Merge remote-tracking branch 'upstream/main' into 2602_benchmark_infr…
rlratzel Dec 17, 2025
82383a0
Merge branch '2602_benchmark_infra_updates' of https://github.com/rlr…
rlratzel Dec 17, 2025
3ec5b30
Removes unused support for an artifacts dir.
rlratzel Dec 18, 2025
ed1b95e
Removes unconditional use of --benchmarks-results-dir arg when runnin…
rlratzel Dec 18, 2025
59de0d9
Fixes warning condition about not converting to number when only huma…
rlratzel Dec 19, 2025
53ef91d
Updates results path to be session_entry_dir so framework can find re…
rlratzel Dec 19, 2025
af646d8
Merge branch '2602_benchmark_infra_updates' into 26.02-add_image_bench
rlratzel Dec 19, 2025
eba1928
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Dec 19, 2025
cc2bf93
Adds initial entry for image curation benchmark
rlratzel Dec 21, 2025
026d79c
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Dec 21, 2025
fc61726
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Jan 6, 2026
8a7f0b2
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Jan 6, 2026
6e90da1
Merge remote-tracking branch 'upstream' into 26.02-add_image_bench
rlratzel Jan 7, 2026
69b1d06
Adds curator_repo_dir reserved placeholder, fixes bug where invalid p…
rlratzel Jan 7, 2026
58741c4
Merge remote-tracking branch 'upstream' into 26.02-add_image_bench
rlratzel Jan 7, 2026
323c346
Merge remote-tracking branch 'upstream' into 26.02-add_image_bench
rlratzel Jan 7, 2026
58eaf11
Initial audio benchmark script.
rlratzel Jan 9, 2026
3324e2f
Minor updates for linter.
rlratzel Jan 9, 2026
6b461e8
Adds updates for writing out out json/pickle files, adds new benchmar…
rlratzel Jan 10, 2026
a991a07
Merge remote-tracking branch 'upstream' into 26.02-add_image_bench
rlratzel Jan 10, 2026
43f1bfc
Merge remote-tracking branch 'upstream' into 26.02-add_audio_bench
rlratzel Jan 10, 2026
bc50782
Merge branch '26.02-add_image_bench' into 26.02-add_audio_bench
rlratzel Jan 10, 2026
6a34d85
Fixes mkdir error in write_benchmark_results utility.
rlratzel Jan 10, 2026
58bb3a5
Initializes results
rlratzel Jan 11, 2026
be5d93b
return success based on is_success metric
rlratzel Jan 11, 2026
12931e8
Removes unneeded get_obj_for_json utility.
rlratzel Jan 13, 2026
33ebc5a
Merge remote-tracking branch 'upstream/main' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
a1c89be
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Jan 13, 2026
c6d6589
Merge branch '26.02-add_image_bench' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
02ba779
Adds JSON util back
rlratzel Jan 13, 2026
6a03d08
Merge branch '26.02-add_image_bench' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
98e3a56
Merge remote-tracking branch 'upstream/main' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
6e5cd40
Removes unneeded assertion code
rlratzel Jan 13, 2026
3e556f7
Merge remote-tracking branch 'upstream/main' into 26.02-add_image_bench
rlratzel Jan 13, 2026
dfb5834
Merge branch '26.02-add_image_bench' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
fa311ed
Adds JSON util back
rlratzel Jan 13, 2026
cda714d
Merge branch '26.02-add_image_bench' into 26.02-add_audio_bench
rlratzel Jan 13, 2026
3f3d5ac
Merge branch 'main' into 26.02-add_audio_bench
praateekmahajan Jan 14, 2026
8f84e03
Merge remote-tracking branch 'upstream/main' into 26.02-add_audio_bench
rlratzel Jan 14, 2026
957f2e6
Merge branch '26.02-add_audio_bench' of https://github.com/rlratzel/c…
rlratzel Jan 14, 2026
3ed1e14
Removes redundant line from merge
rlratzel Jan 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions benchmarking/nightly-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,15 @@ entries:
--nsfw-threshold 0.9
--skip-download
--verbose

- name: audio_fleurs
enabled: true
script: audio_fleurs_benchmark.py
args: >-
--benchmark-results-path={session_entry_dir}
--scratch-output-path={session_entry_dir}/scratch
--model-name=nvidia/stt_hy_fastconformer_hybrid_large_pc
--lang=hy_am
--split=dev
--wer-threshold=5.5
--gpus=1
17 changes: 17 additions & 0 deletions benchmarking/runner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
import pickle
import re
import subprocess
from pathlib import Path
Expand All @@ -29,6 +31,21 @@
_env_var_pattern = re.compile(r"\$\{([^}]+)\}") # Pattern to match ${VAR_NAME}


def write_benchmark_results(results: dict, output_path: Path) -> None:
"""Write results to the standard files expected by the benchmark framework.

This utility is typically used by developer-written benchmark scripts to write results
to the standard files expected by the benchmark framework.
"""
output_path.mkdir(parents=True, exist_ok=True)
if "params" in results:
(output_path / "params.json").write_text(json.dumps(results["params"], indent=2))
if "metrics" in results:
(output_path / "metrics.json").write_text(json.dumps(results["metrics"], indent=2))
if "tasks" in results:
(output_path / "tasks.pkl").write_bytes(pickle.dumps(results["tasks"]))


# TODO: This utility contains some special cases for Slack JSON messages used in the Slack sink.
# Consider moving these special cases to the Slack sink itself.
def get_obj_for_json(obj: object) -> object:
Expand Down
141 changes: 141 additions & 0 deletions benchmarking/scripts/audio_fleurs_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copyright year is set to 2026, which is in the future. This should be 2025 to match the other files in this PR (entry.py, session.py, utils.py all use 2025).

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copyright year is 2026, but should be 2025.

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copyright year is set to 2026, which appears to be incorrect. Should be 2025 to match other files in the repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright year should be 2025, not 2026. All other files in the repository use 2025.

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Copyright year should be 2025, not 2026

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Copyright year should be 2025 to match other files in this PR (entry.py, utils.py, session.py all use 2025)

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: copyright year should be 2025 to match other files in the repository

Suggested change
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# ruff: noqa: S101 # Allow asserts in this script

import argparse
import sys
from pathlib import Path
from typing import Any

from loguru import logger

from nemo_curator.backends.xenna import XennaExecutor
from nemo_curator.pipeline import Pipeline
from nemo_curator.stages.audio.common import GetAudioDurationStage, PreserveByValueStage
from nemo_curator.stages.audio.datasets.fleurs.create_initial_manifest import CreateInitialManifestFleursStage
from nemo_curator.stages.audio.inference.asr_nemo import InferenceAsrNemoStage
from nemo_curator.stages.audio.io.convert import AudioToDocumentStage
from nemo_curator.stages.audio.metrics.get_wer import GetPairwiseWerStage
from nemo_curator.stages.resources import Resources
from nemo_curator.stages.text.io.writer import JsonlWriter

# Import benchmarking utils which are currently only available directly from the Curator source tree.
# __file__ is expected to be <curator repo>/benchmarking/scripts/audio_fleurs_benchmark.py
_repo_dir = Path(__file__).resolve().parent.parent.parent
sys.path.insert(0, str(_repo_dir))
from benchmarking.runner.utils import write_benchmark_results # noqa: E402


def run_audio_fleurs_benchmark(args: argparse.Namespace) -> dict[str, Any]:
results_dir = args.benchmark_results_path / "results"

# Ensure the results dir does not exist so that it will be created.
# This ensures no preexisting files are present which would otherwise be treated as additional results.
if results_dir.exists():
msg = f"Result directory {results_dir} already exists."
raise ValueError(msg)

executor = XennaExecutor()
pipeline = Pipeline(name="audio_inference", description="Inference audio and filter by WER threshold.")

# Add stages
# Add the composite stage that combines reading and downloading
pipeline.add_stage(
CreateInitialManifestFleursStage(
lang=args.lang,
split=args.split,
raw_data_dir=args.scratch_output_path / "armenian/fleurs",
).with_(batch_size=4)
)
pipeline.add_stage(InferenceAsrNemoStage(model_name=args.model_name).with_(resources=Resources(gpus=args.gpus)))
pipeline.add_stage(
GetPairwiseWerStage(
text_key="text",
pred_text_key="pred_text",
wer_key="wer",
)
)
pipeline.add_stage(
GetAudioDurationStage(
audio_filepath_key="audio_filepath",
duration_key="duration",
)
)
pipeline.add_stage(
PreserveByValueStage(
input_value_key="wer",
target_value=args.wer_threshold,
operator="le",
)
)
pipeline.add_stage(AudioToDocumentStage().with_(batch_size=1))
pipeline.add_stage(
JsonlWriter(
path=results_dir,
write_kwargs={"force_ascii": False},
)
)

results = pipeline.run(executor)

return {
# Populate the metrics dictionary with metrics to include in the report for this benchmark.
# This also allows the framework to perform user-defined checks on the metrics to ensure perf requirements are met.
"metrics": {
"is_success": True,
},
"tasks": results,
}
Comment thread
rlratzel marked this conversation as resolved.
Resolved


def main() -> int:
parser = argparse.ArgumentParser(description="Audio Fleurs benchmark")
parser.add_argument("--benchmark-results-path", required=True, help="Path to benchmark results")
parser.add_argument("--scratch-output-path", required=True, help="Path to scratch output directory")
parser.add_argument("--model-name", default="nvidia/stt_hy_fastconformer_hybrid_large_pc", help="ASR model name")
parser.add_argument("--lang", default="hy_am", help="Language code")
parser.add_argument("--split", default="dev", help="Dataset split to use")
parser.add_argument("--wer-threshold", type=float, default=5.5, help="WER threshold for filtering")
parser.add_argument("--gpus", type=int, default=1, help="Number of GPUs to use")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --gpus argument is defined as type=int, but the original tutorial code in tutorials/audio/fleurs/pipeline.py line 110 uses type=float. This creates an inconsistency.

The Resources class used in line 104 likely expects a float (GPUs can be fractional for resource allocation). Consider using type=float to match the original tutorial:

Suggested change
parser.add_argument("--gpus", type=int, default=1, help="Number of GPUs to use")
parser.add_argument("--gpus", type=float, default=1, help="Number of GPUs to use")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --gpus argument uses type=int, but the tutorial script this is based on (tutorials/audio/fleurs/pipeline.py line 110) uses type=float to allow fractional GPU allocation (e.g., 0.5 for half a GPU). While Resources.gpus accepts float values, using type=int limits flexibility.

Consider using type=float for consistency with the original tutorial and to allow fractional GPU allocation if needed in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: type=int differs from the tutorial's type=float (tutorials/audio/fleurs/pipeline.py:110), though both work with Resources.gpus

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

args = parser.parse_args()
logger.info("=== Audio Fleurs Benchmark Starting ===")
logger.info(f"Arguments: {vars(args)}")

success_code = 1 # assume failure until benchmark succeeds

# This dictionary will contain benchmark metadata and results, written to files for the benchmark framework to read.
# The dictionary must contain objects which can be serialized to JSON or pickle files.
result_dict = {
"params": vars(args).copy(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params field stores vars(args).copy() which includes Path objects as strings. However, at line 180-181, the args are converted to Path objects after being saved. This means the JSON-serialized params won't reflect the actual Path type used internally. Consider converting paths to strings explicitly after Path conversion, or document this transformation order is intentional for JSON serialization.

"metrics": {
"is_success": False,
},
"tasks": [],
}
# Now that the args have been saved as JSON-serializable strings for the result_dict, convert paths to Path
# objects for use in the benchmark script.
args.benchmark_results_path = Path(args.benchmark_results_path)
args.scratch_output_path = Path(args.scratch_output_path)

try:
result_dict.update(run_audio_fleurs_benchmark(args))
success_code = 0 if result_dict["metrics"]["is_success"] else 1
finally:
write_benchmark_results(result_dict, args.benchmark_results_path)
return success_code


if __name__ == "__main__":
raise SystemExit(main())