Skip to content

hengtaoguo-exp5 - #5146

Draft
hengtaoguo wants to merge 1 commit into
mainfrom
hengtaoguo-exp5
Draft

hengtaoguo-exp5#5146
hengtaoguo wants to merge 1 commit into
mainfrom
hengtaoguo-exp5

Conversation

@hengtaoguo

@hengtaoguo hengtaoguo commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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:

  • why is this change being made,
  • the problem being solved and any relevant context,
  • why this is a good solution,
  • some information about the specific implementation,
  • shortcomings of the solution and possible future improvements.

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

python -m maxtext.inference.decode src/maxtext/configs/base.yml run_name=vllm_decode_qwen3_vl model_name=qwen3.8-27b tokenizer_path=Qwen/Qwen3.8-27B base_output_directory=gs://hengtaoguo-maxtext-logs/checkpoints/qwen3.8-27b/unscanned/2026-09-04/0/items tokenizer_type=huggingface prompt=\'Paris\ is\ the\' max_prefill_predict_length=16 max_target_length=32 per_device_batch_size=1 ici_tensor_parallelism=4 scan_layers=false weight_dtype=bfloat16 hf_access_token=xxx

Input `Paris is the` -> ` capital of France and the largest city in the country. It is located in the north`

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, perform a defensive check here to ensure num_experts is not None before comparing it to prevent potential runtime crashes.

    num_experts = getattr(self.config, "num_experts", 1)
    if num_experts is not None and num_experts > 1:

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 17.64706% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...xtext/checkpoint_conversion/utils/param_mapping.py 0.00% 20 Missing ⚠️
src/maxtext/models/qwen3_5.py 33.33% 3 Missing and 3 partials ⚠️
...xt/checkpoint_conversion/utils/hf_model_configs.py 60.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant