Skip to content

Integrate Qwen3 CANN FAI decode#69

Draft
ChaoWao wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoWao:codex/qwen3-cann-fai-serving
Draft

Integrate Qwen3 CANN FAI decode#69
ChaoWao wants to merge 1 commit into
hw-native-sys:mainfrom
ChaoWao:codex/qwen3-cann-fai-serving

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 13, 2026

Copy link
Copy Markdown

Summary

  • Pin pypto-lib #755 and run Qwen3 decode through its direct CANN FAI CCEC kernel.
  • Dispatch active-prefix tensor views for B1 or true B16 while preserving the public [B, 8] token ABI. B1 no longer replicates inactive KV rows, and serving performs no KV-cache layout conversion.
  • Restrict this executor to A2/A3 onboard and reject B2-B15 before decode dispatch.
  • Map warmup reads and writes to scratch slot 0 instead of the invalid -1 slot.
  • Rebind the HOST decode output to its declared out parameter so current PyPTO can specialize all tuple return shapes.
  • Cover true B16 with 16 distinct prompt histories, each compared against its own B1 result.
  • Use a 2 GiB ring for CI's B16/4096-token warmup while retaining #753's manual scope boundaries and 16K task/dep pools.

Testing

  • python -m pytest -q tests/test_batching.py tests/test_parallel.py tests/test_device_sampling_submission.py: 40 passed.
  • Headers, English-only, ruff on changed files, workflow YAML parsing, and git diff --check: passed.
  • Current PyPTO b2f347f compiled the complete HOST decode wrapper to DistributedCompiledProgram.
  • Hardware golden under task-submit: task task_20260713_002105_18464897737, 8/8 expected tokens matched.
  • CI-shape B16/4096-token warmup with 2 GiB heap and 16K pools: task task_20260713_013155_194847010745, full accuracy passed.
  • True independent B16 under task-submit: task task_20260712_234748_24151917638, 16 requests matched their independent B1 references without deadlock.
  • A 3338-token, full 40-layer B1 serving run completed all 19 decode steps without device deadlock: TPOT 31.2 ms, decode-kernel wall average 30.82 ms, device Effective 28.53 ms.
  • At that B1 shape, L2 records show a 42.39 us median slowest-AIV span inside the mixed attention launch and a 166.12 us median scheduler-visible attention stage including tiling and dispatch.

Dependencies

  • PyPTO #2009 is merged.
  • Depends on pypto-lib #755.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6e497a3-2d85-401d-96a8-748089ef3296

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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 refactors the Qwen3-14B NPU runner and executor to support dynamic public batching (batch 1 or full capacity) for the fused decode kernel, replacing the previous fixed-batch padding approach. It also removes the standalone token embedding kernel, as embedding lookup and greedy sampling are now integrated directly into the fused decode kernel. Feedback is provided regarding a potential shape mismatch in _stage_decode_inputs where slicing token_ids with :width could cause issues if sampled_ids_width is greater than 1.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread examples/model/qwen3_14b/runner/npu_runner.py
@ChaoWao
ChaoWao force-pushed the codex/qwen3-cann-fai-serving branch from e956c30 to c6e05a5 Compare July 13, 2026 07:41
@ChaoWao ChaoWao changed the title Update Qwen serving for CANN FAI decode Integrate Qwen3 CANN FAI decode Jul 13, 2026
@ChaoWao
ChaoWao force-pushed the codex/qwen3-cann-fai-serving branch 3 times, most recently from 45de5eb to 6d64335 Compare July 13, 2026 09:18
- Pin the direct CANN FAI kernel and dispatch active B1/B16
  prefixes without replicated KV rows.
- Restrict the runtime to onboard A2/A3 and reject unsupported
  intermediate batches.
- Keep warmup KV accesses on the scratch page and cover independent
  full-batch histories.
- Rebind host decode outputs for current PyPTO tuple specialization
  and allocate 2 GiB for Qwen CI warmup.
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