Skip to content

[No merge] Draft test - #4747

Draft
NuojCheng wants to merge 8 commits into
mainfrom
chengnuojin-bharatgen
Draft

[No merge] Draft test#4747
NuojCheng wants to merge 8 commits into
mainfrom
chengnuojin-bharatgen

Conversation

@NuojCheng

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

Please describe how you tested this change, and include any instructions and/or
commands to reproduce.

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.

@NuojCheng
NuojCheng force-pushed the chengnuojin-bharatgen branch from b6a5380 to cfffd6c Compare August 5, 2026 20:30

@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 introduces support for the Qwen3-Next 80B model, including scanned decoder blocks, hybrid Gated Delta Net (GDN) implementations utilizing Tokamax GDN v3, benchmark scripts, and corresponding unit tests. Key feedback highlights several critical issues: hardcoded absolute user paths in the run scripts that hinder portability, missing imports (math and cast) in qwen3.py, an invalid unroll=0 parameter in jax.lax.scan, a potential ConcretizationTypeError from casting JAX tracers to Python integers, a slicing bug in hybrid_gdn.py when the convolution kernel size is 1, and an argparse configuration issue in the benchmark script.

I am having trouble creating individual review comments. Click here to see my feedback.

run_qwen3_80b_aot.sh (5)

high

The script contains a hardcoded absolute path to a specific user's home directory (/usr/local/google/home/chengnuojin/.venv/bin/activate). This makes the script non-portable and will fail for other users or in automated CI/CD environments. Please use a relative path or an environment variable (such as $HOME) to locate the virtual environment.

source "$HOME/.venv/bin/activate"

run_qwen3_80b_xpk.sh (5)

high

The script contains a hardcoded absolute path to a specific user's home directory (/usr/local/google/home/chengnuojin/.venv/bin/activate). This makes the script non-portable and will fail for other users or in automated CI/CD environments. Please use a relative path or an environment variable (such as $HOME) to locate the virtual environment.

source "$HOME/.venv/bin/activate"

run_qwen3_80b_xpk.sh (29)

high

The script contains a hardcoded absolute path to a specific user's directory (/usr/local/google/home/chengnuojin/maxtext). This makes the script non-portable. Please use a relative path or an environment variable (such as $HOME) instead.

  cd "$HOME/maxtext" && \

run_qwen3_80b_xpk.sh (165)

high

The script contains a hardcoded absolute path to a specific user's directory (/usr/local/google/home/chengnuojin/xpk/src). This makes the script non-portable. Please use a relative path or an environment variable (such as $HOME) instead.

PYTHONPATH="$HOME/xpk/src" python3 -m xpk.main workload create \

src/maxtext/models/qwen3.py (25-30)

high

The standard library math module is used in this file (e.g., math.ceil, math.log2, and math.prod) but is not imported, which will raise a NameError at runtime. Please add import math to the imports.

import math
import jax.nn
from jax import lax
from jax.ad_checkpoint import checkpoint_name
from jax.experimental import xla_metadata
from jax.sharding import Mesh
import jax.numpy as jnp

src/maxtext/models/qwen3.py (38-43)

high

The cast function from the typing module is used in this file (e.g., lines 1628 and 1638) but is not imported, which will raise a NameError at runtime. Please add cast to the typing imports.

from typing import cast
from maxtext.layers import attentions
from maxtext.layers import initializers as max_initializers
from maxtext.layers import moe
from maxtext.layers import mhc
from maxtext.common.common_types import HyperConnectionType
from maxtext.layers import nnx_scan, nnx_wrappers

benchmarks/benchmark_all_gather_v5p_v7x.py (135-140)

medium

Using action="store_true" with default=True in argparse makes it impossible to set the value to False via the command line (since specifying the flag will just set it to True again). To allow users to disable SparseCore offload, use action=argparse.BooleanOptionalAction (which automatically adds --sc_offload and --no-sc_offload flags) or change the flag to --no-sc_offload with action="store_false".

  parser.add_argument(
      "--sc_offload",
      action=argparse.BooleanOptionalAction,
      default=True,
      help="Whether SparseCore offload is enabled",
  )

src/maxtext/models/qwen3.py (176)

medium

In JAX, the unroll parameter of jax.lax.scan must be a positive integer (>= 1) or a boolean. Passing unroll=0 is invalid and may raise a ValueError or be ignored depending on the JAX version. To specify no unrolling, use unroll=1 or unroll=False.

  final_state, core_attn_out_stacked = jax.lax.scan(scan_body, last_recurrent_state, xs, unroll=1)

src/maxtext/models/qwen3.py (2506-2508)

medium

If video_grid_thw is a JAX Array (which is typical for dynamic inputs in MaxText), calling int(dim) on its elements during JIT compilation will raise a ConcretizationTypeError because JAX tracers cannot be converted to concrete Python integers. If video_grid_thw is expected to be a JAX Array, please avoid int(dim) and instead use JAX-compatible operations, or ensure that video_grid_thw is passed as a static Python/NumPy structure.

src/maxtext/models/hybrid_gdn.py (94)

medium

If conv_kernel_size is 1, conv_kernel_size - 1 is 0. In Python/JAX, slicing with -0 (i.e., qkv[:, -0:, :]) is equivalent to qkv[:, 0:, :], which returns the entire qkv tensor instead of an empty tensor of shape (batch, 0, dim). To prevent this slicing bug when conv_kernel_size is 1, please explicitly check if conv_kernel_size > 1.

    next_conv_state = qkv[:, -(conv_kernel_size - 1):, :] if conv_kernel_size > 1 and seq_len >= conv_kernel_size - 1 else jnp.zeros((batch, conv_kernel_size - 1, qkv.shape[-1]), dtype=qkv.dtype)

@NuojCheng
NuojCheng force-pushed the chengnuojin-bharatgen branch from 37413b8 to 5d1a147 Compare August 6, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants