Hugging Face Asynchronous Robot Inference
Hugging Face has introduced asynchronous robot inference, a system that decouples action prediction from execution to eliminate the idle periods typically found in sequential robotic control loops. This approach allows robots to continue executing a queue of predicted actions while the next set of actions is being computed, resulting in a ~2x speedup in task completion time without compromising success rates.
The Limitations of Sequential Inference
Sequential inference creates a bottleneck where the robot must remain idle while waiting for a policy to predict the next chunk of actions. In a traditional loop, the robot captures an observation, runs the policy to obtain a sequence of future actions, and then executes those actions. Once the queue is empty, the robot stops entirely until the next inference cycle completes.
This dependency leads to two primary issues:
- Runtime Lags: As models become larger and more computationally expensive, inference latency increases, dominating the interaction time and slowing down overall task execution.
- Reduced Responsiveness: The robot operates in an open-loop fashion while executing a chunk and then becomes completely idle, making it unable to react quickly to environmental changes.
Asynchronous Inference Architecture
Asynchronous inference removes idle periods by overlapping computation and execution. The system is split into two distinct components that can reside on different machines connected via a network:
Robot Client
The RobotClient runs on-board the robot. Its primary responsibilities include:
- Observation Streaming: It streams the latest observations to the server. Because high-resolution camera captures often exceed the 4MB gRPC message limit, observations are streamed rather than sent via unary RPC.
- Queue Management: The client maintains a local action queue. It triggers a new observation request when the queue length drops below a configurable threshold (the
chunk_size_thresholdor $g$). - Action Aggregation: When new action chunks arrive, the client merges them with the current queue using custom aggregators. Supported strategies include Replace (overwriting overlapping actions with new predictions) and Weighted blend (combining actions using temporal weights).
Policy Server
The PolicyServer is hosted on accelerated hardware (such as GPUs or TPUs) to maximize computational resources. Its workflow includes:
- Observation Cleaning: A pipeline that handles key matching, preprocessing, and inference preparation.
- Similarity Filtering: To avoid redundant computations, the server compares the current observation with the previous one using joint-space similarity. If the observations are too similar, the server may skip inference unless the observation is tagged with
must_go=True. - Request Blocking: The server blocks incoming observations until the previous one has been processed to ensure it always works on the most recent data.
Technical Implementation and Performance
Communication Protocol
The system utilizes gRPC (HTTP/2-based with protocol buffers) for communication. This choice provides low-latency binary messaging and bidirectional streams, achieving sub-100ms round-trip latency on local networks using hardware like the NVIDIA RTX 4090.
Tuning the Control Loop
Performance is governed by the ratio $c = \frac{\mathtt{environment}\mathtt{dt}}{\mathtt{inference}\mathtt{time}}$. To prevent the system from degenerating back into sequential control, users can:
- Increase Compute: Use more powerful GPUs to reduce $\mathtt{inference}_\mathtt{time}$.
- Adjust the Threshold ($g$): The parameter $g$ represents the fraction of the maximum chunk size at which a new observation is sent.
- $g = 0$ mimics sequential inference.
- $g = 1$ sends observations every timestep for minimal lag but maximum compute.
- Experiments indicate that $g \approx 0.7$ is an effective trade-off, though Hugging Face recommends a starting value of $g = 0.5$.
Impact on Robotic Policies
Asynchronous inference is compatible with policies that support action chunking, such as ACT, OpenVLA, PI0, and SmolVLA. By tightening the control loop and allowing for continuous movement, the system enables more adaptive control and faster task completion. In tests with SmolVLA, this architecture resulted in a ~2x speedup in task completion time while maintaining a comparable task success rate.