Skip to content

fix(asr): resolve CPU-GPU sync bottleneck in BLEU metric computation#15891

Open
Sainava wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
Sainava:fix/bleu-metric-gpu-sync
Open

fix(asr): resolve CPU-GPU sync bottleneck in BLEU metric computation#15891
Sainava wants to merge 2 commits into
NVIDIA-NeMo:mainfrom
Sainava:fix/bleu-metric-gpu-sync

Conversation

@Sainava

@Sainava Sainava commented Jul 7, 2026

Copy link
Copy Markdown

Important

The Update branch button must only be pressed in very rare occassions.
An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.

What does this PR do ?

Resolves a documented TODO regarding excessive CPU-to-GPU operations by replacing an $O(N)$ sequential metric update loop with an $O(1)$ batched update, eliminating implicit host-to-device synchronizations per sample.

Collection: ASR

Changelog

  • Aggregated hypotheses and references into batch lists rather than processing them sample-by-sample.
  • Grouped texts by tokenizer type to preserve support for dynamic BLEU_TOKENIZER extraction via check_cuts.
  • Replaced the iterative _bleu_score_update calls with a single group-level update, preventing the numerator, denominator, preds_len, and target_len state tensors from forcing sequential CPU-GPU blocking during evaluation.

Usage

  • Internal performance optimization. No changes to the public API or user-facing usage are required.
# The BLEU metric is instantiated and used exactly as before, but evaluation throughput is significantly increased, especially at larger batch sizes.

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Resolves the in-code # TODO: on line 190 of nemo/collections/asr/metrics/bleu.py regarding backend implementation speedups.

Signed-off-by: Sainava <sainava.modak@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Jul 9, 2026
@Sainava

Sainava commented Jul 14, 2026

Copy link
Copy Markdown
Author

Hi , I noticed a TODO regarding the CPU-GPU sync bottleneck in the BLEU metric, so I batched the updates to eliminate the sequential host-to-device synchronizations. Please take a look whenever you have a moment!

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants