Add external JIT mixed dispatch and include paths - #2009
Conversation
📝 WalkthroughWalkthroughThis PR adds ChangesExternal kernel source hashing and caching
Dual-AIV dispatch propagation
External manifest emission
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant UserCode
participant ExternDecorator
participant Specializer
participant SplitVectorKernel
participant PTOBackend
participant DeviceRunner
UserCode->>ExternDecorator: declare mixed external kernel
ExternDecorator->>Specializer: pass dual_aiv_dispatch
Specializer->>SplitVectorKernel: emit external AIV attributes
SplitVectorKernel->>PTOBackend: preserve external declarations
PTOBackend->>DeviceRunner: provide external kernel configuration
DeviceRunner->>DeviceRunner: hash sources and compile or load cache
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for dual AIV dispatch (dual_aiv_dispatch=True) in mixed external kernels, updating the JIT compiler, IR transforms, codegen, and runtime to handle this option. It also implements a content-addressed caching mechanism for external CCEC binaries by hashing source files and their include closures. The review feedback highlights a critical issue where hashing absolute paths (such as pto_isa_root, include_dirs, and resolved source/include paths) in the cache fingerprint makes the compiled kernel cache non-relocatable across different environments or CI/CD runners, and suggests using relative paths or omitting absolute paths from the digest.
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.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/en/dev/language/01-external-kernels.md (1)
112-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the
@pl.programequivalent for dual dispatch.This option is shown only for
@pl.jit.extern. For direct@pl.function(external_source=...)users, add a short example or cross-reference showingattrs={"dual_aiv_dispatch": True}on the AIV member, as exercised bytests/ut/ir/transforms/test_split_vector_kernel.py.🤖 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 `@docs/en/dev/language/01-external-kernels.md` around lines 112 - 121, Document the direct `@pl.function`(external_source=...) equivalent for dual dispatch alongside the existing `@pl.jit.extern` guidance. Add a concise example or cross-reference showing attrs={"dual_aiv_dispatch": True} on the AIV member, matching the usage covered by test_split_vector_kernel.py.
🤖 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.
Nitpick comments:
In `@docs/en/dev/language/01-external-kernels.md`:
- Around line 112-121: Document the direct `@pl.function`(external_source=...)
equivalent for dual dispatch alongside the existing `@pl.jit.extern` guidance. Add
a concise example or cross-reference showing attrs={"dual_aiv_dispatch": True}
on the AIV member, matching the usage covered by test_split_vector_kernel.py.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a35a7d92-a9e0-4844-82c1-2fbfe8a27fee
📒 Files selected for processing (13)
docs/en/dev/language/01-external-kernels.mddocs/zh-cn/dev/language/01-external-kernels.mdpython/pypto/_external_source.pypython/pypto/backend/pto_backend.pypython/pypto/jit/decorator.pypython/pypto/jit/specializer.pypython/pypto/runtime/device_runner.pysrc/codegen/orchestration/orchestration_codegen.cppsrc/ir/transforms/split_vector_kernel_pass.cpptests/ut/codegen/test_external_kernel.pytests/ut/ir/transforms/test_split_vector_kernel.pytests/ut/jit/test_extern_kernel.pytests/ut/runtime/test_external_kernel_cache.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2c8f80e53
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ff77ad4 to
a5bad6c
Compare
|
Addressed the automated review follow-ups in a5bad6c: cache digests no longer contain machine-specific absolute paths and now have a relocation regression; the new test has the required direct pytest entrypoint; and the docs show the direct @pl.function attribute form. |
a5bad6c to
6ab11b7
Compare
- Add optional dual-AIV dispatch for mixed external kernels - Preserve signature-only external kernels through vector splitting - Resolve and propagate ordered include directories to CCEC - Key external binary caches by sources, headers, launch metadata, and target identity - Document the public extern API and cover validation, manifests, and cache invalidation
Summary
pl.jit.externkernelsinclude_dirsrelative to the extern stub and forward them to CCECTesting
60 passedacross focused codegen, IR, JIT, backend, and runtime unit testsruff checkandruff format --checkpyright(0 errors)