Skip to content

feat(mimo): add Whisper audio encoder to LLaVA MIMO training pipeline#3520

Merged
kamran-nvidia merged 23 commits into
mainfrom
kamran/mimo_audio
May 12, 2026
Merged

feat(mimo): add Whisper audio encoder to LLaVA MIMO training pipeline#3520
kamran-nvidia merged 23 commits into
mainfrom
kamran/mimo_audio

Conversation

@kamran-nvidia

@kamran-nvidia kamran-nvidia commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

Adds end-to-end audio modality support to the MIMO LLaVA example, alongside the existing CLIP vision branch. Specifically:

Changelog

Also from this PR (#3531):

  • Adds an opt-in --deterministic flag to the MIMO LLaVA and LLaVA-audio
    training scripts (megatron_mimo_training_llava.py,
    megatron_mimo_training_llava_audio.py). When set, vision, language, audio,
    and projection configs run in FP32 with unfused attention, loss fusion
    disabled, and full activation recompute so runs are bitwise reproducible.
  • Threads the deterministic argument through the relevant config and model
    spec helpers so each sub-module is configured consistently.
  • Updates the launcher shell scripts under
    examples/models/megatron_mimo/ (run_hetero_llava.sh,
    run_hetero_llava_audio.sh, and the three *_parallelism_tests*.sh
    variants) to forward --deterministic and export the env vars required for
    deterministic execution (e.g. cuBLAS / NCCL settings).
  • No behavior change when the flag is omitted — default training paths are
    untouched.

GitHub Actions CI

See the CI sectionin the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.

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?

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

Additional Information

  • Related to # (issue)

- Introduced `whisper` module with `WhisperEncoder` for Megatron.
- Implemented `convert_hf_whisper_to_megatron.py` to convert HuggingFace Whisper weights to Megatron format.
- Added verification script `verify_whisper_conversion.py` to compare outputs between HuggingFace and Megatron models.
- Created `whisper_layer_specs.py` to define layer specifications for Whisper encoder.
- Updated dataset processing in `dataset.py` to handle audio feature extractors with sampling rate.

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Apr 24, 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.

@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 9c558ff

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 05f22f5

@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/claude review

Comment thread examples/models/megatron_mimo/whisper/__init__.py Outdated
Comment thread examples/models/megatron_mimo/whisper/whisper_model.py
Comment thread examples/models/megatron_mimo/megatron_mimo_training_llava_audio.py Outdated

@claude claude Bot 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.

Light Review Summary

3 bugs, 1 typo, 1 coverage gap:

  1. Typowhisper/__init__.py has copyright year 2025; all other new files use 2026.

  2. Bugwhisper_model.py:21: bare except: silently catches SystemExit/KeyboardInterrupt. Should be except ImportError:.

  3. Bugmegatron_mimo_training_llava_audio.py:316-317: audio sample rate from sf.read() is discarded. Files not at 16 kHz will silently produce wrong Whisper features.

  4. Minorconvert_hf_whisper_to_megatron.py:167-170: the silent zero-fill for missing K-proj bias is correct for current Whisper variants but fragile — worth an explicit assert or comment.

  5. Test coverage — This PR adds ~2600 lines of new model, conversion, and training code with no unit tests. The PR checklist boxes for tests and docs are unchecked. At minimum, the conversion round-trip (convert_hf_whisper_to_megatronload_megatron_whisper_weights → shape/value check) and the QKV interleave logic should have unit tests.

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 3a72a2b

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test ab9a70e

- Introduced `test_synthesize_audio_helpers.py` to validate helper functions in audio synthesis, including human text extraction and audio relative path generation.
- Created `test_training_llava_audio_helpers.py` for testing pure helpers in the training script, focusing on functions related to token span finding and audio configuration.
- Enhanced `test_whisper_conversion.py` with additional tests for handling unmapped encoder keys and verifying conversion shapes.
- Added `test_whisper_encoder_forward.py` to ensure correct forward-pass behavior in the Whisper encoder, including output shape contracts and position embedding checks.
- Implemented `test_whisper_layer_specs.py` to confirm that attention mask types remain consistent and validate linear layer implementations in Whisper's architecture.

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 67a106e

…rove clarity

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test cc9e68e

@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 4c8f254

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 42fb555

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Comment thread tests/functional_tests/test_groups/training/test_pretrain_megatron_mimo.py Outdated

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.

should this modeling code live in the examples folder?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cuichenx Good question. I guess I can move this to the models folder but we are not qualifying the Whisper model as a stand-alone model in the MBridge with this PR. Wdyt?

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.

@cuichenx what's the move for where modeling code lives?
I saw it in several places.. CLIP is in MCore, QWen3VL is in MBridge. Any thoughts on where we should drop this audio encoder? As Kamran mentioned, it won't be a standalone model...

…meters in training script

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
… learning rates

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 1fc43e1

… 5.6

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
@kamran-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 43c65a7

@yaoyu-33 yaoyu-33 added the needs-review PR is ready for code review and waiting on a reviewer label May 12, 2026
@kamran-nvidia kamran-nvidia merged commit e215dc9 into main May 12, 2026
95 checks passed
@kamran-nvidia kamran-nvidia deleted the kamran/mimo_audio branch May 12, 2026 20:16
vasunvidia pushed a commit to vasunvidia/Megatron-Bridge that referenced this pull request Jun 10, 2026
…NVIDIA-NeMo#3520)

Signed-off-by: Kamran Jafari <kjafarisadeg@nvidia.com>
Signed-off-by: Vasudevan Rengasamy <vrengasamy@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model implementations and HF bridge logic feature New capabilities, enhancements, or enablement work high-complexity Harder to merge: prone to conflicts and needs additional test coverage needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants