bridge.models.gemma_vl.gemma4_vl_builder#

Model builders for Gemma 4 vision-language models.

Both builders construct the existing Gemma4VLModel as the legacy Gemma4VLModelProvider and Gemma4DenseVLProvider do: the Hugging Face vision (and audio) encoders first, then the language model from the Gemma 4 text builder.

Module Contents#

Classes#

Gemma4VLModelBuilder

Combine the Gemma 4 MoE language model with the Hugging Face vision encoder.

Gemma4DenseVLModelBuilder

Combine the Gemma 4 dense language model with the Hugging Face vision and audio encoders.

Functions#

Data#

API#

bridge.models.gemma_vl.gemma4_vl_builder._build_gemma4_vl_model(
model_config: megatron.bridge.models.gemma_vl.gemma4_vl_config.Gemma4VLModelConfig | megatron.bridge.models.gemma_vl.gemma4_vl_config.Gemma4DenseVLModelConfig,
build_language_model: collections.abc.Callable[..., megatron.core.models.gpt.GPTModel],
pg_collection: megatron.core.process_groups_config.ProcessGroupCollection,
pre_process: bool | None,
post_process: bool | None,
vp_stage: int | None,
) → megatron.bridge.models.gemma_vl.modeling_gemma4_vl.Gemma4VLModel#
class bridge.models.gemma_vl.gemma4_vl_builder.Gemma4VLModelBuilder#

Bases: megatron.bridge.models.gemma.gemma4_builder.Gemma4ModelBuilder

Combine the Gemma 4 MoE language model with the Hugging Face vision encoder.

build_model(
pg_collection: megatron.core.process_groups_config.ProcessGroupCollection,
pre_process: bool | None = None,
post_process: bool | None = None,
vp_stage: int | None = None,
) → megatron.bridge.models.gemma_vl.modeling_gemma4_vl.Gemma4VLModel#

Build one Gemma 4 MoE vision-language pipeline stage.

Parameters:
  • pg_collection – Process groups used for distributed construction.

  • pre_process – Whether this stage owns the embeddings and the vision encoder.

  • post_process – Whether this stage owns the language-model output layer.

  • vp_stage – Virtual pipeline stage.

Returns:

A Gemma 4 vision-language model stage.

Raises:
  • TypeError – If the builder was given another model config.

  • ValueError – If vision_config or text_config is unset.

class bridge.models.gemma_vl.gemma4_vl_builder.Gemma4DenseVLModelBuilder#

Bases: megatron.bridge.models.gemma.gemma4_builder.Gemma4DenseModelBuilder

Combine the Gemma 4 dense language model with the Hugging Face vision and audio encoders.

build_model(
pg_collection: megatron.core.process_groups_config.ProcessGroupCollection,
pre_process: bool | None = None,
post_process: bool | None = None,
vp_stage: int | None = None,
) → megatron.bridge.models.gemma_vl.modeling_gemma4_vl.Gemma4VLModel#

Build a Gemma 4 dense vision-language model.

Parameters:
  • pg_collection – Process groups used for distributed construction.

  • pre_process – Whether to build the embeddings and the vision encoder.

  • post_process – Whether to build the language-model output layer.

  • vp_stage – Virtual pipeline stage; Gemma 4 dense supports none.

Returns:

A Gemma 4 dense vision-language model.

Raises:
  • TypeError – If the builder was given another model config.

  • ValueError – If vision_config or text_config is unset.

bridge.models.gemma_vl.gemma4_vl_builder.__all__#

[‘Gemma4DenseVLModelBuilder’, ‘Gemma4VLModelBuilder’]