Skip to content

fix(nemo/qnn/parakeet-ctc): wrapper.py raises NameError on undefined feat_dim - #3937

Merged
csukuangfj merged 1 commit into
k2-fsa:masterfrom
Anai-Guo:fix-parakeet-ctc-wrapper-feat-dim
Sep 9, 2026
Merged

csukuangfj merged 1 commit into
k2-fsa:masterfrom
Anai-Guo:fix-parakeet-ctc-wrapper-feat-dim

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

scripts/nemo/qnn/parakeet-ctc/wrapper.py uses feat_dim without ever binding it:

    m = ModelWrapper(asr_model)
    m.eval()

    print("feat_dim", feat_dim)                                    # NameError
    x = torch.rand(1, feat_dim, args.max_len, dtype=torch.float32)
$ pyflakes scripts/nemo/qnn/parakeet-ctc/wrapper.py
scripts/nemo/qnn/parakeet-ctc/wrapper.py:67:23: undefined name 'feat_dim'
scripts/nemo/qnn/parakeet-ctc/wrapper.py:68:23: undefined name 'feat_dim'

Those are the only two undefined names in the file, and they sit on the straight-line path of
main(), so python wrapper.py --max-len ... --model-id ... always dies right after downloading
and printing the model — before it exports anything.

The sibling script one directory over,
scripts/nemo/qnn/nemotron-3.5-asr-streaming-0.6b/wrapper.py:370, has the line this one is
missing:

    feat_dim = asr_model.cfg.preprocessor.features
    ...
    x = torch.rand(1, feat_dim, window_size, dtype=torch.float32)

(scripts/nemo/nemotron-3.5-asr-streaming-0.6b/export_onnx.py:186 does the same.)

Reproduction

NeMo is not needed to show it — main is lifted out of the file with ast and run against a
stub whose cfg behaves like the OmegaConf config NeMo returns
(preprocessor.features = 128), with torch.onnx.export captured:

### python wrapper.py --max-len 200 --model-id nvidia/parakeet-ctc-0.6b
  [before] NameError: name 'feat_dim' is not defined
  [after]  feat_dim 128
           exported input shape (1, 128, 200)

(1, 128, 200) is (N, C, T) as documented in ModelWrapper.forward.

Fix

Add the missing feat_dim = asr_model.cfg.preprocessor.features, matching the sibling wrapper.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved ONNX export compatibility by matching the generated input tensor to the model’s configured feature dimensions.

main() printed and used feat_dim without defining it, so running the
script always raised NameError before exporting anything. The sibling
scripts/nemo/qnn/nemotron-3.5-asr-streaming-0.6b/wrapper.py reads it
from asr_model.cfg.preprocessor.features; do the same here.
@coderabbitai

coderabbitai Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b494f902-3848-4bb7-8895-206d02d42f31

📥 Commits

Reviewing files that changed from the base of the PR and between f64f90b and bba9272.

📒 Files selected for processing (1)
  • scripts/nemo/qnn/parakeet-ctc/wrapper.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The ONNX export wrapper now reads the model’s configured preprocessor feature dimension before constructing the random input tensor.

Changes

ONNX export input configuration

Layer / File(s) Summary
Read configured feature dimension
scripts/nemo/qnn/parakeet-ctc/wrapper.py
main() retrieves asr_model.cfg.preprocessor.features for input-tensor construction.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to bba92

The export wrapper now obtains the configured feature dimension before creating its input tensor, preventing the prior NameError and allowing ONNX export to proceed. No current merge-blocking risk is identified.

Suggested reviewers: csukuangfj

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the affected wrapper and the primary fix: defining the undefined feat_dim that caused a NameError.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@csukuangfj csukuangfj left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants