Skip to content

feat(m3): add ModelConfig subclasses for all m3 model families - #6541

Open
SurbhiJainUSC wants to merge 1 commit into
m3-configsfrom
m3-model-configs
Open

SurbhiJainUSC wants to merge 1 commit into
m3-configsfrom
m3-model-configs

Conversation

@SurbhiJainUSC

@SurbhiJainUSC SurbhiJainUSC commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Stacked on #6539

Adds frozen, HuggingFace-native Pydantic v2 ModelConfig subclasses for the five m3 model families and registers them in MODEL_GARDEN_REGISTRY:

  • src/maxtext/m3/models/qwen3/qwen3_config.py: Qwen3Config (qwen3-0.6b)
  • src/maxtext/m3/models/qwen3_vl/qwen3_vl_config.py: Qwen3VLConfig (qwen3-vl-2b, subclasses Qwen3Config)
  • src/maxtext/m3/models/glm5_3_flash/glm5_config.py: Glm5ModelConfig (glm5.3-flash)
  • src/maxtext/m3/models/granitemoe/granitemoe_config.py: GraniteMoeModelConfig (granite-3.0-1b-a400m and granitemoe alias)
  • src/maxtext/m3/models/qwen3_8_flash_next/qwen3_8_config.py: Qwen3_8FlashNextConfig (qwen3.8-flash-next)
  • src/maxtext/m3/models/registry.py: populates MODEL_GARDEN_REGISTRY matching the causal entries in MODEL_REGISTRY

drop routed_bias_update_rate: 0.0 from configs/models/glm5.3-flash.ym as it is a training setting (now on TrainingConfig); base.yml has the same 0.0 default, so behavior is unchanged.

Tests

CI

Checklist

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

@github-actions github-actions Bot added the skip-ci-tests Add this label to the PR to skip running CI tests label Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@SurbhiJainUSC
SurbhiJainUSC changed the base branch from main to m3-configs November 25, 2026 00:34
@SurbhiJainUSC
SurbhiJainUSC force-pushed the m3-model-configs branch 4 times, most recently from b12ac9c to a39e923 Compare November 25, 2026 00:46
@SurbhiJainUSC
SurbhiJainUSC force-pushed the m3-configs branch 2 times, most recently from 129c56f to 5190505 Compare November 25, 2026 06:47
@SurbhiJainUSC
SurbhiJainUSC force-pushed the m3-model-configs branch 4 times, most recently from 441a513 to b230898 Compare November 25, 2026 19:55
@SurbhiJainUSC
SurbhiJainUSC force-pushed the m3-model-configs branch 2 times, most recently from aa59936 to 0689770 Compare November 25, 2026 20:13
@SurbhiJainUSC
SurbhiJainUSC marked this pull request as ready for review November 25, 2026 20:14
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @SurbhiJainUSC, I'm running an automatic MaxText review of this pull request. You can track my progress in the logs. To request another review later, add the gemini-review label or comment @gemini-cli /review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

Verdict: Spec partially met; missing param_scan_axis overrides for m3 native checkpoints.

Top issues:

  1. 🔴 [Bug] Qwen3Config and Glm5ModelConfig do not declare param_scan_axis: int = Field(0) or add it to to_pyconfig_dict(). They will inherit the base value of 1, which breaks stacked m3-native checkpoints that expect 0. → Add the field and dict entry (see inline comments).
  2. 🟠 [Bug] glm5.3-flash.yml is missing param_scan_axis: 0 alongside use_m3_model: true. → Add param_scan_axis: 0 to the config YAML.
  3. 🟠 [Bug] Qwen3Config does not override supported_mesh_axes(), so it inherits the base set (which includes expert and context). Qwen3 is a dense model and does not implement MoE experts. → Override supported_mesh_axes() returning only the supported dense axes (see inline comment).
Inferred spec & validation
  • Sources: PR description, code before/after.
  • Problem: Adding missing frozen HuggingFace-native Pydantic ModelConfig subclasses for five m3 model families.
Spec item Implementation Validating test
[R1 (stated): Add ModelConfig subclasses for all 5 m3 families] ✅ tests/unit/m3/model_config_test.py::test_registry_matches_m3_model_registry ✅
[R2 (stated): Register them in MODEL_GARDEN_REGISTRY] ✅ test_registry_matches_m3_model_registry ✅
[C1 (inferred): Configs correctly expose their mesh divisibility constraints and supported axes] ⚠️ partial test_supported_mesh_axes_match_model_registry ⚠️ superficial (inherits overly broad base default for dense models)
[C2 (inferred): Configs set param_scan_axis to 0 for m3 checkpoint compatibility] ❌ not met ❌ none

@SurbhiJainUSC SurbhiJainUSC removed the skip-ci-tests Add this label to the PR to skip running CI tests label Nov 25, 2026
@SurbhiJainUSC

Copy link
Copy Markdown
Collaborator Author

📋 Review Summary

Verdict: Spec partially met; missing param_scan_axis overrides for m3 native checkpoints.

Top issues:

  1. 🔴 [Bug] Qwen3Config and Glm5ModelConfig do not declare param_scan_axis: int = Field(0) or add it to to_pyconfig_dict(). They will inherit the base value of 1, which breaks stacked m3-native checkpoints that expect 0. → Add the field and dict entry (see inline comments).
  2. 🟠 [Bug] glm5.3-flash.yml is missing param_scan_axis: 0 alongside use_m3_model: true. → Add param_scan_axis: 0 to the config YAML.
  3. 🟠 [Bug] Qwen3Config does not override supported_mesh_axes(), so it inherits the base set (which includes expert and context). Qwen3 is a dense model and does not implement MoE experts. → Override supported_mesh_axes() returning only the supported dense axes (see inline comment).

Inferred spec & validation

param_scan_axis: 0 isn't an m3-wide rule. Granite and Qwen3.8 use it (and already export it) because their checkpoint mappings are written for it. Qwen3 must stay on base.yml's 1 because it shares legacy MaxText's scanned checkpoint layout. GLM-5 stacks its layers itself and ignores the field. The YAML parity test pins each family to its current YAML, so this PR doesn't change any scan layout.

@bvandermoon bvandermoon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! A few small validation nits below, fine to clean up here or in a follow-up.

hc_sinkhorn_iters: int = Field(20, gt=0)
hc_eps: float = Field(1e-6, gt=0.0)
rms_norm_eps: float = Field(1e-5, gt=0.0)
tie_word_embeddings: bool = False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glm5Config doesn't support tied embeddings (to_glm5_config drops this), so Literal[False] = False or rejecting True would avoid silently ignoring it.

raise ValueError(f"linear_lower_bound cannot be None when kda_implementation={self.kda_implementation!r}.")
if not 1 <= self.num_experts_per_tok <= self.n_routed_experts:
raise ValueError(f"num_experts_per_tok ({self.num_experts_per_tok}) must be in [1, {self.n_routed_experts}].")
return self

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth checking first_k_dense_replace <= num_hidden_layers here too since modeling_glm5_3_flash.py rejects it at init.

def mesh_divisibility_constraints(self) -> dict[str, dict[str, int]]:
"""Returns dims that must divide evenly by the `tensor` and `expert` mesh axis sizes."""
return {
"tensor": {"num_attention_heads": self.num_attention_heads, "num_key_value_heads": self.num_key_value_heads},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linear_num_key_heads is also sharded on tensor (A_log), worth adding here.

f"linear_num_value_heads ({self.linear_num_value_heads}) must be divisible by "
f"linear_num_key_heads ({self.linear_num_key_heads})."
)
if self.eos_token_id >= self.vocab_size:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate this on self.use_ple_layer (like ple_layer_id above) so shrinking vocab_size with PLE off doesn't require also overriding eos_token_id.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants