Skip to content

hw/misc/rk3588_rknpu: support Qwen3-0.6B RKLLM workload - #46

Merged
zevorn merged 11 commits into
develfrom
pm/rk3588-rknpu-qwen3
Oct 25, 2026
Merged

zevorn merged 11 commits into
develfrom
pm/rk3588-rknpu-qwen3

Conversation

@zevorn

@zevorn zevorn commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Add the RKNPU execution paths needed by the Qwen3-0.6B RKLLM workload.

RKNPU model changes

  • accept quantized int32 DPU output for the LLM matmul tasks
  • execute the DPU_RDMA FP16 reshape used before the two-feature matmul
  • route the notched FP32 matmul through the existing softfloat FP16
    execution path
  • use SURFACE_ADD as the surface step for decoded notched layouts when
    DST_SURF_STRIDE is the row step
  • generalize the reshape and notched matmul checks by element counts and
    FP16/FP32 capabilities instead of the initial Qwen-specific shapes

Verification

Qwen3-0.6B RKLLM w8a8 on rock-5b-plus,rknpu=on generates 16 tokens
and reaches:

RKLLM-INIT ret=0
Question
Hello, I'm trying to find the value of the integral $\int
RKLLM-RUN ret=0
RKLLM-SMOKE exit=0

Measured with a timestamped QEMU run:

  • QEMU launch to RKLLM-RUN ret=0: 47.793 s
  • prompt-ready to RKLLM-RUN ret=0: 10.134 s
  • guest-reported generate time: 9535.63 ms for 16 tokens
  • guest-reported rate: 1.68 tokens/s

The smaller Qwen2.5-0.5B model was converted with RKLLM-Toolkit 1.3.1
and used to validate the same task shapes before the Qwen3 run.

rk3588-rknpu-test passes all 117 subtests, including the new
quantized int32 output and DPU_RDMA FP16 reshape cases.

Local evidence is under .oh-my-qemu/rk3588-rknpu-qwen3/.

The LLM matmul path emits an int8 convolution with a quantized int32
accumulator output.  Accept that output precision and validate the
32-bit output layout before selecting the int32 DPU writer.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
Add the DPU_RDMA FP16 reshape and notched FP32 matmul paths used by
RKLLM prefill.  The reshape path copies the RKLLM tile into the DPU
output view.  The notched path uses the existing softfloat FP16
execution and accepts SURFACE_ADD as the surface step when the
programmed DST_SURF_STRIDE is the row step.

The Qwen3-0.6B smoke run now completes with RKLLM-RUN ret=0.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
@zevorn
zevorn marked this pull request as ready for review October 24, 2026 05:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-25T04:56:46.094773Z 2003533 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaa2e0c42c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Comment thread hw/misc/rk3588_rknpu.c Resolved
Replace the Qwen-specific shape checks with capability checks for the
DPU_RDMA FP16 reshape and notched FP32 matmul paths.  The reshape path
now accepts any FP16 source and output tile with the same element
count, and the notched path accepts any FP16 matmul with a notched
FP32 output and a valid SURFACE_ADD surface step.

Keep the SURFACE_ADD interpretation scoped to decoded notched layouts
so existing DST_SURF_STRIDE checks remain unchanged.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
Add a quantized int32 DPU output case and a DPU_RDMA FP16 reshape
case.  The reshape case verifies the element-for-element copy from the
RDMA source tile to the DPU output view; the int32 case verifies that
the quantized LLM matmul output reaches the int32 writer with zero
input and weights.

Signed-off-by: Chao Liu <chao.liu@processmission.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7c749e3ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Comment thread hw/misc/rk3588_rknpu.c Resolved
Multi-token prefill uses a wider RDMA tile with no output notch and no
source line notch.  Recognize the reshape by the FP16 data format, EW
configuration and LUT bypass rather than the single-token tile shape.

Signed-off-by: Chao Liu <chao.liu@processmission.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 705c70b560

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Comment thread hw/misc/rk3588_rknpu.c Resolved
@zevorn

zevorn commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings in d740467:

  • notched FP32 matmul now validates core, CNA and DPU geometry before dispatch
  • 224-row notched output uses row-group SURFACE_ADD addressing
  • reshape working storage is charged against the host memory budget
  • reshape source reads honor RDMA line padding and surface notch fields
  • reshape fast path requires bypassed BS/BN stages and identity output conversion
  • derived SURFACE_ADD fields are reconstructed in post_load()

Validation:

rk3588-rknpu-test: 117 subtests passed
rock-5b-test: 5 passed
rock5b-plus-test: 18 passed
rk3588-evb-test: 10 passed
rk3588s-roc-pc-test: 1 passed

The reshape qtest now uses a padded RDMA source row stride to cover the
stride-aware read path.

@zevorn

zevorn commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

Additional validation after the review fixes:

  • rk3588-rknpu-test: 117 subtests passed
  • rock-5b-test: 5 passed
  • rock5b-plus-test: 18 passed
  • rk3588-evb-test: 10 passed
  • rk3588s-roc-pc-test: 1 passed

Qwen3-0.6B still completes both the single-token English prompt and
the four-token Chinese prompt with RKLLM-RUN ret=0 after the signed
RDMA surface-notch handling.

Latest commits:

d740467db2 hw/misc/rk3588_rknpu: fix RKLLM execution review findings
5802bf0e8d hw/misc/rk3588_rknpu: handle signed RDMA surface notch

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5802bf0e8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Comment thread hw/misc/rk3588_rknpu.c Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a7ac3a2d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Validate the DPU core dimensions, CNA storage layout and output geometry
before selecting the notched FP32 matmul path, so the shared allocation
and indexing checks cannot be bypassed.

Handle the 224-row notched output by treating SURFACE_ADD as a row group
stride and writing rows across row groups.  Account reshape working
storage against the host memory budget, validate the RDMA source stride
before reading, reject unaligned source channel counts, and only accept
the reshape fast path when the BS/BN stages and output conversion are
identity.

Evaluate the signed RDMA surface notch with sextract32() so a negative
notch yields a valid compact source layout.  Reconstruct the derived
SURFACE_ADD view fields in post_load().

Signed-off-by: Chao Liu <chao.liu@processmission.com>
@zevorn
zevorn force-pushed the pm/rk3588-rknpu-qwen3 branch from 4a7ac3a to 8233642 Compare October 25, 2026 04:13

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82336421ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Run the existing FP16 BS and BN stage validation before selecting the
notched FP32 matmul path.  This rejects active RDMA-sourced stages that
the execution path cannot service.

Signed-off-by: Chao Liu <chao.liu@processmission.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a319b53fbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Require the notched FP32 matmul path to bypass the DPU LUT.  The
shared FP16 execution path writes 16-bit LUT results, which is not a
valid 32-bit notched output.

Signed-off-by: Chao Liu <chao.liu@processmission.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc4a59e476

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
The notched FP32 executor initializes out-of-bounds samples to zero and
does not apply the programmed CNA pad value.  Reject such tasks before
dispatching the notched matmul path.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
The notched FP32 executor does not apply EW arithmetic.  Require the EW
stage to be fully bypassed before selecting this mode.

Signed-off-by: Chao Liu <chao.liu@processmission.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f25361a709

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hw/misc/rk3588_rknpu.c Resolved
Comment thread hw/misc/rk3588_rknpu.c Resolved
Require the reshape fast path to use a fully packed output: valid and
storage channel counts must match and be eight-channel aligned.  Reject
RDMA source padding, which the reshape reader does not synthesize.

Signed-off-by: Chao Liu <chao.liu@processmission.com>
@zevorn

zevorn commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator Author

Latest review fixes:

  • validate CNA storage layout before the notched FP32 path
  • validate BS/BN FP16 stages and require EW bypass
  • reject CNA pad values in the notched path
  • reject reshape source channels not aligned to eight-channel atoms
  • reject reshape source padding and partial output atoms

Review threads are resolved. Current CI state:

checkapply: pass
checkpatch: pass
other jobs: queued/running

Local verification:

rk3588-rknpu-test: 117 subtests passed
Qwen3 English prompt: RKLLM-RUN ret=0

@zevorn
zevorn merged commit a27b32c into devel Oct 25, 2026
47 checks 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.

1 participant