bridge.models.qwen_vl.modelling_qwen3_vl.mimo#

Carry Qwen3-VL DeepStack data in each MIMO context-parallel batch.

Module Contents#

Classes#

CombinedEmbeddingsWithDeepStackFeatures

Carry aligned token embeddings and auxiliary image rows into input preparation.

DeepStackContextParallelBatch

Keep rank-local image indices and differentiable features for one forward.

Qwen3VLMIMOVisionModel

Pack primary and DeepStack embeddings for the tensor-only image boundary.

Qwen3VLMIMOModel

Prepare aligned embeddings and DeepStack features for the language component.

API#

class bridge.models.qwen_vl.modelling_qwen3_vl.mimo.CombinedEmbeddingsWithDeepStackFeatures#

Carry aligned token embeddings and auxiliary image rows into input preparation.

embeddings: torch.Tensor#

None

deepstack_features: tuple[torch.Tensor, ...]#

None

property shape: torch.Size#

Return the aligned token shape used by MIMO forward logging.

class bridge.models.qwen_vl.modelling_qwen3_vl.mimo.DeepStackContextParallelBatch#

Bases: megatron.core.context_parallel.ContextParallelBatch

Keep rank-local image indices and differentiable features for one forward.

image_token_indices: torch.Tensor | None#

None

deepstack_features: tuple[torch.Tensor, ...]#

()

get_deepstack_inputs() → tuple[torch.Tensor | None, list[torch.Tensor] | None]#

Select this CP/SP rank’s image rows in local batch-major token order.

class bridge.models.qwen_vl.modelling_qwen3_vl.mimo.Qwen3VLMIMOVisionModel#

Bases: megatron.bridge.models.qwen_vl.modelling_qwen3_vl.vision_model.Qwen3VLVisionModel

Pack primary and DeepStack embeddings for the tensor-only image boundary.

forward(
hidden_states: torch.Tensor | None,
grid_thw: torch.Tensor,
inference_params: megatron.core.InferenceParams | None = None,
extra_block_kwargs: dict | None = None,
) → torch.Tensor#

Concatenate primary and auxiliary features along the hidden dimension.

class bridge.models.qwen_vl.modelling_qwen3_vl.mimo.Qwen3VLMIMOModel#

Bases: megatron.core.models.mimo.MimoModel

Prepare aligned embeddings and DeepStack features for the language component.

align_embeddings_by_token_positions(
modality_embeddings: dict[str, torch.Tensor],
input_ids: torch.Tensor,
special_token_ids: dict[str, int],
modality_token_indices: dict[str, torch.Tensor] | None = None,
) → torch.Tensor | bridge.models.qwen_vl.modelling_qwen3_vl.mimo.CombinedEmbeddingsWithDeepStackFeatures#

Pass primary embeddings and DeepStack metadata together to preparation.

_prepare_language_inputs(
embeddings: torch.Tensor | bridge.models.qwen_vl.modelling_qwen3_vl.mimo.CombinedEmbeddingsWithDeepStackFeatures | None,
input_ids: torch.Tensor | None,
position_ids: torch.Tensor | None,
labels: torch.Tensor | None,
loss_mask: torch.Tensor | None,
cu_seqlens: torch.Tensor | None,
cu_seqlens_padded: torch.Tensor | None,
max_seqlen: torch.Tensor | None,
owns_mtp: bool,
text_token_indices: torch.Tensor | None = None,
) → bridge.models.qwen_vl.modelling_qwen3_vl.mimo.DeepStackContextParallelBatch#

Partition image-token indices with the CP layout and SP split.

_forward_prepared_language_inputs(
cp_batch: bridge.models.qwen_vl.modelling_qwen3_vl.mimo.DeepStackContextParallelBatch,
attention_mask: torch.Tensor | None,
) → Any#

Forward language inputs and rank-local DeepStack features to the decoder.