verl icon indicating copy to clipboard operation
verl copied to clipboard

Megatron backend still fails to build models on Megatron-Core >= 0.18 via unpinned `mbridge` (even after #6927)

Open chengcuiping opened this issue 4 months ago • 1 comments

System Info

#6927 fixed the ModelType.encoder_and_decoder removal in verl's own megatron_utils.py, which is great — but the megatron backend still can't build a model on Megatron-Core 0.18, because it goes through mbridge for get_model, and mbridge (0.15.1, the current latest) has the exact same removed-member reference in mbridge/core/util.py:52,83. So a run configured with model_engine=megatron + use_fused_kernels=True gets past config/validation, Ray init, and worker startup, then dies at model construction:

File ".../mbridge/core/util.py", line 83, in build_model
    if model_type == ModelType.encoder_and_decoder:
AttributeError: type object 'ModelType' has no attribute 'encoder_and_decoder'

Applying the same getattr guard locally to util.py:52,83 works as a stopgap.

The actual fix belongs in mbridge (filed there: ISEEKYAN/mbridge#155). The verl-side point here is narrower: setup.py declares MCORE_REQUIRES = ["mbridge"] with no version constraint, so pip install pulls whatever mbridge latest is — and right now that latest is incompatible with the same Megatron-Core version #6927 was meant to unlock. The net effect is that "verl supports Megatron-Core 0.18" is true for verl's own code but not end-to-end, and the failure surfaces deep in model build rather than at install/validation time.

Would it make sense to pin mbridge to a known-good range in MCORE_REQUIRES (once a fixed mbridge is out), or at least document the Megatron-Core/mbridge compatibility pairing? Right now anyone bringing up the megatron backend on 0.18 hits this, fused kernels or not.

Context: this came up while validating the output_processor hook migration (#6933) end-to-end on Megatron-Core 0.18 — the hook change itself is unaffected (the crash is upstream of any forward), but it blocks the live megatron run.

Information

  • [ ] The official example scripts
  • [x] My own modified scripts

Tasks

  • [ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • [ ] My own task or dataset (give details below)

Reproduction

Steps to reproduce the behavior:

  1. Install verl with the megatron extras in an environment with megatron-core 0.18.0. MCORE_REQUIRES has no version constraint on mbridge, so pip pulls the current latest, mbridge==0.15.1.
  2. Launch any PPO run with the megatron engine (we used a dense Qwen2.5-0.5B on gsm8k, TP2 PP1, vLLM rollout — but the config doesn't matter; any model built through the megatron backend hits it).
  3. Startup gets past config validation, Ray init, and worker startup, then crashes at model construction: File ".../mbridge/core/util.py", line 83, in build_model if model_type == ModelType.encoder_and_decoder: AttributeError: type object 'ModelType' has no attribute 'encoder_and_decoder'

Root cause: megatron.core dropped ModelType.encoder_and_decoder (it now only has encoder_or_decoder), and mbridge 0.15.1 still references the removed member at util.py:52 and :83. Same class of issue #6927 fixed in verl's own megatron_utils.py. Filed on the mbridge side: ISEEKYAN/mbridge#155.

Expected behavior

Model construction succeeds on Megatron-Core 0.18, end-to-end — #6927 already fixed verl's own code for this, so the megatron backend should come up rather than dying inside an unpinned dependency. Failing that, an install-time or validation-time incompatibility error would be much better than a crash deep in model build. Pinning mbridge to a known-good range in MCORE_REQUIRES (once a fixed release is out), or documenting the Megatron-Core/mbridge compatibility pairing, would both address it.

chengcuiping avatar Jul 06 '26 08:07 chengcuiping

@chengcuiping The mbridge is deprecated, please use megatron-bridge instead.

actor_rollout_ref.actor.megatron.vanilla_mbridge=False

We will soon enable megatron-bridge by default. https://github.com/verl-project/verl/pull/6951

wuxibin89 avatar Jul 06 '26 09:07 wuxibin89