-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(policies): Add remote http policy, to benchmark custom models #2330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a remote policy type that allows external models to be evaluated through LeRobot's benchmarking infrastructure. It enables users with custom policies served via HTTP to run LeRobot benchmarks without integrating their model code directly into the repository.
Key changes:
- Remote policy implementation that communicates with HTTP servers for action prediction
- MessagePack-based serialization utilities for efficient tensor transmission
- Example FastAPI server demonstrating the protocol
- Integration with LeRobot's existing evaluation pipeline
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lerobot/utils/messaging.py | Adds msgpack-based serialization/deserialization for tensors and numpy arrays |
| src/lerobot/policies/remote/configuration_remote.py | Configuration class defining remote policy parameters (URL, timeout, retry attempts) |
| src/lerobot/policies/remote/modeling_remote.py | Remote policy implementation with HTTP client and action queue management |
| src/lerobot/policies/remote/processor_remote.py | Pre/post-processing pipeline for remote policy observations |
| src/lerobot/policies/remote/init.py | Module exports for remote policy components |
| src/lerobot/policies/factory.py | Factory integration to enable remote policy instantiation |
| src/lerobot/policies/init.py | Adds RemoteConfig to public API exports |
| src/lerobot/async_inference/constants.py | Adds "remote" to supported policies list |
| pyproject.toml | Adds server extra dependencies (fastapi, uvicorn, msgpack) |
| examples/remote/remote_policy_server.py | Example FastAPI server returning zero actions |
| README.md | Documentation for remote policy evaluation workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/lerobot/utils/messaging.py
Outdated
| import time | ||
| from typing import Any, Dict | ||
|
|
||
| import msgpack | ||
|
|
||
|
|
||
| from typing import Any, Dict, List, Union |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate imports of Any, Dict on lines 2 and 7. Consolidate imports into a single from typing statement.
src/lerobot/utils/messaging.py
Outdated
| else: | ||
| return o | ||
|
|
||
| # @timeit(logger) |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out decorator @timeit(logger) should be removed if not needed, or uncommented and properly configured if timing is required.
| # @timeit(logger) |
|
|
||
| # --- Abstract API implementations required by PreTrainedConfig --- | ||
| def get_optimizer_preset(self) -> AdamWConfig: | ||
| """Remote policy is inference-only; return a inert preset for API compatibility.""" |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'inert' to 'inert' (though 'inert' is correct, the article should be 'an inert' not 'a inert').
| """Remote policy is inference-only; return a inert preset for API compatibility.""" | |
| """Remote policy is inference-only; return an inert preset for API compatibility.""" |
| if v.ndim >= 1: | ||
| B = int(v.shape[0]) | ||
| break | ||
|
|
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NoneType error if B is not inferred from any tensor/array in obs_input. Add a fallback default or raise a descriptive error if B remains None.
| if B is None: | |
| raise ValueError( | |
| "Could not infer batch size 'B' from obs_input. " | |
| "Ensure that obs_input contains at least one array-like value (torch.Tensor or np.ndarray) with a batch dimension." | |
| ) |
|
Lerobot has Async inference which work over Grpc. |
|
@helper2424 |
|
Yep, but it's extendable. |
|
I mean, you have create additional http policy server - it could be done with Async remote server, as purpose is the same |
|
Oh, okay |
|
Very cool, if u need help - ping me |
|
Hey, it took me some time to understand how grpc in lerobot works |
|
@helper2424 Hey |
What this does
Adds policy, that queries HTTP server for actions.
It's needed if you have your custom policy, that is hard to integrate to lerobot repository, but you want to run benchmarks available in lerobot.
How it was tested
You can install additional dependencies by doing
pip install -e ".[server]"And run an example server with
Then you can run benchmark for example
How to checkout & try? (for the reviewer)
Examples:
pip install -e ".[server]" uvicorn examples.remote.remote_policy_server:app --host 0.0.0.0 --port 8000pip install -e ".[libero]" lerobot-eval \ --output_dir=/logs/ \ --env.type=libero \ --env.task=libero_spatial \ --eval.batch_size=1 \ --eval.n_episodes=3 \ --policy.type=remote \ --policy.server_url=http://localhost:8000 \ --policy.timeout=30.0 \ --policy.attempts=3 \ --policy.n_action_steps=10 \ --output_dir=./eval_logs_libero_spatial/ \ --env.max_parallel_tasks=1