Skip to content

fix(moe): port effective aiter runner and shuffle markers and fix PTPC padding - #86

Merged
apinge merged 6 commits into
qwen4_v0.5.21from
qwen4-aiter-ptpc-padding
Nov 7, 2026
Merged

apinge merged 6 commits into
qwen4_v0.5.21from
qwen4-aiter-ptpc-padding

Conversation

@apinge

@apinge apinge commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Motivation

This PR is mainly based on #30, adds modifications for padding of ptpc fp8 and other changes from 619632b

Modifications

Aside from scripts, testing and utils files, the main difference from the base commit 816ff20 is the moe padding chanages.:

Path Existing behavior in the base Main changes this PR
bf16 moe aiter weight shuffling was already supported. The per-TP intermediate size had to be 128-aligned; unsupported sizes triggered a fallback or an error. Use get_moe_weight_sizes() to allocate padded weights and zero-fill padding during loading. Remove the fixed 128-alignment restriction and explicitly set the is_shuffled markers.
ptpc fp8 moe Generic padded weight allocation, shuffle_weight(), and is_shuffled markers were already present. Require a padding alignment of 64. Add matching padding for weights and per-channel scales when needed, then apply the existing shuffle path.

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@apinge apinge changed the title Qwen4 aiter ptpc padding fix(moe): port effective aiter runner and shuffle markers and fix PTPC padding Nov 5, 2026
sammysun0711 added a commit that referenced this pull request Nov 6, 2026
* [AMD] Tune Qwen3.8 HC mix for MI308X

Specialize the BF16 HC mix for the Qwen3.8 shape on 80-CU gfx942 devices using measured Triton launch parameters and smaller row tiles.

Expand correctness coverage to 1-16 rows, add graph replay regression tests, and register AMD kernel CI.

Validation: 39 tests passed on MI308X. Graph replay with all 100 checkpoint HC weight pairs improves by approximately 2.28x over the original persistent configuration.
(cherry picked from commit 8cf5501)

* feat(rocm): add Pyhip GR read support for Qwen3.8 Flash Next TP2 and TP4 (#39)

* use pyhip gr read

* update comments

* add comments

* update scripts

* update setup

* update pyproject_other.toml

* Revert "update pyproject_other.toml"

This reverts commit 9b0cebd.

* update pyprojct

* update warmup

(cherry picked from commit 182e5e8)
Ported onto qwen4_v0.5.21 with only the changes the branch's lint requires:
- Test moved to test/registered/kernels/ops/gemm/ (kernel test layout) and
  registered with register_amd_ci (check-registered-tests).
- ruff-format applied to the added lines.
- Dropped hunks whose context no longer exists: scripts/ TP1 launcher
  (removed), compressed-tensors bump, and weight_updater call-site edits
  (call sites already pass the model).

* Address review comments on Qwen3.8 GR cherry-pick

- hc_mix: use is_gfx942_supported() for the gfx942 check and keep the
  original num_ctas line.
- launch script: drop the duplicate AITER_MOE_PADDING_SIZE export; #86
  exports it at its definition.

---------

Co-authored-by: apinge <[email protected]>
Co-authored-by: tongqiu <[email protected]>
Co-authored-by: root <[email protected]>
Co-authored-by: Xiake Sun <[email protected]>
@apinge
apinge force-pushed the qwen4-aiter-ptpc-padding branch 2 times, most recently from cf50814 to e2c6c5c Compare November 6, 2026 07:11
apinge and others added 3 commits November 6, 2026 08:01
Adapt the source branch interfaces required by the PR #30 FP8 PTPC and
BF16 MoE import to qwen4_v0.5.21. Keep explicit Triton selection ahead
of SGLANG_USE_AITER in allocation, routing and shared-expert setup.
Load padded BF16 buffers with logical TP checkpoint offsets.

Based-on: 619632b
Based-on: 6053574

These are selective interface adaptations, not full cherry-picks of the
referenced commits. Keep generic padding at 128 and omit INT4-triggered
backend selection. The following commits contain PR #30 itself and the
project PTPC alignment and launch policy.

Signed-off-by: apinge <[email protected]>
…o aiter (#30)

* add preshuffle flag for ptpc

* fix(moe): align FP8 PTPC shuffle with runner

* recover mtp tp2 and tp4

(cherry picked from commit cc0c3c5)

Source-PR: #30
Port notes:
- Resolve PTPC context against the new base, which already has some shuffle
  markers; retain the effective-runner import and source padding behavior.
- Preserve the new base gfx95 activation guard and parameter identity while
  removing the old BF16 128-alignment restriction from PR #30.
- Adapt source regression fixtures to the new MoeRunnerConfig interfaces.
- Project-specific 64 alignment and launch policy are in the next commit.

Signed-off-by: apinge <[email protected]>
Load equal logical TP checkpoint slices before padding FP8 PTPC gate/up
weights and channel scales, then pad down-projection K and shuffle.
Require PTPC alignment 64 without changing the generic AITER default.
Keep explicit Triton MoE free of AITER padding and preshuffle even with
SGLANG_USE_AITER=1, as required by the Qwen3.8 TP1 launch.

Use 64-aligned physical BF16 dimensions for the gfx942 gated MTP path,
with zero pad metadata for the tuned Qwen3.8 kernels. Preserve Qwen3.5
automatic AITER selection, shared-expert routing and ASM/CK layouts.
Export the PTPC default in Qwen launch scripts and select AITER for the
Qwen3.8 MTP MoE. Keep source PR #30 regressions in the repository; local
migration experiments and their artifacts are kept separately in /opt.

Qwen3.8 MoE configs: apinge/aiter@23115cc
Qwen3.5 ASM configs: apinge/aiter@4752a40
Qwen3.5 CK configs: apinge/aiter@3bb5dfa

Signed-off-by: apinge <[email protected]>
@apinge
apinge force-pushed the qwen4-aiter-ptpc-padding branch from 0b9bcb3 to fcb6f43 Compare November 6, 2026 08:32
Restore the inline F.pad, torch.cat and Parameter assignments from the
source branch after PR #30 so reviewers can compare the padding path
directly. Remove the local padding helpers and copy_or_rebind_param use.
Release temporary tensors after use to limit their lifetime.

Keep strict alignment-64 validation, unpadded logical TP loading and
effective backend selection unchanged. Explicit Triton still bypasses
AITER MoE padding and shuffle. Preserve the padding observation log.

Reference: cc0c3c5

Validation: 56 targeted tests and 6 subtests passed. Real GPU FP8 padding
and shuffle produce identical weight/scale bytes and layout markers for
intermediate 128, 160 and 320. The 160-to-192 single-layer allocation test
peaks about 361 MiB above the helper implementation; unpadded cases match.
No full model evaluation was rerun for this refactor.

Signed-off-by: apinge <[email protected]>
Restore the source get_moe_padding_size implementation, including the
AITER_MOE_PADDING_SIZE override and the generic default of 128. Pass the
effective AITER backend directly to PTPC weight allocation again, then
use the existing padded loader to copy logical TP weight and scale slices.
Remove the project-specific gfx942 BF16 alignment override so BF16 also
uses the source environment-driven allocation.

Retain the requested strict PTPC alignment-64 check, but validate the
same resolved value used for allocation. PTPC launch scripts supply the
64 default; a direct PTPC launch without that setting now fails early
instead of validating 64 and silently allocating with the generic 128.
Explicit Triton continues to bypass AITER MoE padding and shuffle.

Based-on: cc0c3c5

Validation: 47 targeted checks and 6 subtests passed, including every TP
rank, presharded inputs, channel scales and explicit Triton selection.
Real single-layer GPU loading, normalization and shuffle produced identical
weight/scale bytes and markers for Qwen3.8 TP2/TP4. Local experiments are
under /opt; no full-model runs were added.

Signed-off-by: apinge <[email protected]>
@apinge
apinge requested a review from sammysun0711 November 6, 2026 09:51
@apinge
apinge marked this pull request as ready for review November 6, 2026 09:51

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

Local check with following config

  • Qwen3.8 TP2/TP4 + MTP
  • Qwen3.5 35B TP1/TP2/TP4 + Dflash
  • Qwen397B TP8 + Dflash
    Both function and accuracy check passed, invoked MOE kernel matched tuned aiter moe kernel introduced by apinge/aiter#1.

@apinge
apinge merged commit 54ad17d into qwen4_v0.5.21 Nov 7, 2026
17 of 23 checks passed
@apinge
apinge deleted the qwen4-aiter-ptpc-padding branch November 19, 2026 02:56
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