Repository navigation
Migrate AICore kernel compilation from C++ to Python and simplify DeviceRunner API - #5
Merged
Merged
Conversation
…iceRunner API This commit fundamentally restructures how AICore kernels are compiled and loaded, moving kernel compilation responsibility from C++ to Python and simplifying the device runtime API. Key changes: **Kernel Compilation Migration:** - Extract kernel compilation from C++ (kernel_compiler.cpp/h) to Python - Add PTOCompiler class for Python-side kernel compilation using ccec - Add elf_parser.py for extracting .text sections from ELF object files - Remove binary_loader.cpp/h and kernel_compiler.cpp/h (replaced by Python) - Kernels now compiled and registered at Python layer before runtime execution **DeviceRunner API Simplification:** - Replace DeviceRunner Init/Run/Finalize with set_device() and launch_graph() - Remove pto_isa_root parameter (no longer needed after moving compilation to Python) - Add RegisterKernel() API for kernel binary registration - DeviceRunner now auto-finalizes via destructor (no manual Finalize needed) - Device initialization split into set_device() (early) and lazy binary loading (in launch_graph) **Runtime API Changes:** - Change Runtime allocation from C++ new/delete to placement new pattern - Add GetGraphSize() for user-side buffer allocation - Rename ValidateGraph() to FinalizeGraph() to better reflect responsibility - Remove function_cache.h (kernel lookup now uses direct registration) **AICore Executor Abstraction:** - Extract aicore_executor.h with core type and device args abstraction - Add DeviceArgs struct to replace uint64_t kernel parameters - Refactor kernel.cpp to use new executor pattern **Documentation and Testing:** - Update example/main.py to demonstrate new Python-first workflow - Simplify README testing instructions (use ./ci.sh) - Add ci.sh for streamlined testing Net result: -270 lines, cleaner separation of concerns, Python has full control over kernel compilation and registration lifecycle. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Complete the renaming from "Graph" to "Runtime" across all components to better reflect the system's purpose as a task execution runtime rather than just a graph data structure. Simplify the Python API by consolidating device initialization and execution into a single launch_runtime() function. Changes: - Rename Graph class to Runtime throughout C++ codebase - Update all function names: InitGraph → InitRuntime, ValidateGraph → FinalizeRuntime, launch_graph → launch_runtime - Rename GraphHandle to RuntimeHandle in C API - Simplify Python API: remove DeviceRunner from public interface, consolidate initialization into launch_runtime() - Update all documentation, comments, and examples to reflect new terminology - Update terminology in README and example documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ChaoWao
force-pushed
the
runtime-rebase
branch
from
January 28, 2026 03:15
27a1c3e to
66342bd
Compare
ChaoWao
added a commit
that referenced
this pull request
Mar 9, 2026
Remove PTO2_SPIN_PAUSE() and PTO2_SPIN_PAUSE_LIGHT() from pto_runtime2_types.h; replace all call sites with SPIN_WAIT_HINT(). PTO2_SPIN_PAUSE() violated codestyle rule #5 by calling sched_yield() on hardware. Use __has_include guard for spin_hint.h so Host .so (which lacks the AICPU include path) compiles with a no-op fallback.
1 of 2 tasks
ChaoWao
added a commit
that referenced
this pull request
Mar 9, 2026
Remove PTO2_SPIN_PAUSE() and PTO2_SPIN_PAUSE_LIGHT() from pto_runtime2_types.h; replace all call sites with SPIN_WAIT_HINT(). PTO2_SPIN_PAUSE() violated codestyle rule #5 by calling sched_yield() on hardware. Use __has_include guard for spin_hint.h so Host .so (which lacks the AICPU include path) compiles with a no-op fallback.
PKUZHOU
pushed a commit
to PKUZHOU/simpler
that referenced
this pull request
Mar 31, 2026
…ys#219) Remove PTO2_SPIN_PAUSE() and PTO2_SPIN_PAUSE_LIGHT() from pto_runtime2_types.h; replace all call sites with SPIN_WAIT_HINT(). PTO2_SPIN_PAUSE() violated codestyle rule hw-native-sys#5 by calling sched_yield() on hardware. Use __has_include guard for spin_hint.h so Host .so (which lacks the AICPU include path) compiles with a no-op fallback.
This was referenced Apr 14, 2026
4 of 5 tasks
2 tasks
ChaoWao
added a commit
to hw-native-sys-bot/simpler
that referenced
this pull request
Jun 3, 2026
…e goal Adds three steps that the bug-hunting checklist alone could not produce: - Step 4 reworked to accept stated goals from multiple sources, ranking user-provided description (in the /review-pr invocation) above the PR body. Catches the failure mode where authors silently narrow the goal in their own description. - Step 5.5 Mechanism Brief — required on PRs over ~500 lines. Forces the reviewer to demonstrate they understood the design (data structures, lifetime, concurrency, cross-boundary contracts) before judging it. - Step 5.7 Goal-Method Traceability table — every stated goal maps to a specific design choice and code location, marked Solid / Underspecified / Weak / Missing / Implicit. ❌ Missing and ➕ Implicit rows become Must-fix findings. - Feature checklist extended from 4 to 8 questions (stable-boundary discipline, error propagation paths, concurrency model with contention testing, alternatives considered). - Step 7 adds a "Verification before surfacing" subsection with concrete git commands to catch the most common external-reviewer hallucination (citing code outside the PR diff as a PR finding). - Step 8 output structure updated to require Mechanism Brief and Traceability sections, plus a dropped-finding audit trail for external reviewers. - Common Pitfall hw-native-sys#5 updated: never silently accept the PR body's framing when other goal sources are broader. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ChaoWao
added a commit
that referenced
this pull request
Jun 3, 2026
…e goal (#973) Adds three steps that the bug-hunting checklist alone could not produce: - Step 4 reworked to accept stated goals from multiple sources, ranking user-provided description (in the /review-pr invocation) above the PR body. Catches the failure mode where authors silently narrow the goal in their own description. - Step 5.5 Mechanism Brief — required on PRs over ~500 lines. Forces the reviewer to demonstrate they understood the design (data structures, lifetime, concurrency, cross-boundary contracts) before judging it. - Step 5.7 Goal-Method Traceability table — every stated goal maps to a specific design choice and code location, marked Solid / Underspecified / Weak / Missing / Implicit. ❌ Missing and ➕ Implicit rows become Must-fix findings. - Feature checklist extended from 4 to 8 questions (stable-boundary discipline, error propagation paths, concurrency model with contention testing, alternatives considered). - Step 7 adds a "Verification before surfacing" subsection with concrete git commands to catch the most common external-reviewer hallucination (citing code outside the PR diff as a PR finding). - Step 8 output structure updated to require Mechanism Brief and Traceability sections, plus a dropped-finding audit trail for external reviewers. - Common Pitfall #5 updated: never silently accept the PR body's framing when other goal sources are broader. Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
vegetabledoww
pushed a commit
to vegetabledoww/simpler
that referenced
this pull request
Jun 4, 2026
…e goal (hw-native-sys#973) Adds three steps that the bug-hunting checklist alone could not produce: - Step 4 reworked to accept stated goals from multiple sources, ranking user-provided description (in the /review-pr invocation) above the PR body. Catches the failure mode where authors silently narrow the goal in their own description. - Step 5.5 Mechanism Brief — required on PRs over ~500 lines. Forces the reviewer to demonstrate they understood the design (data structures, lifetime, concurrency, cross-boundary contracts) before judging it. - Step 5.7 Goal-Method Traceability table — every stated goal maps to a specific design choice and code location, marked Solid / Underspecified / Weak / Missing / Implicit. ❌ Missing and ➕ Implicit rows become Must-fix findings. - Feature checklist extended from 4 to 8 questions (stable-boundary discipline, error propagation paths, concurrency model with contention testing, alternatives considered). - Step 7 adds a "Verification before surfacing" subsection with concrete git commands to catch the most common external-reviewer hallucination (citing code outside the PR diff as a PR finding). - Step 8 output structure updated to require Mechanism Brief and Traceability sections, plus a dropped-finding audit trail for external reviewers. - Common Pitfall hw-native-sys#5 updated: never silently accept the PR body's framing when other goal sources are broader. Co-authored-by: Chao Wang <26245345+ChaoWao@users.noreply.github.com>
This was referenced Jul 3, 2026
poursoul
pushed a commit
to poursoul/simpler
that referenced
this pull request
Jul 16, 2026
Fdwic swimlane deps
3 tasks done
ChaoWao
added a commit
that referenced
this pull request
Jul 29, 2026
…1578) RemoteSocketTransport tests start a helper server thread, then construct a RemoteL3SocketTransport whose constructor throws on a connect or HELLO timeout — routine on a loaded box. The unwind destroyed the local std::thread while it was still joinable, so std::terminate aborted the whole binary mid-suite: #5 std::terminate () #6 std::thread::~thread() () #7 RemoteSocketTransport_ClosedPeerWriteDoesNotRaiseSigpipe_Test::TestBody() Reproduced at 2/96 with 32 concurrent copies on a loaded 320-core box; the run that aborts takes every other case in the binary with it, and the message ("terminate called without an active exception", printed because no handler has caught the in-flight exception yet) reads like a hang rather than a timeout. start_stalling_server also captured the test's stack std::atomic<bool> stop flag by reference, so the same unwind left a running thread polling a dead object. ScopedServerThread owns both the thread and the stop flag, and joins in its destructor, which closes both holes: the flag now outlives the thread, and no unwind can reach a joinable std::thread. Joining alone would swap the abort for a hang, because a thread parked in accept() never returns when the client's connect is exactly what failed. accept_until_stop polls the listener in 20 ms slices and rechecks the stop flag, so stop_and_join always makes progress. It reads the flag only after a poll slice, so a connection already pending still wins: ClosedPeerWriteDoesNotRaiseSigpipe calls stop_and_join right after a successful connect and depends on that connection being accepted and RST. Add ServerThreadIsJoinedWhenTestBodyUnwinds, which throws out of a scope holding a live server thread that never sees a client. It covers both halves — reverted to the old bare-std::thread idiom it aborts with the production message, and a join that could not reap a parked accept() would trip its elapsed bound instead. ut-cpp 65/65 green; 192 concurrent runs of the binary now abort 0 times.
ChaoZheng109
pushed a commit
that referenced
this pull request
Aug 3, 2026
- reserve the A5 L2 task-record slot before ACK and commit that exact slot after execution, so buffer rotation cannot move a record into a later generation - avoid reading the AICore system timer when L2 swimlane DFX is disabled - preserve A5 PMU per-task staging order and lazy L2 head resolution - add a focused unit test for reserve/commit across buffer generation changes Related to #1582 (missing item #5).
4 of 5 tasks
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit fundamentally restructures how AICore kernels are compiled and loaded, moving kernel compilation responsibility from C++ to Python and simplifying the device runtime API.
Key changes:
Kernel Compilation Migration:
DeviceRunner API Simplification:
Runtime API Changes:
AICore Executor Abstraction:
Documentation and Testing:
Net result: -270 lines, cleaner separation of concerns, Python has full control over kernel compilation and registration lifecycle.