[inference] fix: Support MCore dev inference mode - #3889
Conversation
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
|
/ok to test d389b5e |
|
|
||
| # TODO: remove this guard when Megatron-Core dev exposes InferenceMode from | ||
| # megatron.core.inference.utils. | ||
| class InferenceMode: |
There was a problem hiding this comment.
Nit: the fallback InferenceMode shim has no dedicated unit test exercising the fallback path (i.e., when the real InferenceMode import fails). The existing test_vlm_engine.py imports InferenceMode but doesn't verify the shim's is_active() -> False / no-op set_active/unset_active behavior in isolation. Since this is a temporary compat shim with a clear TODO, this is low priority — but a quick parametrized test patching the import to force the fallback would catch regressions if the shim's contract changes.
|
Light Review -- PR 3889 -- Clean MCore dev bump with stale compat guard removal. The changes are straightforward and well-scoped. -- Observations -- Guard removals look correct. _mcore_compat.py shim is narrow and safe. Qwen3ASR docstrings consistent. Test updates match source changes. Minor test coverage gap on the fallback InferenceMode shim (see inline comment). -- Suggested test cases -- No perf tests impacted. |
Light Review -- PR 3889 (formatted re-post) --- Clean MCore dev bump with stale compat guard removal. The changes are straightforward and well-scoped. --- Observations --- Guard removals look correct: mtp_block_spec, hybrid_override_pattern to hybrid_layer_pattern, muon_nesterov, get_mup_config_overrides, get_async_strategy/EnergyMonitor, and null tokenizer fallbacks are all cleanly removed. The surviving hybrid_context_parallel guard in initialize.py has an updated TODO with clear removal condition. | _mcore_compat.py shim is narrow and safe: fallback InferenceMode returns False for is_active() (safe default) and has a clear TODO for removal. The ImportError message check correctly re-raises if the entire module is missing vs just the name. | Qwen3ASR docstrings: cache_position parameter docs added to both forward methods. Formatting is consistent with the existing HF-style parameter docs. | Test updates match source changes: removed Mamba fallback helper tests, simplified test_finalize_uses_compatible_hybrid_layer_count, and hardcoded muon_nesterov assertions. | Minor test coverage gap: the _mcore_compat.py fallback InferenceMode class (the shim itself) has no dedicated test exercising the fallback path. See inline comment. Low priority given the temporary nature of the shim. --- Suggested test cases: No perf tests impacted. |
Original bump PR: #3883
Target:
devDate: 2026-05-19
Failure classification: MCore broke Bridge
Root cause:
InferenceModefrommegatron.core.inference.utils, so Bridge VLM inference modules failed import during install checks and unit-test collection.cache_positiondocstring entries in Qwen3ASR forward methods.Fix summary:
InferenceModeand route VLM code/tests through it.cache_positionin the Qwen3ASR forward docstrings.Guards:
src/megatron/bridge/inference/vlm/_mcore_compat.pywith TODO removal condition: remove when Megatron-Core dev exposesInferenceModefrommegatron.core.inference.utils.mtp_block_spec, Mamba hybrid layer helper/kwarg, Muonmuon_nesterov,get_mup_config_overrides, async checkpoint/EnergyMonitor imports, and null tokenizer library names.Validation:
python3 -m py_compile <changed Python files>passed.srun -A coreai_dlalgo_llm -p interactive ... bash -lc 'cd $WORKDIR && export PYTHONPATH=$PWD/src:$PWD/3rdparty/Megatron-LM:${PYTHONPATH:-} && export UV_NO_SYNC=1 && uv run python -c "import megatron.bridge.inference.vlm.base; import megatron.bridge.inference.vlm.vlm_engine; import megatron.bridge.models.qwen3_asr.hf_qwen3_asr.modeling_qwen3_asr" && uv run python -m pytest tests/unit_tests/inference/vlm/test_base.py tests/unit_tests/inference/vlm/test_vlm_engine.py tests/unit_tests/models/mamba/test_mamba_provider.py tests/unit_tests/recipes/utils/test_optimizer_utils.py tests/unit_tests/training/test_optim.py tests/unit_tests/training/test_state.py tests/unit_tests/training/test_energy_monitor.py tests/unit_tests/training/test_tokenizer.py -q'-> 112 passed, 35 warnings.uv run pre-commit run --all-files.Note: local
uv runcould not start hooks/tests because the workstation uv cache path formamba-ssm==2.3.2.post1is not writable; the required validation was completed in the CW interactive container.