hengtaoguo-exp5 - #5146
Conversation
There was a problem hiding this comment.
Code Review
This pull request successfully onboards the text-only Qwen3.8-27B model to MaxText, introducing its configuration, registering its model name and Hugging Face ID, and updating the parameter mapping and hooks to support dense MLPs when the number of experts is one or fewer. Additionally, the Qwen3.5 decoder layer was updated to conditionally instantiate either a sparse MoE block or a dense MLP block, and a KV cache dtype mismatch was resolved. The review feedback suggests adding defensive checks in the decoder layer to ensure num_experts is not None before performing comparisons, thereby preventing potential runtime TypeError exceptions.
| # Instantiate our `Qwen3_5SparseMoEBlock`. | ||
| self.mlp = Qwen3_5SparseMoEBlock(config=cfg, mesh=self.mesh, quant=self.quant, rngs=rngs) | ||
| # Conditionally instantiate MoE or dense MLP. | ||
| if getattr(cfg, "num_experts", 1) > 1: |
There was a problem hiding this comment.
To prevent potential TypeError exceptions during configuration parsing or testing, it is safer to perform a defensive check to ensure num_experts is not None before comparing it.
| if getattr(cfg, "num_experts", 1) > 1: | |
| num_experts = getattr(cfg, "num_experts", 1) | |
| if num_experts is not None and num_experts > 1: |
| if self.config.load_balance_loss_weight > 0.0 and load_balance_loss is not None: | ||
| self.sow(nnx.Intermediate, "moe_lb_loss", load_balance_loss) | ||
| # Instantiate and call our MLP / MoE block. | ||
| if getattr(self.config, "num_experts", 1) > 1: |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Description
Start with a short description of what the PR does and how this is a change from
the past.
The rest of the description includes relevant details and context, examples:
If the change fixes a bug or a Github issue, please include a link, e.g.,:
FIXES: b/123456
FIXES: #123456
You can also provide a comma-separated list. If you don't want to close a bug but
simply to reference it, use BUGS, e.g.:
BUGS: b/123456
Notice 1: Once all tests pass, the "pull ready" label will automatically be assigned.
This label is used for administrative purposes. Please do not add it manually.
Notice 2: For external contributions, our settings currently require an approval from a MaxText maintainer to trigger CI tests.
Tests
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.