Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/fern/versions/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ navigation:
- page: "MiniMax-M3"
path: ../../model-coverage/vlm/minimax/minimax-m3.mdx
slug: minimax-m3
- page: "GLM-5.3-Flash"
path: ../../model-coverage/vlm/thudm/glm-5-3-flash.mdx
slug: glm-5-3-flash
- section: "Multimodal"
slug: multimodal
contents:
Expand Down
41 changes: 41 additions & 0 deletions docs/model-coverage/vlm/thudm/glm-5-3-flash.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: "GLM-5.3-Flash"
description: "Fine-tune the GLM-5.3-Flash mixture-of-experts vision-language model with packed context and expert parallelism."
slug: model-coverage/vision-language-models/thudm/glm-5-3-flash
---

[GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash) is a mixture-of-experts vision-language model with a hybrid Kimi Delta Attention and Dynamic Sparse Attention language backbone.

<Info>

| | |
|---|---|
| **Task** | Image-Text-to-Text |
| **Architecture** | `Glm5NextForConditionalGeneration` |
| **Language Module** | Hybrid KDA / KPool-DSA MoE decoder |
| **Training Precision** | BF16 after FP8 checkpoint dequantization |
| **HF Org** | [zai-org](https://huggingface.co/zai-org) |

</Info>

## Supported Training Path

NeMo AutoModel provides a native configuration, image processor, vision tower, language model, and Hugging Face state-dict adapter for GLM-5.3-Flash. The supported full-model initialization path loads the base checkpoint through distributed checkpointing; single-GPU full-checkpoint loading is not supported.

The current onboarding supports image training. Video inputs, tensor parallelism, and pipeline parallelism are not enabled for this model. The validated recipe uses FSDP2 with expert parallelism, contiguous packed context parallelism, and HybridEP dispatch.

## Attention Backends

- KDA layers use Flash Linear Attention kernels.
- Sparse DSA layers support the SDPA reference path.
- On SM90 or later, `backend.attn: cudnn` uses FlashMLA forward with cuDNN sparse-attention backward. This optional path requires compatible FlashMLA and cuDNN Frontend installations.

## Example Recipe

- [Full SFT — MedPix, packed 2K, EP72 + CP2](https://github.com/NVIDIA-NeMo/Automodel/blob/main/examples/vlm_finetune/glm5_next/glm5_3_flash_medpix_packed2k_ep72_cp2_100steps.yaml)

The recipe is sized for 9 nodes with 8 GPUs per node. It uses local batch size 1 and four gradient-accumulation microsteps to form a global batch of 144 packed samples.

## Hugging Face Model Card

- [zai-org/GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash)
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Validated 9-node/72-GPU packed MedPix run for GLM-5.3-Flash. CP2 gives DP36;
# EP72 spans the dp(36) x cp(2) mesh and stores four of 288 routed experts per
# GPU. Four accumulation microsteps form each 144-pack optimizer step. TP and PP
# remain disabled.

recipe: FinetuneRecipeForVLM
seed: 1234

step_scheduler:
global_batch_size: 144
local_batch_size: 1
ckpt_every_steps: 1000
val_every_steps: 1000
log_remote_every_steps: 1
gc_every_steps: 5
num_epochs: 4
max_steps: 100

dist_env:
backend: nccl
timeout_minutes: 120

rng:
_target_: nemo_automodel.components.training.rng.StatefulRNG
seed: 1234
ranked: true
deterministic: true

model:
_target_: nemo_automodel.NeMoAutoModelForImageTextToText.from_pretrained
pretrained_model_name_or_path: zai-org/GLM-5.3-Flash
torch_dtype: bfloat16
attn_implementation: sdpa
use_liger_kernel: false
use_sdpa_patching: false
text_config:
output_hidden_states: true
num_nextn_predict_layers: 0
backend:
_target_: nemo_automodel.components.models.common.BackendConfig
# KDA layers remain on FLA; this selects cuDNN/FlashMLA for sparse MLA layers.
attn: cudnn
linear: torch
rms_norm: torch_fp32
experts: torch_mm
dispatcher: hybridep
rope_fusion: false
gate_precision: float32
fake_balanced_gate: false
enable_hf_state_dict_adapter: true
enable_fsdp_optimizations: true

processor:
_target_: nemo_automodel.components.models.glm5_next.processing.build_glm5_next_processor
pretrained_model_name_or_path: zai-org/GLM-5.3-Flash
trust_remote_code: false

checkpoint:
enabled: false
checkpoint_dir: checkpoints/glm5_3_flash_medpix_packed2k_ep72_cp2_100steps/
model_save_format: safetensors
save_consolidated: false
dequantize_base_checkpoint: true

distributed:
strategy: fsdp2
tp_size: 1
cp_size: 2
pp_size: 1
ep_size: 72
sequence_parallel: false
activation_checkpointing: true
# Avoid retaining a full accumulated gradient set across four microsteps.
defer_fsdp_grad_sync: false
moe:
reshard_after_forward: false
wrap_outer_model: true
ignore_router_for_ac: true

freeze_config:
freeze_embeddings: true
freeze_vision_tower: true
freeze_audio_tower: true
freeze_language_model: false

loss_fn:
_target_: nemo_automodel.components.loss.linear_ce.FusedLinearCrossEntropy

dataset:
_target_: nemo_automodel.components.datasets.vlm.datasets.make_medpix_dataset
path_or_dataset: mmoukouba/MedPix-VQA
split: train

packed_sequence:
pretokenize: true
max_length: 2048
pack_size: 2048
collate_max_length: 2048
packing_ratio: 0.9
drop_long_samples: true
balance_media_tokens: true
packing_format: neat
attn_implementation: sdpa

dataloader:
_target_: torchdata.stateful_dataloader.StatefulDataLoader
num_workers: 1
persistent_workers: true
pin_memory: true
drop_last: true

validation_dataset: none
validation_dataloader: none

optimizer:
_target_: torch.optim.AdamW
betas: [0.9, 0.95]
eps: 1e-8
lr: 5.0e-6
weight_decay: 0.1

lr_scheduler:
lr_decay_style: constant

clip_grad_norm:
max_norm: 1.0

wandb:
enable: false
project: huiyingl_workspace
entity: Nemo-automodel
name: glm5_3_flash_medpix_packed2k_ep72_cp2_100steps
group: glm5_3_flash_medpix_packed2k_cp_parity_100steps
tags: [glm5.3-flash, medpix, vlm, packed2k, ep72, cp2, parity]
dir: logs/glm5_3_flash_medpix_packed2k_ep72_cp2_100steps/wandb

ci:
recipe_owner: HuiyingLi
nodes: 9
time: "01:00:00"
max_steps: 5
8 changes: 8 additions & 0 deletions nemo_automodel/_transformers/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
"GlmMoeDsaForCausalLM",
("nemo_automodel.components.models.glm_moe_dsa.model", "GlmMoeDsaForCausalLM"),
),
(
"Glm5NextForConditionalGeneration",
(
"nemo_automodel.components.models.glm5_next.model",
"Glm5NextForConditionalGeneration",
),
),
(
"Gemma4ForConditionalGeneration",
("nemo_automodel.components.models.gemma4_moe.model", "Gemma4ForConditionalGeneration"),
Expand Down Expand Up @@ -326,6 +333,7 @@
"bailing_moe": ("nemo_automodel.components.models.ling_v2.config", "BailingMoeV2Config"),
"deepseek_v4": ("nemo_automodel.components.models.deepseek_v4.config", "DeepseekV4Config"),
"glm_moe_dsa": ("nemo_automodel.components.models.glm_moe_dsa.config", "GlmMoeDsaConfig"),
"glm5_next": ("nemo_automodel.components.models.glm5_next.config", "Glm5NextConfig"),
"hy_v3": ("nemo_automodel.components.models.hy_v3.config", "HYV3Config"),
"inkling_mm_model": ("nemo_automodel.components.models.inkling.configuration", "InklingConfig"),
"kimi_k2": ("nemo_automodel.components.models.kimi_k2.config", "KimiK2Config"),
Expand Down
Loading
Loading