Skip to content

Commit afa68f1

Browse files
committed
Multimodal Megatron inference + RL dev branch.
Signed-off-by: Cory Ye <cye@nvidia.com>
1 parent babf953 commit afa68f1

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/megatron/bridge/inference/vlm/qwenvl_inference_wrapper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class QwenVLInferenceWrapper(AbstractModelInferenceWrapper):
3737
model (Qwen2VLModel): The Qwen2VL model
3838
"""
3939

40+
supports_text = True
41+
supports_image = True
42+
supports_video = False
43+
supports_audio = False
44+
4045
def __init__(self, model, inference_context=None):
4146
super().__init__(model, inference_context=inference_context)
4247

src/megatron/bridge/models/nemotron_omni/modeling_nemotron_omni.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ def __init__(
191191
self.post_process = post_process
192192
self.add_encoder = add_encoder
193193
self.add_decoder = add_decoder
194+
# Inference controllers inspect the top-level model for the padded
195+
# vocabulary size. Keep it consistent with the nested HybridModel.
196+
self.vocab_size = language_vocab_size
194197
self.image_token_index = image_token_index
195198
self.sound_token_index = sound_token_index
196199
self.patch_dim = patch_dim

src/megatron/bridge/models/nemotron_omni/nemotron_omni_bridge.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,16 @@ def stream_weights_megatron_to_hf(
319319
state = StateDict(source)
320320
source_keys = set(source.get_all_keys())
321321
for name in self._HF_PASSTHROUGH_KEYS:
322-
if name in source_keys:
323-
yield from HFWeightTuple(name, state[name]).iter_finalized(cpu=cpu)
322+
if name not in source_keys:
323+
continue
324+
tensor = state[name]
325+
# These come straight off disk, so they are on CPU while every
326+
# mapped tensor in the stream above is on the current device when
327+
# cpu=False. Consumers that batch the whole stream together (RL
328+
# refit packs it into one buffer) cannot mix devices.
329+
if not cpu and tensor.device.type == "cpu" and torch.cuda.is_available():
330+
tensor = tensor.to(device=torch.cuda.current_device())
331+
yield from HFWeightTuple(name, tensor).iter_finalized(cpu=cpu)
324332

325333

326334
class NemotronOmniLlavaBridge(NemotronOmniBridge):

0 commit comments

Comments
 (0)