Skip to content

Fix LazyNeMoIterator for non-tarred S3 audio data - #15732

Merged
nithinraok merged 3 commits into
mainfrom
fix/get-full-path-datastore-uri
May 28, 2026
Merged

nithinraok merged 3 commits into
mainfrom
fix/get-full-path-datastore-uri

Conversation

@melllinia

@melllinia melllinia commented May 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes two issues that prevent LazyNeMoIterator from reading NeMo manifests referencing audio on object stores (s3://, ais://) in non-tarred format.

Issue 1: get_full_path joins S3 URIs with manifest directory

os.path.isabs("s3://bucket/file.opus") returns False, causing get_full_path to treat S3 URIs as relative paths and join with the manifest directory:

Input:  s3://audio-riva-originals/youtube/audios/file.opus
Result: s3:/manifest_dir/s3:/audio-riva-originals/youtube/audios/file.opus  (broken)

Fix: Check is_datastore_path(audio_file) at the top of get_full_path before any relative-path logic.

Issue 2: LazyNeMoIterator only pops "sampling_rate", ignoring "sample_rate"

Many datasets use "sample_rate" (e.g., ssl_yt_harvested). When the field is missing, NeMo falls back to Recording.from_file() which calls soundfile.info() on an S3 URI — which fails.

Fix: data.pop("sampling_rate", None) or data.pop("sample_rate", None)

How to reproduce

# Manifest with: {"audio_filepath": "s3://bucket/file.opus", "duration": 100, "sample_rate": 48000}
from lhotse import CutSet
from nemo.collections.common.data.lhotse.nemo_adapters import LazyNeMoIterator

cutset = CutSet(LazyNeMoIterator("manifest.jsonl"))
for cut in cutset:  # Fails without fix
    audio = cut.load_audio()

When does this happen?

  • Only affects non-tarred data (type: nemo) with S3/AIS audio paths
  • Tarred data (type: nemo_tarred) is unaffected because LazyNeMoTarredIterator reads audio bytes directly from tar
  • Tested with ssl_yt_harvested dataset (opus files on PDX S3)

Files changed

  • nemo/collections/common/parts/preprocessing/manifest.py — early return for datastore URIs
  • nemo/collections/common/data/lhotse/nemo_adapters.py — sample_rate fallback

Test plan

  • Verified get_full_path returns S3 URIs unchanged
  • Verified relative/absolute local paths still work correctly
  • End-to-end test: loaded 3 opus files from s3://audio-riva-originals via LazyNeMoIterator

@copy-pr-bot

copy-pr-bot Bot commented May 27, 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.

Two issues prevent LazyNeMoIterator from reading manifests that
reference audio files on object stores (s3://, ais://) when using
non-tarred (type: nemo) format:

1. get_full_path joins S3 URIs with manifest directory

   `os.path.isabs("s3://bucket/file.opus")` returns False, so
   get_full_path treats the S3 URI as a relative path and joins it
   with the manifest directory, producing invalid paths like:
   "s3:/manifest_dir/s3:/bucket/file.opus"

   Fix: check `is_datastore_path(audio_file)` before any relative-path
   logic and return the URI directly.

2. LazyNeMoIterator only pops "sampling_rate", ignoring "sample_rate"

   Many datasets (e.g. ssl_yt_harvested) use "sample_rate" in their
   manifests. When the field is missing, NeMo falls back to
   `Recording.from_file()` which cannot read S3 URIs via soundfile.

   Fix: fall back to `data.pop("sample_rate", None)` when
   "sampling_rate" is not present.

Reproducer:
  # Manifest on S3 with entries like:
  # {"audio_filepath": "s3://bucket/audios/file.opus", "duration": 100, "sample_rate": 48000}
  from lhotse import CutSet
  from nemo.collections.common.data.lhotse.nemo_adapters import LazyNeMoIterator
  cutset = CutSet(LazyNeMoIterator("path/to/manifest.jsonl"))
  for cut in cutset:  # Fails without fix
      audio = cut.load_audio()

Signed-off-by: Meline Mkrtchyan <mmkrtchyan@nvidia.com>
@melllinia
melllinia force-pushed the fix/get-full-path-datastore-uri branch from b8ea0fa to 1b21c6f Compare May 27, 2026 15:07

Copilot AI left a comment

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.

Pull request overview

This PR fixes LazyNeMoIterator and manifest path resolution so NeMo JSON manifests can reference non-tarred audio stored on object stores (e.g., s3://, ais://) without breaking path handling or triggering local-only audio metadata probing.

Changes:

  • Update get_full_path() to treat datastore URIs as absolute and return them unchanged (or cached), instead of joining them with the manifest directory.
  • Update LazyNeMoIterator to accept sample_rate as an alias/fallback for sampling_rate when creating Lhotse recordings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
nemo/collections/common/parts/preprocessing/manifest.py Prevents object-store URIs from being incorrectly treated as relative paths during full-path resolution.
nemo/collections/common/data/lhotse/nemo_adapters.py Adds sample_rate fallback when extracting sampling rate from NeMo manifest entries to avoid failing SR inference on remote URIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

pzelasko
pzelasko previously approved these changes May 27, 2026
@pzelasko

Copy link
Copy Markdown
Collaborator

/ok to test eec9e20

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

- Replace `or` operator with explicit `is None` check to avoid
  incorrect fallthrough when sampling_rate is 0 (falsy)
- Add test_get_full_path_datastore_uri_passthrough: verifies S3/AIS
  URIs are returned unchanged by get_full_path
- Add test_lazy_nemo_iterator_sample_rate_fallback: verifies
  LazyNeMoIterator uses sample_rate when sampling_rate is absent

Signed-off-by: Meline Mkrtchyan <mmkrtchyan@nvidia.com>
@melllinia
melllinia force-pushed the fix/get-full-path-datastore-uri branch from 0ad27f6 to 6f89b91 Compare May 28, 2026 05:43
@melllinia

Copy link
Copy Markdown
Member Author

/ok to test 6f89b91

@github-actions

Copy link
Copy Markdown
Contributor

[🤖]: Hi @melllinia 👋,

We wanted to let you know that a CICD pipeline for this PR just finished successfully.

So it might be time to merge this PR or get some approvals.

@melllinia
melllinia requested a review from pzelasko May 28, 2026 07:09

@nithinraok nithinraok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@nithinraok
nithinraok merged commit 5d9b6bc into main May 28, 2026
164 checks passed
@nithinraok
nithinraok deleted the fix/get-full-path-datastore-uri branch May 28, 2026 14:21

This branch was previously deployed

2 inactive deployments
public — 6f89b91e Deployed May 28, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #441
test — 6f89b91e Deployed May 28, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #19925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants