Repository navigation
feat: add t5_split_qkv_append_cache operator package - #2811
Kingsley-Yoimiya wants to merge 2 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06d9556d50
ℹ️ 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".
| size_t count=0; | ||
| ~Metadata(){for(auto* t:tensors)if(t)aclDestroyTensor(t);} | ||
| void add(const TensorInfo& t){ | ||
| auto* result=aclCreateTensor(t.sizes.data(),t.rank,t.dtype,t.strides.data(),0,ACL_FORMAT_ND,t.sizes.data(),t.rank,t.data); |
There was a problem hiding this comment.
Reject packed NPU storage before declaring tensors ND
When internal NPU formats are enabled, a logically contiguous tensor produced by torch_npu.npu_format_cast(..., 29) can pass the contiguity checks while retaining FRACTAL_NZ physical storage; xllm/python/kernels_npu/activation.py:46-51 already handles this distinction. This descriptor instead labels every buffer as ND, causing the kernel to interpret packed or padded bytes as ordinary QKV/cache data and silently produce incorrect outputs rather than reject the unsupported layout. Check the actual NPU storage format at the framework boundary, including the run_direct and prepare entry points.
Useful? React with 👍 / 👎.
| assert math.isclose(statistics.median(item['wall_us_rounds']),item['wall_us_median']) | ||
| custom=r['results']['custom']['wall_us_median'];base=min(v['wall_us_median'] for k,v in r['results'].items() if k!='custom') | ||
| ratio=custom/base | ||
| assert ratio<=c['max_custom_over_fastest_valid_baseline'],(c['case_name'],ratio,c['max_custom_over_fastest_valid_baseline']) |
There was a problem hiding this comment.
Enforce fixed latency limits in the full acceptance gate
When absolute latency exceeds the documented target but remains faster than the remeasured baseline, this comparison still passes. The advertised verify_all.sh workflow runs the internal benchmark and this checker at lines 23-24 without invoking the fixed-target checker. In a CPU-only probe, doubling all recorded timing samples and medians still produced a passing acceptance result even though public/check_performance.py rejected all ten cases—for example, case 007 measured 119.1 µs against its 75 µs limit. Apply public/performance_targets.json here, preferably by reusing the public evaluator, so this workflow cannot certify out-of-spec performance.
Useful? React with 👍 / 👎.
| @@ -0,0 +1,136 @@ | |||
| #include "kernel_operator.h" | |||
There was a problem hiding this comment.
Add the mandatory copyright headers to the new sources
The new handwritten kernel starts directly with an include, and the new bindings and Python implementation similarly omit copyright headers. AGENTS.md makes the shared code-style guide mandatory for files under xllm/, and that guide's File & Header Rules explicitly require a copyright header on every new file. Add the appropriate headers and creation years across the new handwritten sources while preserving existing vendor notices.
AGENTS.md reference: AGENTS.md:L5-L8
Useful? React with 👍 / 👎.
| raise ValueError('head attributes must be integers') | ||
| return attrs | ||
|
|
||
| def run_aclnn(inputs, attributes=None): |
There was a problem hiding this comment.
Annotate the Python entry points and their helpers
The formal ACLNN entry point has no parameter or return annotations, as do prepare, Prepared.__call__, and the supporting functions. The mandatory Python guide explicitly requires annotations on every function signature, so this newly added public tensor/attribute interface does not meet the repository's documented contract conventions. Annotate the input tensors, optional attributes, returned tensor tuple, and helper signatures rather than leaving the package untyped.
AGENTS.md reference: AGENTS.md:L5-L8
Useful? React with 👍 / 👎.
Add copyright headers to handwritten sources, reject non-ND NPU storage before building ACLNN descriptors, annotate the Python entry points, and enforce the fixed latency limits in the acceptance gate and verify_all.sh.
|
Thanks for the review — all four findings are addressed in
Re-ran the offline gate against the submitted reports: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a6214533c
ℹ️ 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".
| std::vector<uint8_t*> pointers; | ||
| for (const auto& tensor : in) pointers.push_back(ptr(tensor)); | ||
| for (const auto& tensor : out) pointers.push_back(ptr(tensor)); | ||
| for (const auto& tensor : workspace) pointers.push_back(ptr(tensor)); |
There was a problem hiding this comment.
Reserve the fixed-size launch pointer vector
Every run_direct invocation appends exactly six pointers to this initially empty vector, introducing avoidable heap reallocations and frees on the host launch path. The mandatory custom-code-style-cpp.md §9 explicitly requires reserving a vector when its final size is known. Reserve the combined input/output/workspace count before these loops, or use a fixed array as the ACLNN binding does.
AGENTS.md reference: AGENTS.md:L5-L8
Useful? React with 👍 / 👎.
| "op_host/aclnn_binding.cpp": "964f5bd04d250bca0e24c834af1c1a3063b94cc6ccca85e70e049c747843d2b8", | ||
| "op_host/torch_binding.cpp": "f73980ebba0493e247e13d2d1c10dec928a9b78780d9a88848967f23a60fa5e6", |
There was a problem hiding this comment.
Refresh the fingerprints for the revised sources
Checking the manifest with hashlib.sha256 shows that 19 of its 35 source hashes disagree with the committed files, including both bindings, the kernels, and python/solution.py. The manifest therefore cannot validate this checkout or establish its correspondence to the bundled test evidence, despite the README's claim that these sources remain byte-identical to the recorded upstream commit. Update the current-source fingerprints and corresponding checksum inventory, while keeping historical upstream and tested-artifact fingerprints explicitly distinguished from the revised implementation.
Useful? React with 👍 / 👎.
What
Add the complete ACLNN operator package for
T5SplitQkvAppendCacheunderxllm/core/kernels/npu/xllm_ops/t5_split_qkv_append_cache/, following the task book §5 target and the same delivery shape asrow_col_int8_quant.The package is self-contained (own
build.sh, ACLNN project, samples, Python entry, tests and submission materials); it does not modify the engine build.Contents
aclnn/op_host/,op_kernel/,include/api.hexamples/run_aclnn_example/run_exampleC++ samplespython/run()ACLNN entry +run_direct()cross-check + baselinetests/public/docs/task_submission/artifacts/custom_opp_openEuler_aarch64.runevidence/SOURCE_MANIFEST.json,SHA256SUMS.txtOperator
Single-token decode: split
qkv[B,1,3*H*D]into contiguousquery[B,H,1,D], append the current token's K/V topastKey/pastValue[B,H,L,D]and returnkey/value[B,H,L+1,D]. FP16/BF16, bit-exact 16-bit copy (±0/Inf/NaN preserved), inputs untouched, outputs disjoint, workspace = 0.Verification (Ascend910_9382 / CANN 9.1.0 / driver 25.5.t6.b001)
bit_mismatches=0), plus 12 extra seed/offset inputs, 28 negative scenarios, two-stream / repeated-append / output-lifetime checks.(16,16,2048,64)FP16 = 74.0 us (limit 75), BF16 = 74.4 us (limit 77); small shapes 19.9-22.0 us.task_submission/,evidence/.Reproduce