verl.model_merger cannot convert Qwen3_5ForConditionalGeneration Megatron checkpoints to HuggingFace format
Summary
verl.model_merger does not currently support converting Megatron checkpoints for Qwen3_5ForConditionalGeneration into HuggingFace format, even though Qwen3.5-related training paths appear to be partially supported in the codebase.
What I am trying to do
Convert a Megatron SFT checkpoint saved by verl into HuggingFace format with:
torchrun \
--nnodes 1 \
--nproc_per_node 1 \
--master_addr 127.0.0.1 \
--master_port 29631 \
-m verl.model_merger merge \
--backend megatron \
--local_dir <checkpoint_dir> \
--target_dir <output_dir> \
--tie-word-embedding \
--trust-remote-code \
--use_cpu_initialization
The checkpoint directory has the standard Megatron layout expected by the merger, including:
dist_ckpt/data_0.pt,data_1.pt, ...
Problem
The merger fails for Qwen3_5ForConditionalGeneration.
There seem to be two separate issues:
1. Qwen3_5Config compatibility in merger path
The merger assumes top-level config fields such as:
num_hidden_layershidden_sizenum_attention_headsnum_key_value_headsintermediate_size
But for Qwen3_5Config, these are stored under text_config.
This causes failures like:
AttributeError: 'Qwen3_5Config' object has no attribute 'num_hidden_layers'
2. Missing registry support for Qwen3_5ForConditionalGeneration
After patching the config shape manually, the merger still fails with:
NotImplementedError: Model Type: Qwen3_5ForConditionalGeneration not supported.
From the current code, Qwen3_5ForConditionalGeneration is not registered in the merger registries used by verl.model_merger, including:
SupportedModelMODEL_CONFIG_CONVERTER_REGISTRYMODEL_INITIALIZER_REGISTRYMODEL_WEIGHT_CONVERTER_REGISTRY
Relevant code observations
In verl/models/mcore/registry.py:
- some newer VLM names are recognized elsewhere in the codebase
- but
verl.model_mergerstill relies onSupportedModeland the old registries Qwen3_5ForConditionalGenerationis missing there
In verl/model_merger/megatron_model_merger.py:
- merger logic directly reads
self.hf_config.num_hidden_layers - this is incompatible with configs where text model fields live under
text_config
Expected behavior
verl.model_merger should be able to convert Megatron checkpoints for Qwen3_5ForConditionalGeneration to HuggingFace format, or at minimum clearly document that this architecture is not yet supported.
Actual behavior
Conversion fails before loading and merging finishes, due to:
- config field assumptions incompatible with
Qwen3_5Config - missing model registration for
Qwen3_5ForConditionalGeneration
Suggested fix
Support Qwen3_5ForConditionalGeneration in the Megatron merger path by:
- Making merger and config conversion handle
text_config.*for Qwen3.5 VLM configs - Registering
Qwen3_5ForConditionalGenerationin:SupportedModelMODEL_CONFIG_CONVERTER_REGISTRYMODEL_INITIALIZER_REGISTRYMODEL_WEIGHT_CONVERTER_REGISTRY
- Ensuring weight conversion logic is available for this architecture
Notes
This issue is specifically about Megatron checkpoint -> HuggingFace conversion.
It is not about checkpoint saving itself: the checkpoint directory already contains a valid dist_ckpt/ layout.
Did you use mbridge?
I guess you will have to use mbridge where model_merger is not necessary
As @vermouth1992 mentioned, using mbridge is the recommended approach for Qwen3.5 VLM models. The model_merger path is primarily for legacy workflows.
With mbridge:
- Set
actor_rollout_ref.actor.megatron.use_mbridge=Trueduring training - Use mbridge's
save_hf_modelAPI directly to export to HuggingFace format - No separate merger step needed
However, if you need to use model_merger for existing checkpoints without mbridge:
- Config access: Modify
megatron_model_merger.pyto handle nestedtext_config:
# Instead of:
num_layers = self.hf_config.num_hidden_layers
# Use:
num_layers = getattr(self.hf_config, 'num_hidden_layers', None) or \
getattr(self.hf_config, 'text_config', {}).get('num_hidden_layers')
- Registry support: Add
Qwen3_5ForConditionalGenerationto the registries
This is a valid gap in the merger support for newer VLM architectures. Consider contributing a PR if you implement the fix.
As @vermouth1992 mentioned, using mbridge is the recommended approach for Qwen3.5 VLM models. The
model_mergerpath is primarily for legacy workflows.如前所述,使用 mbridge 是 Qwen3.5 VLM 模型的推荐方法。model_merger路径主要用于遗留工作流。With mbridge: 与 mbridge 合作:
- Set
actor_rollout_ref.actor.megatron.use_mbridge=Trueduring training设置actor_rollout_ref.actor.megatron.use_mbridge=训练期间为真- Use mbridge's
save_hf_modelAPI directly to export to HuggingFace format直接使用 mbridge 的save_hf_modelAPI 导出为 HuggingFace 格式- No separate merger step needed无需单独的合并步骤
However, if you need to use
model_mergerfor existing checkpoints without mbridge:不过,如果你需要用model_merger来管理没有 mbridge 的现有检查点:
- Config access: Modify
megatron_model_merger.pyto handle nestedtext_config:**配置访问 **:修改megatron_model_merger.py以处理嵌套的 text_config:Instead of:
num_layers = self.hf_config.num_hidden_layers
Use:
num_layers = getattr(self.hf_config, 'num_hidden_layers', None) or
getattr(self.hf_config, 'text_config', {}).get('num_hidden_layers') 2. Registry support: AddQwen3_5ForConditionalGenerationto the registries**注册表支持 **:向注册表添加Qwen3_5ForConditionalGenerationThis is a valid gap in the merger support for newer VLM architectures. Consider contributing a PR if you implement the fix.这是新 VLM 架构合并支持中的一个有效空白。如果你实施修复,考虑贡献一个公共关系。
As @vermouth1992 mentioned, using mbridge is the recommended approach for Qwen3.5 VLM models. The
model_mergerpath is primarily for legacy workflows.With mbridge:
- Set
actor_rollout_ref.actor.megatron.use_mbridge=Trueduring training- Use mbridge's
save_hf_modelAPI directly to export to HuggingFace format- No separate merger step needed
However, if you need to use
model_mergerfor existing checkpoints without mbridge:
- Config access: Modify
megatron_model_merger.pyto handle nestedtext_config:Instead of:
num_layers = self.hf_config.num_hidden_layers
Use:
num_layers = getattr(self.hf_config, 'num_hidden_layers', None) or
getattr(self.hf_config, 'text_config', {}).get('num_hidden_layers') 2. Registry support: AddQwen3_5ForConditionalGenerationto the registriesThis is a valid gap in the merger support for newer VLM architectures. Consider contributing a PR if you implement the fix.
May I ask if you can share the MBridge merge script? My MBridge version is 0.15.1 and does not have the savehf_model API. I always encounter errors when using AutoBridge to merge