Repository navigation
feat(m3): add ModelConfig subclasses for all m3 model families - #6541
SurbhiJainUSC wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
a86b01a to
4e6accd
Compare
b12ac9c to
a39e923
Compare
a39e923 to
3dbbe2c
Compare
129c56f to
5190505
Compare
441a513 to
b230898
Compare
5190505 to
9ef85b8
Compare
aa59936 to
0689770
Compare
|
🤖 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 |
There was a problem hiding this comment.
📋 Review Summary
Verdict: Spec partially met; missing param_scan_axis overrides for m3 native checkpoints.
Top issues:
- 🔴 [Bug]
Qwen3ConfigandGlm5ModelConfigdo not declareparam_scan_axis: int = Field(0)or add it toto_pyconfig_dict(). They will inherit the base value of1, which breaks stacked m3-native checkpoints that expect0. → Add the field and dict entry (see inline comments). - 🟠 [Bug]
glm5.3-flash.ymlis missingparam_scan_axis: 0alongsideuse_m3_model: true. → Addparam_scan_axis: 0to the config YAML. - 🟠 [Bug]
Qwen3Configdoes not overridesupported_mesh_axes(), so it inherits the base set (which includesexpertandcontext). Qwen3 is a dense model and does not implement MoE experts. → Overridesupported_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
ModelConfigsubclasses for fivem3model 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] | test_supported_mesh_axes_match_model_registry |
|
[C2 (inferred): Configs set param_scan_axis to 0 for m3 checkpoint compatibility] |
❌ not met | ❌ none |
|
0689770 to
008a8f4
Compare
bvandermoon
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}, |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
Description
Stacked on #6539
Adds frozen, HuggingFace-native Pydantic v2
ModelConfigsubclasses for the fivem3model families and registers them inMODEL_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, subclassesQwen3Config)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-a400mandgranitemoealias)src/maxtext/m3/models/qwen3_8_flash_next/qwen3_8_config.py:Qwen3_8FlashNextConfig(qwen3.8-flash-next)src/maxtext/m3/models/registry.py: populatesMODEL_GARDEN_REGISTRYmatching the causal entries inMODEL_REGISTRYdrop routed_bias_update_rate: 0.0fromconfigs/models/glm5.3-flash.ymas it is a training setting (now on TrainingConfig); base.yml has the same 0.0 default, so behavior is unchanged.Tests
CI
Checklist