Back to News Feed
Hugging Face Blog18d ago

Record, train, and deploy from one place with Strands Agents, LeRobot, and Hugging Face Storage Buckets

The lifecycle of physical AI—collecting demonstrations, training policies, and deploying them to hardware—has historically been a fragmented, high-friction process. Today, we are streamlining that loop. By integrating Strands Agents, the LeRobot stack, and the newly introduced Hugging Face Storage Buckets, developers can now manage the entire data pipeline within a single, unified workflow.

This approach allows you to record robot demonstrations, sync them to the cloud with byte-level deduplication, stream them directly into training pipelines, and deploy the resulting policies back to your hardware—all without ever leaving the LeRobot data format.

The Unified Data Loop

In our previous exploration of Strands Robots, we introduced an open-source SDK designed to simplify robot abstractions and simulation. We demonstrated how to record a simulation, run a policy, and deploy that same agent code to a physical SO-101 arm.

Building on that foundation, we are now closing the loop. The goal is to run a continuous cycle: collect episodes throughout the day, train a policy on the expanding dataset, deploy the checkpoint, and pull the next batch of data to refine the model. Previously, this process was plagued by redundant data transfers and massive local storage requirements. By utilizing Hugging Face Storage Buckets—a mutable, non-versioned, Xet-backed object storage layer—we can now treat the cloud as our primary working directory.

What You Will Build

The agent you will construct in this workflow performs four critical functions: 1. Record: Captures a LeRobotDataset based on natural language prompts. 2. Sync: Uploads data to a Storage Bucket using efficient, byte-level deduplication. 3. Stream: Reads the dataset directly from the Hub for training, bypassing the need for local downloads. 4. Deploy: Pushes the trained policy back to the robot hardware with a simple configuration toggle.

"The bucket acts as the working layer that holds your data between the day you record it and the day you train on it. It sits beside your dataset repositories in the same hf:// namespace, utilizing the hf CLI you already know."

Prerequisites for the Pipeline

To get started, you will need a Python 3.12+ environment on Linux or macOS. The core requirements include:

  • Strands Robots: Installed with uv pip install -U "strands-robots[sim-mujoco,lerobot]>=0.5.1".
  • Model Provider: Access to Amazon Bedrock, Anthropic, OpenAI, or a local Ollama instance for agent reasoning.
  • Hugging Face Credentials: A token with write permissions and the hf CLI for bucket management.

Step 1: Recording and Syncing to Buckets

The Strands Robots Robot() factory handles the heavy lifting. Whether you are working with a simulated environment or a physical SO-101, the recording process remains consistent.

When you invoke agent("Record a pick-the-cube demo and sync it to my-org/robot-fave."), the agent initiates the DatasetRecorder. Once the episode concludes, the sync_dataset_to_bucket function validates the data and pushes it to the cloud. Because the bucket is mutable, you can continuously append new episodes to the same run_id, keeping your collection organized without the overhead of creating new repository versions for every minor update.

Step 2: Efficiency via Byte-Level Deduplication

One of the most significant challenges in robotics is the sheer volume of video data. Recording eight hours of table-clearing tasks results in massive amounts of redundant pixels—static backgrounds and lighting conditions that don't change.

By leveraging Xet-backed Storage Buckets, we utilize content-defined chunking. Unlike traditional object storage, which requires re-uploading an entire file if a single byte changes, Xet identifies the specific chunks that have been modified.

  • Reduced Bandwidth: Hugging Face benchmarks indicate that content-defined chunking can reduce data transfer per upload by approximately 4x.
  • Cost Efficiency: On Enterprise plans, billing is calculated based on the deduplicated footprint, not the raw file size.
  • Shard Management: Since LeRobot uses Parquet shards for data and MP4 shards for video, the system only uploads the new or modified trailing shards, rather than the entire dataset.

Step 3: Training via Streaming

The traditional "download-then-train" workflow is a bottleneck for GPU utilization. With StreamingLeRobotDataset, your GPUs no longer sit idle waiting for gigabytes of data to copy to local disk.

Instead, the training process performs byte-range reads directly from the bucket. The stream_dataset() method turns your remote data into a drop-in PyTorch iterable.

# Streaming directly from the bucket
reader = sim.stream_dataset("my-org/robot-fave/cube_pick", repo_type="bucket")
for batch in reader.dataloader(batch_size=64):
    loss, _ = policy(batch)
    loss.backward()

This method ensures that only the necessary metadata is stored locally, while camera frames are decoded on the fly. This architecture allows for immediate training, significantly reducing the time-to-experiment.

Step 4: Deployment and Iteration

Once the training run is complete, deploying the policy to your physical hardware is as simple as changing a single keyword argument. By setting mode="real" in your Robot() configuration, the agent switches from simulation to the physical controller.

The demonstrations recorded by the physical arm are then saved in the same LeRobot format, ready to be synced back to the bucket. This creates a self-improving loop: 1. Collect data on hardware. 2. Sync to the bucket. 3. Stream to the GPU for training. 4. Deploy the updated policy to the robot.

Security and Best Practices

As we move toward autonomous agents that interact with physical hardware and shared storage, security must be a priority:

  • Prompt Injection: Always treat input data as untrusted. Restrict the tools available to the agent to prevent unauthorized actions.
  • Trust Boundaries: Keep the credentials used for data collection separate from those used for training. Treat the versioned dataset repository as your "reviewed" artifact, while using buckets as a temporary, mutable workspace.
  • Code Execution: When loading models, ensure you are using trusted organizations. Set STRANDS_TRUST_REMOTE_CODE=1 only when you are certain of the source, and prefer safetensors over pickle-based checkpoints.

Conclusion

The integration of Strands Agents with Hugging Face Storage Buckets represents a major leap forward in the physical AI development lifecycle. By removing the friction of data management and enabling seamless streaming, we are allowing researchers and engineers to focus on what matters: building smarter, more capable robots.

For those ready to dive in, the full walkthrough is available in the Strands Robots GitHub repository. Whether you are fine-tuning a VLA or training a custom ACT policy, this loop provides the infrastructure to scale your robotics research from a single laptop to a full-scale fleet.

#rag#agentshugging face