Skip to content

fix: guard PRE_MLP NVFP4 fusion for dense layers - #17191

Open
zcxGGmu wants to merge 6 commits into
NVIDIA:mainfrom
zcxGGmu:fix/pre-mlp-nvfp4-unquantized-dense
Open

fix: guard PRE_MLP NVFP4 fusion for dense layers#17191
zcxGGmu wants to merge 6 commits into
NVIDIA:mainfrom
zcxGGmu:fix/pre-mlp-nvfp4-unquantized-dense

Conversation

@zcxGGmu

@zcxGGmu zcxGGmu commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • Guard GLM and ExaOne dense PRE_MLP NVFP4 fusion with the final gate_up_proj.has_nvfp4 module state.
  • Fall back to the regular residual RMSNorm allreduce when dense MLP weights are excluded from NVFP4 quantization.
  • Add a lightweight regression test covering DeepSeekV3, GLM, and ExaOne PRE_MLP fusion guards.

Fixes #15516

Test Plan

  • python -m pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q
  • python -m ruff check tensorrt_llm/_torch/models/modeling_glm.py tensorrt_llm/_torch/models/modeling_exaone_moe.py tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py
  • python -m py_compile tensorrt_llm/_torch/models/modeling_glm.py tensorrt_llm/_torch/models/modeling_exaone_moe.py tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

Dev Engineer Review

  • GLM and ExaOne guard PRE_MLP NVFP4 fusion with has_nvfp4.
  • Unquantized dense MLP layers use the standard RESIDUAL_RMS_NORM path.
  • The fallback avoids invalid input_scale access.
  • AST-based checks cover DeepSeekV3, GLM, and ExaOne.
  • Both test-list entries use the correct path with no duplicates.
  • Targeted validation passed.
  • Verdict: sufficient.

QA Engineer Review

  • Added test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp, parameterized for DeepSeekV3, GLM, and ExaOne.
  • Added test_forward_mlp_has_nvfp4_branch_supports_alias_and_getattr.
  • Both tests are covered in:
    • tests/integration/test_lists/test-db/l0_cpu_arm.yml
    • tests/integration/test_lists/test-db/l0_cpu_x86.yml
  • Targeted pytest runs passed.
  • Verdict: sufficient.

Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu
zcxGGmu requested a review from a team as a code owner August 3, 2026 07:25
@zcxGGmu
zcxGGmu requested a review from aswinvisva August 3, 2026 07:25
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The Exaone-MoE and GLM MLP paths now select quantized or standard residual RMSNorm fusion from gate_up_proj.has_nvfp4. AST tests validate both branches and run in the ARM and x86 CPU pre-merge suites.

Changes

NVFP4 pre-MLP fusion

Layer / File(s) Summary
Per-projection fusion branching
tensorrt_llm/_torch/models/modeling_exaone_moe.py, tensorrt_llm/_torch/models/modeling_glm.py
forward_mlp uses quantized residual RMSNorm and Fp4QuantizedTensor only for NVFP4 projections. Other projections use unquantized residual RMSNorm.
Fusion guard validation
tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py, tests/integration/test_lists/test-db/l0_cpu_arm.yml, tests/integration/test_lists/test-db/l0_cpu_x86.yml
AST helpers and tests verify NVFP4 and fallback branches, including aliased getattr checks. The test runs in both CPU pre-merge suites.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: qijune, bowenfu, aswinvisva

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: guarding PRE_MLP NVFP4 fusion for dense layers.
Description check ✅ Passed The description explains the bug and solution and lists targeted regression tests, although it does not reproduce every template heading or checklist item.
Linked Issues check ✅ Passed The changes address issue #15516 by guarding dense-layer NVFP4 fusion and preserving the regular residual RMSNorm fallback path.
Out of Scope Changes check ✅ Passed The model changes, regression tests, and CPU test-list updates are directly related to the linked issue and stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/pre-mlp-nvfp4-unquantized-dense
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py`:
- Around line 40-41: Strengthen the test around the guarded pre-MLP behavior by
verifying that `input_scale` is accessed only within the true `has_nvfp4`
branch, rather than relying on source-text ordering. Also exercise the false
`has_nvfp4` path with a raising `input_scale` sentinel and assert the
`RESIDUAL_RMS_NORM` fallback behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5280d550-7e2a-4ed6-90b4-2161dcd865e1

📥 Commits

Reviewing files that changed from the base of the PR and between 93e7c91 and 1d01e7a.

📒 Files selected for processing (3)
  • tensorrt_llm/_torch/models/modeling_exaone_moe.py
  • tensorrt_llm/_torch/models/modeling_glm.py
  • tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

Comment thread tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py Outdated
Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu

zcxGGmu commented Aug 5, 2026

Copy link
Copy Markdown
Author

Thanks for the review — I pushed 27d8384a6 addressing the feedback.

Changes made:

  • Replaced the source-text ordering check with an AST-based guard over the three affected model files.
  • The test now asserts input_scale and RESIDUAL_RMS_NORM_QUANT_NVFP4 are only present on the true has_nvfp4 branch.
  • The false branch is now checked to avoid input_scale / NVFP4 quant fusion and to retain the RESIDUAL_RMS_NORM fallback.

Validation:

  • Temporary mutation guard — injecting scale=self.mlp.gate_up_proj.input_scale into the false branch made the test fail as expected, then restoring the source made it pass.
  • pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q — passed, 3 tests; emitted the existing isolated-config warnings for unknown pytest options.
  • git diff --check — passed.
  • Added-line secret scan — passed, no credential-like additions.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py (1)

37-47: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Scope the AST lookup to the PRE_MLP fusion branch.

_forward_mlp_has_nvfp4_branch() returns the first matching has_nvfp4 branch in forward_mlp. It does not verify that the branch is nested under self.fusion_config.PRE_MLP_FUSION. A later unrelated branch could satisfy the test while PRE_MLP fusion is unguarded. Restrict the search to the expected outer branch before scanning its children.

This keeps the regression check tied to the PRE_MLP fusion requirement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py` around lines 37
- 47, Update _forward_mlp_has_nvfp4_branch to first locate the
self.fusion_config.PRE_MLP_FUSION outer branch within forward_mlp, then search
only that branch’s descendants for self.mlp.gate_up_proj.has_nvfp4. Return the
matching ast.If and fail the assertion if the expected PRE_MLP branch or nested
NVFP4 guard is absent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py`:
- Around line 58-69: Add test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp
to a suitable CI and QA test-list entry under
tests/integration/test_lists/test-db, ensuring all three model parameters are
covered. Then run pytest tests/unittest/ to validate the updated coverage.

---

Nitpick comments:
In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py`:
- Around line 37-47: Update _forward_mlp_has_nvfp4_branch to first locate the
self.fusion_config.PRE_MLP_FUSION outer branch within forward_mlp, then search
only that branch’s descendants for self.mlp.gate_up_proj.has_nvfp4. Return the
matching ast.If and fail the assertion if the expected PRE_MLP branch or nested
NVFP4 guard is absent.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0669592d-7a22-4622-9391-27e7cc5b4cd3

📥 Commits

Reviewing files that changed from the base of the PR and between 1d01e7a and 27d8384.

📒 Files selected for processing (1)
  • tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

Comment on lines +58 to +69
def test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp(model_file: str) -> None:
nvfp4_branch = _forward_mlp_has_nvfp4_branch(model_file)

assert _contains_attribute(nvfp4_branch, "self.mlp.gate_up_proj.input_scale")
assert _contains_attribute(nvfp4_branch, "AllReduceFusionOp.RESIDUAL_RMS_NORM_QUANT_NVFP4")

for false_branch_node in nvfp4_branch.orelse:
assert not _contains_attribute(false_branch_node, "self.mlp.gate_up_proj.input_scale")
assert not _contains_attribute(false_branch_node, "AllReduceFusionOp.RESIDUAL_RMS_NORM_QUANT_NVFP4")
assert any(
_contains_attribute(false_branch_node, "AllReduceFusionOp.RESIDUAL_RMS_NORM")
for false_branch_node in nvfp4_branch.orelse)

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

test_name='test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp'
test_file='test_pre_mlp_nvfp4_fusion.py'

for list_dir in \
    tests/integration/test_lists/test-db \
    tests/integration/test_lists/qa; do
    echo "== $list_dir =="
    rg -n --fixed-strings "$test_name" "$list_dir" || true
    rg -n --fixed-strings "$test_file" "$list_dir" || true
done

Repository: NVIDIA/TensorRT-LLM

Length of output: 238


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== changed files =="
git status --short
git diff --stat

echo "== test file outline =="
ast-grep outline tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

echo "== test file context =="
sed -n '1,140p' tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

echo "== test-list files =="
find tests/integration/test_lists -maxdepth 2 -type f \( -path '*/test-db/*' -o -path '*/qa/*' \) -print | sort | head -80

echo "== relevant list entries =="
rg -n -i 'pre[_-]mlp|nvfp4|fusion' tests/integration/test_lists/test-db tests/integration/test_lists/qa || true

Repository: NVIDIA/TensorRT-LLM

Length of output: 50376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== test-list documentation =="
sed -n '1,220p' tests/integration/test_lists/test-db/README.md
sed -n '1,220p' tests/integration/test_lists/qa/README.md

echo "== list and CI references to unit-test paths =="
rg -n --glob '*.yml' --glob '*.yaml' --glob '*.md' --glob '*.py' \
  'tests/integration/test_lists|unittest/' .github tests scripts 2>/dev/null \
  | head -160 || true

echo "== exact file and function references in all tracked files =="
rg -n --fixed-strings \
  'test_pre_mlp_nvfp4_fusion.py|test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp' \
  . --glob '!tests/integration/test_lists/**' || true

echo "== deterministic AST check for the three model files =="
python3 - <<'PY'
import ast
from pathlib import Path

models = [
    "modeling_deepseekv3.py",
    "modeling_glm.py",
    "modeling_exaone_moe.py",
]
root = Path("tensorrt_llm/_torch/models")

def path(node):
    if isinstance(node, ast.Name):
        return node.id
    if isinstance(node, ast.Attribute):
        prefix = path(node.value)
        return f"{prefix}.{node.attr}" if prefix else node.attr
    return ""

def contains(node, expected):
    return any(path(child) == expected for child in ast.walk(node))

for model in models:
    module = ast.parse((root / model).read_text())
    branches = []
    for function in ast.walk(module):
        if isinstance(function, ast.FunctionDef) and function.name == "forward_mlp":
            for child in ast.walk(function):
                if path(getattr(child, "test", ast.Constant(None))) == \
                        "self.mlp.gate_up_proj.has_nvfp4":
                    branches.append(child)
    print(model, "matching_branches=", len(branches))
    for branch in branches:
        true_checks = [
            contains(branch, "self.mlp.gate_up_proj.input_scale"),
            contains(branch, "AllReduceFusionOp.RESIDUAL_RMS_NORM_QUANT_NVFP4"),
        ]
        false_checks = [
            not contains(node, "self.mlp.gate_up_proj.input_scale")
            and not contains(
                node, "AllReduceFusionOp.RESIDUAL_RMS_NORM_QUANT_NVFP4")
            for node in branch.orelse
        ]
        fallback = any(
            contains(node, "AllReduceFusionOp.RESIDUAL_RMS_NORM")
            for node in branch.orelse
        )
        print("  true_checks=", true_checks,
              "false_checks=", false_checks,
              "fallback=", fallback)
PY

Repository: NVIDIA/TensorRT-LLM

Length of output: 24521


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== modeling-directory coverage in test lists =="
rg -n --fixed-strings \
  'unittest/_torch/modeling' \
  tests/integration/test_lists/test-db tests/integration/test_lists/qa \
  || true

echo "== exact target path coverage in test lists =="
rg -n --fixed-strings \
  'unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py' \
  tests/integration/test_lists/test-db tests/integration/test_lists/qa \
  || true

echo "== relevant tests README guidance =="
sed -n '135,175p' tests/README.md

Repository: NVIDIA/TensorRT-LLM

Length of output: 10503


Add the unit test to the CI test list.

test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp is absent from both CI and QA lists. Add it to a suitable tests/integration/test_lists/test-db/*.yml entry and run pytest tests/unittest/.

Coverage summary: one modified test with three model parameters. It checks NVFP4 and fallback branches. Coverage verdict: insufficient.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py` around lines 58
- 69, Add test_pre_mlp_nvfp4_fusion_guards_unquantized_dense_mlp to a suitable
CI and QA test-list entry under tests/integration/test_lists/test-db, ensuring
all three model parameters are covered. Then run pytest tests/unittest/ to
validate the updated coverage.

Source: Path instructions

Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu

zcxGGmu commented Aug 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review — I pushed 6dbe66172 addressing the test-list feedback.

Changes made:

  • Added unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py to the B200 pre-merge test list so the three parametrized PRE_MLP NVFP4 guard cases are covered by CI.

Validation:

  • grep -RIn --fixed-strings 'unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py' tests/integration/test_lists/test-db tests/integration/test_lists/qa — passed; the entry is present in l0_b200.yml.
  • pytest tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q --confcutdir=tests/unittest/_torch/modeling — passed, 3 tests.
  • (cd tests && pytest unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q --confcutdir=unittest/_torch/modeling) — passed, 3 tests in bridge-style path.
  • git diff --cached --check and staged credential-shaped added-line scan — passed.

Note: plain root-level pytest in this local Windows environment is blocked by unrelated test-harness imports (ray_stub / MPI library discovery), so I used the pure-test --confcutdir form for this AST-only regression test.

@brnguyen2 brnguyen2 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.

Approving — the comments below are optional touch-ups, not blockers.

Fix looks right. I confirmed the predicate holds up: apply_quant_config_exclude_modules (tensorrt_llm/_torch/models/modeling_utils.py:619) replaces the excluded module's quant_config, so Linear.has_nvfp4 really does go False for model.layers.0*-style exclusions, and the fallback still issues an allreduce, keeping disable_attn_allreduce consistent. The GLM/ExaOne change is a verbatim copy of the guard already on main in modeling_deepseekv3.py:1607, which is the right call for consistency.

Worth stating in the description that the crash reported in #15516 is in the DeepSeekV3 path and is already fixed on main — this PR is parity for the two other models with the same pattern, plus a test that also pins the existing DeepSeekV3 guard. As written it reads like the fix for the reported crash.

Follow-up, out of scope here: modeling_llama.py:838 gates the same gate_up_proj.input_scale read on the layer-level self.is_nvfp4, so it has the identical latent failure for checkpoints with submodule-level exclusions.

Comments below are on the test, not the fix.

- unittest/_torch/attention/sparse/deepseek_v4/test_compressor_tf32.py TIMEOUT (15)
- unittest/_torch/attention/sparse/test_sparse_mla_forward.py TIMEOUT (60)
- unittest/_torch/modeling/test_modeling_deepseekv4.py
- unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

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.

This test is pure ast.parse over source files — no GPU, no torch, 0.02s locally. Registering it on the B200 pre-merge list spends scarce Blackwell capacity on something that can't fail differently there. tests/integration/test_lists/test-db/l0_cpu_x86.yml (and l0_cpu_arm.yml) is the right home.

from pathlib import Path

import pytest

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.

parents[4] hardcodes the test's depth in the tree and assumes a source checkout rooted there. Moving the file one level silently points at the wrong path (or FileNotFoundError), and if a CI stage runs against an installed tensorrt_llm wheel this asserts on repo source that isn't necessarily what's imported. Derive it from the package instead:

import tensorrt_llm._torch.models as _models
_MODELS_DIR = Path(_models.__file__).parent

and drop the "tensorrt_llm" / "_torch" / "models" join in _forward_mlp_has_nvfp4_branch.

def _contains_attribute(node: ast.AST, attribute_path: str) -> bool:
return any(_attribute_path(child) == attribute_path for child in ast.walk(node))


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.

_forward_mlp_has_nvfp4_branch matches on the exact attribute path self.mlp.gate_up_proj.has_nvfp4, so any equivalent refactor — hoisting the check to a local, getattr(gu, "has_nvfp4", False) as modeling_gemma4.py:831 does, or inverting to if not ... — fails the test with a message claiming the guard is missing. That's the accepted cost of AST-pinning something that needs TP>1 + an NVFP4 checkpoint to exercise, but the raise AssertionError(f"{model_file} does not guard PRE_MLP NVFP4 fusion") message should say what shape it was looking for so the next person doesn't go hunting for a regression that isn't there.

Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu

zcxGGmu commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thanks for the review — I pushed 2bdc269eb addressing the feedback.

Changes made:

  • Moved test_pre_mlp_nvfp4_fusion.py off the B200 pre-merge list and onto the CPU x86/ARM lists.
  • Removed the fixed parents[4] checkout-root assumption and resolve the repository root from pytest's configured root path.
  • Made the AST guard robust to has_nvfp4 aliases / getattr(..., "has_nvfp4", False) patterns, with a focused regression test.

Validation:

  • pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q — passed, 4 tests.
  • python scripts/test_to_stage_mapping.py --tests "unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py" — passed, maps to CPU-Generic-arm-1 and CPU-Generic-x86-1.
  • git diff --check — passed.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py`:
- Around line 47-58: Update _forward_mlp_nvfp4_aliases to recursively inspect
nested control-flow statements while skipping nested functions and classes,
collecting matching assignment and annotated-assignment targets throughout
forward_mlp. Rename the fixture alias has_nvfp4 to a distinct name such as
use_nvfp4 so alias tracking is exercised.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d19b771b-af32-44f1-995b-05bff941973f

📥 Commits

Reviewing files that changed from the base of the PR and between 6dbe661 and 2bdc269.

📒 Files selected for processing (3)
  • tests/integration/test_lists/test-db/l0_cpu_arm.yml
  • tests/integration/test_lists/test-db/l0_cpu_x86.yml
  • tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

Comment thread tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py Outdated
Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu

zcxGGmu commented Aug 7, 2026

Copy link
Copy Markdown
Author

Thanks for the follow-up — I pushed 15dce66fd addressing the nested-alias feedback.

Changes made:

  • Renamed the regression fixture alias from has_nvfp4 to use_nvfp4 so it exercises alias tracking rather than the direct-name fallback.
  • Updated _forward_mlp_nvfp4_aliases to recursively inspect nested control-flow statements while skipping nested functions/classes.

Validation:

  • pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q — passed, 4 tests.
  • python scripts/test_to_stage_mapping.py --tests "unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py" — passed, maps to CPU-Generic-arm-1 and CPU-Generic-x86-1.
  • git diff --check — passed.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py`:
- Around line 63-66: Update _forward_mlp_nvfp4_aliases and its callers to
preserve source order and branch scope, accepting an alias only when its
assignment dominates the candidate if use_nvfp4 branch; reject
use-before-assignment and assignments from sibling branches. Add fixtures
covering both invalid cases and register the test file in the l0_cpu_arm.yml and
l0_cpu_x86.yml test lists.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4ba9b23b-40cc-44c7-b41d-49bcea27bc3c

📥 Commits

Reviewing files that changed from the base of the PR and between 2bdc269 and 15dce66.

📒 Files selected for processing (1)
  • tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py

Comment thread tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py Outdated
Signed-off-by: zq <zhouquan1511@163.com>
@zcxGGmu

zcxGGmu commented Aug 8, 2026

Copy link
Copy Markdown
Author

Thanks for the review — I pushed 80c96cd28 addressing the alias-order feedback.

Changes made:

  • Preserve source-order alias visibility when scanning forward_mlp AST branches.
  • Keep aliases scoped to the statement list where they are defined, so sibling-branch aliases do not leak into later candidates.
  • Add regression fixtures for use-before-assignment and sibling-branch alias leakage.
  • Confirm the focused test is already listed in l0_cpu_arm.yml and l0_cpu_x86.yml.

Validation:

  • pytest --confcutdir=tests/unittest/_torch/modeling tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py -q — passed, 6 tests passed; pytest emitted the existing local unknown-config warnings.
  • python scripts/test_to_stage_mapping.py --tests "unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py" — passed, maps to CPU-Generic-arm-1 and CPU-Generic-x86-1.
  • python -m py_compile tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py and python -m ruff check tests/unittest/_torch/modeling/test_pre_mlp_nvfp4_fusion.py — passed.
  • git diff --cached --check and staged credential-shaped added-line scan — passed.

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.

[Bug]: GLM-5.1-NVFP4 serve fails at warmup: PRE_MLP_FUSION accesses missing gate_up_proj.input_scale on excluded dense layers

3 participants