bridge.recipes.qwen_vl.qwen3_vl#

Module Contents#

Classes#

Qwen3VLCommonKwargs

Typed options accepted by Qwen3 VL MoE recipe helpers.

Functions#

qwen3_vl_8b_pretrain_config

Return a pre-training config for Qwen3-VL 8B Instruct.

qwen3_vl_30b_a3b_pretrain_config

Return a pre-training config for Qwen3-VL-30B-A3B-Instruct.

qwen3_vl_235b_a22b_pretrain_config

Return a pre-training config for Qwen3-VL-235B-A22B-Instruct.

qwen3_vl_8b_finetune_config

Return a fine-tuning config for Qwen3-VL 8B Instruct.

qwen3_vl_30b_a3b_finetune_config

Return a fine-tuning config for Qwen3-VL-30B-A3B-Instruct.

qwen3_vl_235b_a22b_finetune_config

Return a fine-tuning config for Qwen3-VL-235B-A22B-Instruct.

_qwen3_vl_common

Create a pre-training configuration for Qwen3 MoE models using a given HuggingFace path.

API#

class bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs#

Bases: typing_extensions.TypedDict

Typed options accepted by Qwen3 VL MoE recipe helpers.

Initialization

Initialize self. See help(type(self)) for accurate signature.

hf_path: str#

None

dir: Optional[str]#

None

name: str#

None

data_paths: Optional[List[str]]#

None

data_args_path: Optional[str]#

None

train_data_path: Optional[List[str]]#

None

valid_data_path: Optional[List[str]]#

None

test_data_path: Optional[List[str]]#

None

per_split_data_args_path: Optional[str]#

None

mock: bool#

None

tensor_model_parallel_size: int#

None

pipeline_model_parallel_size: int#

None

pipeline_dtype: Optional[torch.dtype]#

None

virtual_pipeline_model_parallel_size: Optional[int]#

None

context_parallel_size: int#

None

expert_model_parallel_size: Optional[int]#

None

expert_tensor_parallel_size: int#

None

sequence_parallel: bool#

None

use_megatron_fsdp: bool#

None

enable_recompute: bool#

None

account_for_embedding_in_pipeline_split: bool#

None

account_for_loss_in_pipeline_split: bool#

None

train_iters: int#

None

global_batch_size: int#

None

micro_batch_size: int#

None

seq_length: int#

None

lr: float#

None

min_lr: float#

None

lr_warmup_iters: int#

None

lr_decay_iters: Optional[int]#

None

eval_interval: int#

None

save_interval: int#

None

use_null_tokenizer: bool#

None

precision_config: Optional[Union[megatron.bridge.training.mixed_precision.MixedPrecisionConfig, str]]#

None

comm_overlap_config: Optional[megatron.bridge.training.comm_overlap.CommOverlapConfig]#

None

moe_flex_dispatcher_backend: str | None#

None

pretrained_checkpoint: Optional[str]#

None

freeze_language_model: bool#

None

freeze_vision_model: bool#

None

freeze_vision_projection: bool#

None

dataset_type: Optional[str]#

None

image_folder: Optional[str]#

None

tokenizer_model: Optional[str]#

None

peft: Optional[Union[str, megatron.bridge.peft.base.PEFT]]#

None

finetune_lr: float#

None

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_8b_pretrain_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a pre-training config for Qwen3-VL 8B Instruct.

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_30b_a3b_pretrain_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a pre-training config for Qwen3-VL-30B-A3B-Instruct.

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_235b_a22b_pretrain_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a pre-training config for Qwen3-VL-235B-A22B-Instruct.

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_8b_finetune_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a fine-tuning config for Qwen3-VL 8B Instruct.

Default configuration: 1 node, 8 GPUs

  • LoRA/DoRA: TP=1, PP=1, LR=1e-4

  • Full SFT: TP=4, PP=1, LR=1e-5

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_30b_a3b_finetune_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a fine-tuning config for Qwen3-VL-30B-A3B-Instruct.

This is a Mixture-of-Experts model with 128 experts and top-8 routing. Recommended to use with expert parallelism (EP) for efficient training.

Default configuration: 1 node, 8 GPUs

  • LoRA/DoRA: TP=1, PP=1, EP=8, LR=2e-4

  • Full SFT: TP=1, PP=1, EP=8, LR=2e-5

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl.qwen3_vl_235b_a22b_finetune_config(
**user_kwargs: typing_extensions.Unpack[bridge.recipes.qwen_vl.qwen3_vl.Qwen3VLCommonKwargs],
) megatron.bridge.training.config.ConfigContainer#

Return a fine-tuning config for Qwen3-VL-235B-A22B-Instruct.

This is a Mixture-of-Experts model with 128 experts and top-8 routing. Recommended to use with expert parallelism (EP) for efficient training.

Default configuration: 4 nodes, 32 GPUs total

  • LoRA/DoRA: TP=1, PP=1, EP=8, LR=2e-4

  • Full SFT: TP=4, PP=1, EP=8, LR=2e-5

See _qwen3_vl_common for the full list of parameters.

bridge.recipes.qwen_vl.qwen3_vl._qwen3_vl_common(
hf_path: str,
dir: Optional[str] = None,
name: str = 'default',
data_paths: Optional[List[str]] = None,
data_args_path: Optional[str] = None,
train_data_path: Optional[List[str]] = None,
valid_data_path: Optional[List[str]] = None,
test_data_path: Optional[List[str]] = None,
per_split_data_args_path: Optional[str] = None,
mock: bool = False,
tensor_model_parallel_size: int = 4,
pipeline_model_parallel_size: int = 2,
pipeline_dtype: Optional[torch.dtype] = torch.bfloat16,
virtual_pipeline_model_parallel_size: Optional[int] = None,
context_parallel_size: int = 1,
expert_model_parallel_size: Optional[int] = 4,
expert_tensor_parallel_size: int = 1,
sequence_parallel: bool = False,
use_megatron_fsdp: bool = False,
enable_recompute: bool = False,
account_for_embedding_in_pipeline_split: bool = False,
account_for_loss_in_pipeline_split: bool = False,
train_iters: int = 300000,
global_batch_size: int = 32,
micro_batch_size: int = 2,
seq_length: int = 4096,
lr: float = 0.0003,
min_lr: float = 3e-05,
lr_warmup_iters: int = 500,
lr_decay_iters: Optional[int] = None,
eval_interval: int = 500,
save_interval: int = 500,
use_null_tokenizer: bool = False,
precision_config: Optional[Union[megatron.bridge.training.mixed_precision.MixedPrecisionConfig, str]] = None,
comm_overlap_config: Optional[megatron.bridge.training.comm_overlap.CommOverlapConfig] = None,
moe_flex_dispatcher_backend: Optional[str] = None,
pretrained_checkpoint: Optional[str] = None,
freeze_language_model: bool = True,
freeze_vision_model: bool = True,
freeze_vision_projection: bool = False,
dataset_type: Optional[str] = None,
image_folder: Optional[str] = None,
tokenizer_model: Optional[str] = None,
peft: Optional[Union[str, megatron.bridge.peft.base.PEFT]] = None,
finetune_lr: Optional[float] = None,
) megatron.bridge.training.config.ConfigContainer#

Create a pre-training configuration for Qwen3 MoE models using a given HuggingFace path.

Parameters:
  • hf_path (str) – HuggingFace model path (e.g., β€œQwen/Qwen3-30B-A3B”, β€œQwen/Qwen3-235B-A22B”).

  • dir (Optional[str]) – Base directory for saving logs and checkpoints.

  • name (str) – Name of the pre-training run.

  • data_paths (Optional[List[str]]) – List of paths to dataset files. If None, mock data will be used.

  • data_args_path (Optional[str]) – Path to file containing data arguments.

  • train_data_path (Optional[List[str]]) – List of training data paths.

  • valid_data_path (Optional[List[str]]) – List of validation data paths.

  • test_data_path (Optional[List[str]]) – List of test data paths.

  • per_split_data_args_path (Optional[str]) – Path to JSON file with per-split data configuration.

  • mock (bool) – Whether to use mock data. If True, ignores data_paths.

  • tensor_model_parallel_size (int) – Degree of tensor model parallelism.

  • pipeline_model_parallel_size (int) – Degree of pipeline model parallelism.

  • pipeline_dtype (Optional[torch.dtype]) – Data type for pipeline parallelism.

  • virtual_pipeline_model_parallel_size (Optional[int]) – Size of virtual pipeline parallelism.

  • context_parallel_size (int) – Degree of context parallelism to be passed to model_config.

  • expert_model_parallel_size (Optional[int]) – Degree of expert parallelism for MoE.

  • expert_tensor_parallel_size (int) – Expert tensor parallelism for MoE.

  • sequence_parallel (bool) – Whether to use sequence parallelism.

  • use_megatron_fsdp (bool) – Whether to use Megatron FSDP.

  • enable_recompute (bool) – Whether to enable recompute for memory optimization.

  • account_for_embedding_in_pipeline_split (bool) – Whether to account for embedding in pipeline split.

  • account_for_loss_in_pipeline_split (bool) – Whether to account for loss in pipeline split.

  • train_iters (int) – Total number of training iterations.

  • global_batch_size (int) – Global batch size for training.

  • micro_batch_size (int) – Micro batch size for training.

  • seq_length (int) – Sequence length for training data.

  • lr (float) – Learning rate.

  • min_lr (float) – Minimum learning rate for cosine decay.

  • lr_warmup_iters (int) – Number of warmup iterations for the learning rate.

  • lr_decay_iters (Optional[int]) – Number of iterations over which to decay the LR.

  • precision_config (Optional[Union[MixedPrecisionConfig, str]]) – Precision configuration for the model.

  • comm_overlap_config (Optional[CommOverlapConfig]) – Communication overlap configuration.

  • moe_flex_dispatcher_backend (str | None) – Token dispatcher type [deepep, hybridep].

  • pretrained_checkpoint (Optional[str]) – Path to pretrained checkpoint.

  • freeze_language_model (bool) – Whether to freeze the language model.

  • freeze_vision_model (bool) – Whether to freeze the vision model.

  • freeze_vision_projection (bool) – Whether to freeze the vision projection.

  • dataset_type (Optional[str]) – Type of dataset to use.

  • image_folder (Optional[str]) – Path to image folder.

  • tokenizer_model (Optional[str]) – Path to tokenizer model.

  • peft (Optional[Union[str, PEFT]]) – PEFT configuration (e.g., β€œlora”, β€œdora”, or PEFT object).

  • finetune_lr (Optional[float]) – Learning rate override for fine-tuning.

Returns:

Configuration for pre-training.

Return type:

ConfigContainer