feat(runtime): basic PolicyRuntime implementation#118
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
There was a problem hiding this comment.
Pull request overview
Introduces a new physicalai.runtime package implementing PolicyRuntime, a control loop that drives a robot using a trained policy. It adds an ActionQueue with pluggable ChunkSmoothers (Replace/Lerp), SyncExecution/AsyncExecution strategies (with worker health/watchdog and WorkerDiedError propagation), and a RuntimeCallback Protocol for hooks. Supporting changes fix InferenceModel.use_action_queue / select_action / predict_action_chunk so both single-pass and chunking runners work uniformly, expose RobotObservation, and add an async reference example.
Changes:
- New
physicalai.runtimepackage:PolicyRuntime,ActionQueue,SyncExecution/AsyncExecution,ChunkSmoother/LerpSmoother/ReplaceSmoother. - Reworked
InferenceModel.predict_action_chunk/select_actionto support both runner types, with shape normalization. - Comprehensive unit tests for smoothers, action queue (incl. thread safety), execution strategies, and runtime callbacks.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/physicalai/runtime/runtime.py | New PolicyRuntime, RunStats, default obs converter, callback dispatch. |
| src/physicalai/runtime/execution.py | Execution ABC, SyncExecution, threaded AsyncExecution with watchdog. |
| src/physicalai/runtime/_action_queue.py | Thread-safe queue with smoother-driven push_chunk. |
| src/physicalai/runtime/smoothers.py | Replace/Lerp chunk smoothers + input validation. |
| src/physicalai/runtime/init.py | Public runtime exports. |
| src/physicalai/inference/model.py | Unified select_action / predict_action_chunk; runner-based use_action_queue; chunk-shape normalization. |
| src/physicalai/robot/init.py | Re-exports RobotObservation. |
| tests/unit/runtime/* | New tests for smoothers, queue, execution, runtime. |
| tests/unit/inference/test_model.py | Updated tests reflecting non-raising chunk/select API. |
| examples/runtime/inference_async.py | Reference async inference example. |
| docs/design/components/runtime-system/implementation_plan.md | New implementation plan document. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tion() and predict_action_chunk()
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
samet-akcay
left a comment
There was a problem hiding this comment.
would be good to add your inference demo to our main readme file. Does not have to be in this pr, but we should have it :)
Summary
This PR contains Phase 1 (of 2):
Phase 2: #119
Why
Validation
Breaking changes
Related issues