Skip to content

feat(runtime): basic PolicyRuntime implementation#118

Merged
maxxgx merged 19 commits into
mainfrom
max/runtime
May 21, 2026
Merged

feat(runtime): basic PolicyRuntime implementation#118
maxxgx merged 19 commits into
mainfrom
max/runtime

Conversation

@maxxgx
Copy link
Copy Markdown
Contributor

@maxxgx maxxgx commented May 17, 2026

Summary

This PR contains Phase 1 (of 2):

  • Initial policy runtime and async execution (threaded).
  • Thread safe action queue
  • Chunk smoothing: replace or merge via lerp (linear interpolation)

Phase 2: #119

Why

Validation

Breaking changes

  • None

Related issues

  • Closes #

Copilot AI review requested due to automatic review settings May 17, 2026 19:59
@maxxgx maxxgx requested a review from a team as a code owner May 17, 2026 19:59
@github-advanced-security
Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.runtime package: PolicyRuntime, ActionQueue, SyncExecution/AsyncExecution, ChunkSmoother/LerpSmoother/ReplaceSmoother.
  • Reworked InferenceModel.predict_action_chunk / select_action to 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.

Comment thread src/physicalai/runtime/runtime.py Outdated
Comment thread src/physicalai/runtime/runtime.py
Comment thread src/physicalai/runtime/runtime.py Outdated
Comment thread src/physicalai/runtime/runtime.py
Comment thread src/physicalai/runtime/_action_queue.py
Comment thread src/physicalai/inference/model.py Outdated
Comment thread examples/runtime/async_inference.py Outdated
maxxgx and others added 7 commits May 19, 2026 22:10
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>
Comment thread src/physicalai/inference/utils/action_cursor.py Outdated
Comment thread src/physicalai/inference/preprocessors/pi05.py
Comment thread examples/runtime/async_inference.py
Comment thread src/physicalai/robot/__init__.py
Comment thread src/physicalai/runtime/__init__.py Outdated
Comment thread src/physicalai/inference/preprocessors/pi05.py
Comment thread src/physicalai/inference/model.py Outdated
Comment thread src/physicalai/inference/model.py Outdated
samet-akcay
samet-akcay previously approved these changes May 20, 2026
Copy link
Copy Markdown
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

@maxxgx maxxgx merged commit 67b8b8e into main May 21, 2026
16 checks passed
@maxxgx maxxgx deleted the max/runtime branch May 21, 2026 12:02
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.

5 participants