Skip to content

Commit 4575d1a

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 38b2f4d + 7fe6ada commit 4575d1a

File tree

14 files changed

+46
-26
lines changed

14 files changed

+46
-26
lines changed

docs/source/hilserl.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This guide provides step-by-step instructions for training a robot policy using
2828
- A gamepad (recommended) or keyboard to control the robot
2929
- A Nvidia GPU
3030
- A real robot with a follower and leader arm (optional if you use the keyboard or the gamepad)
31-
- A URDF file for the robot for the kinematics package (check `lerobot/common/model/kinematics.py`)
31+
- A URDF file for the robot for the kinematics package (check `lerobot/model/kinematics.py`)
3232

3333
## What kind of tasks can I train?
3434

@@ -477,7 +477,7 @@ Create a training configuration file (example available [here](https://huggingfa
477477
1. Configure the policy settings (`type="sac"`, `device`, etc.)
478478
2. Set `dataset` to your cropped dataset
479479
3. Configure environment settings with crop parameters
480-
4. Check the other parameters related to SAC in [configuration_sac.py](https://github.com/huggingface/lerobot/blob/19bb621a7d0a31c20cd3cc08b1dbab68d3031454/lerobot/common/policies/sac/configuration_sac.py#L79).
480+
4. Check the other parameters related to SAC in [configuration_sac.py](https://github.com/huggingface/lerobot/blob/main/src/lerobot/policies/sac/configuration_sac.py#L79).
481481
5. Verify that the `policy` config is correct with the right `input_features` and `output_features` for your task.
482482

483483
**Starting the Learner**

docs/source/il_robots.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ The `record` function provides a suite of tools for capturing and managing data
323323
##### 2. Checkpointing and Resuming
324324

325325
- Checkpoints are automatically created during recording.
326-
- If an issue occurs, you can resume by re-running the same command with `--resume=true`.
326+
- If an issue occurs, you can resume by re-running the same command with `--resume=true`. When resuming a recording, `--dataset.num_episodes` must be set to the **number of additional episodes to be recorded**, and not to the targeted total number of episodes in the dataset !
327327
- To start recording from scratch, **manually delete** the dataset directory.
328328

329329
##### 3. Recording Parameters

docs/source/lekiwi.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ You should see on your laptop something like this: `[INFO] Connected to remote r
258258
| F | Decrease speed |
259259

260260
> [!TIP]
261-
> If you use a different keyboard, you can change the keys for each command in the [`LeKiwiConfig`](../src/lerobot/robot_devices/robots/configs.py).
261+
> If you use a different keyboard, you can change the keys for each command in the [`LeKiwiClientConfig`](https://github.com/huggingface/lerobot/blob/main/src/lerobot/robots/lekiwi/config_lekiwi.py).
262262
263263
### Wired version
264264

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dependencies = [
6161
# Hugging Face dependencies
6262
"datasets>=2.19.0,<=3.6.0", # TODO: Bumb dependency
6363
"diffusers>=0.27.2",
64-
"huggingface-hub[hf-transfer,cli]>=0.27.1",
64+
"huggingface-hub[hf-transfer,cli]>=0.27.1,<0.34.0",
6565

6666
# Core dependencies
6767
"cmake>=3.29.0.1",
@@ -75,7 +75,7 @@ dependencies = [
7575
"packaging>=24.2",
7676
"pynput>=1.7.7",
7777
"pyserial>=3.5",
78-
"wandb>=0.16.3",
78+
"wandb>=0.20.0",
7979

8080
"draccus==0.10.0", # TODO: Remove ==
8181
"gymnasium>=0.29.1,<1.0.0", # TODO: Bumb dependency

src/lerobot/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
# lists all available policies from `lerobot/policies`
171171
available_policies = ["act", "diffusion", "tdmpc", "vqbet"]
172172

173-
# lists all available robots from `lerobot/robot_devices/robots`
173+
# lists all available robots from `lerobot/robots`
174174
available_robots = [
175175
"koch",
176176
"koch_bimanual",
@@ -179,13 +179,13 @@
179179
"so101",
180180
]
181181

182-
# lists all available cameras from `lerobot/robot_devices/cameras`
182+
# lists all available cameras from `lerobot/cameras`
183183
available_cameras = [
184184
"opencv",
185185
"intelrealsense",
186186
]
187187

188-
# lists all available motors from `lerobot/robot_devices/motors`
188+
# lists all available motors from `lerobot/motors`
189189
available_motors = [
190190
"dynamixel",
191191
"feetech",

src/lerobot/envs/configs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def gym_kwargs(self) -> dict:
4444
@EnvConfig.register_subclass("aloha")
4545
@dataclass
4646
class AlohaEnv(EnvConfig):
47-
task: str = "AlohaInsertion-v0"
47+
task: str | None = "AlohaInsertion-v0"
4848
fps: int = 50
4949
episode_length: int = 400
5050
obs_type: str = "pixels_agent_pos"
@@ -82,7 +82,7 @@ def gym_kwargs(self) -> dict:
8282
@EnvConfig.register_subclass("pusht")
8383
@dataclass
8484
class PushtEnv(EnvConfig):
85-
task: str = "PushT-v0"
85+
task: str | None = "PushT-v0"
8686
fps: int = 10
8787
episode_length: int = 300
8888
obs_type: str = "pixels_agent_pos"
@@ -124,7 +124,7 @@ def gym_kwargs(self) -> dict:
124124
@EnvConfig.register_subclass("xarm")
125125
@dataclass
126126
class XarmEnv(EnvConfig):
127-
task: str = "XarmLift-v0"
127+
task: str | None = "XarmLift-v0"
128128
fps: int = 15
129129
episode_length: int = 200
130130
obs_type: str = "pixels_agent_pos"
@@ -200,10 +200,10 @@ class HILSerlRobotEnvConfig(EnvConfig):
200200
wrapper: EnvTransformConfig | None = None
201201
fps: int = 10
202202
name: str = "real_robot"
203-
mode: str = None # Either "record", "replay", None
203+
mode: str | None = None # Either "record", "replay", None
204204
repo_id: str | None = None
205205
dataset_root: str | None = None
206-
task: str = ""
206+
task: str | None = ""
207207
num_episodes: int = 10 # only for record mode
208208
episode: int = 0
209209
device: str = "cuda"
@@ -213,6 +213,7 @@ class HILSerlRobotEnvConfig(EnvConfig):
213213
# For the reward classifier, to record more positive examples after a success
214214
number_of_steps_after_success: int = 0
215215

216+
@property
216217
def gym_kwargs(self) -> dict:
217218
return {}
218219

@@ -222,9 +223,8 @@ def gym_kwargs(self) -> dict:
222223
class HILEnvConfig(EnvConfig):
223224
"""Configuration for the HIL environment."""
224225

225-
type: str = "hil"
226226
name: str = "PandaPickCube"
227-
task: str = "PandaPickCubeKeyboard-v0"
227+
task: str | None = "PandaPickCubeKeyboard-v0"
228228
use_viewer: bool = True
229229
gripper_penalty: float = 0.0
230230
use_gamepad: bool = True
@@ -252,7 +252,7 @@ class HILEnvConfig(EnvConfig):
252252
robot_config: RobotConfig | None = None
253253
teleop_config: TeleoperatorConfig | None = None
254254
wrapper: EnvTransformConfig | None = None
255-
mode: str = None # Either "record", "replay", None
255+
mode: str | None = None # Either "record", "replay", None
256256
repo_id: str | None = None
257257
dataset_root: str | None = None
258258
num_episodes: int = 10 # only for record mode

src/lerobot/policies/diffusion/modeling_diffusion.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,15 @@ def select_action(self, batch: dict[str, Tensor]) -> Tensor:
133133
"horizon" may not the best name to describe what the variable actually means, because this period is
134134
actually measured from the first observation which (if `n_obs_steps` > 1) happened in the past.
135135
"""
136+
# NOTE: for offline evaluation, we have action in the batch, so we need to pop it out
137+
if ACTION in batch:
138+
batch.pop(ACTION)
139+
136140
batch = self.normalize_inputs(batch)
137141
if self.config.image_features:
138142
batch = dict(batch) # shallow copy so that adding a key doesn't modify the original
139143
batch[OBS_IMAGES] = torch.stack([batch[key] for key in self.config.image_features], dim=-4)
140-
# Note: It's important that this happens after stacking the images into a single key.
144+
# NOTE: It's important that this happens after stacking the images into a single key.
141145
self._queues = populate_queues(self._queues, batch)
142146

143147
if len(self._queues[ACTION]) == 0:

src/lerobot/policies/pi0/modeling_pi0.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,10 @@ def sample_noise(self, shape, device):
515515
return noise
516516

517517
def sample_time(self, bsize, device):
518-
time_beta = sample_beta(1.5, 1.0, bsize, device)
518+
beta_dist = torch.distributions.Beta(concentration1=1.5, concentration0=1.0)
519+
time_beta = beta_dist.sample((bsize,)).to(device=device, dtype=torch.float32)
519520
time = time_beta * 0.999 + 0.001
520-
return time.to(dtype=torch.float32, device=device)
521+
return time
521522

522523
def embed_prefix(
523524
self, images, img_masks, lang_tokens, lang_masks

src/lerobot/policies/pi0fast/modeling_pi0fast.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ def __init__(self, config: PI0FASTConfig):
488488
param.data = param.data.to(dtype=torch_precision)
489489
self.set_requires_grad()
490490
self.image_keys = self.config.image_features.keys()
491+
# TODO: Remove this once we bump transformers to >4.52.0 because the attribute will be removed
492+
# AttributeError: 'PaliGemmaConfig' object has no attribute 'ignore_index'
491493
self.ignore_index = self.pi0_paligemma.config.ignore_index
492494
self.padding_side = self.config.padding_side
493495

src/lerobot/policies/smolvla/modeling_smolvla.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,13 @@ def get_optim_params(self) -> dict:
384384
return self.parameters()
385385

386386
def _get_action_chunk(self, batch: dict[str, Tensor], noise: Tensor | None = None) -> Tensor:
387+
# TODO: Check if this for loop is needed.
388+
# Context: In fact, self.queues contains only ACTION field, and in inference, we don't have action in the batch
389+
# In the case of offline inference, we have the action in the batch
390+
# that why without the k != ACTION check, it will raise an error because we are trying to stack
391+
# on an empty container.
387392
for k in batch:
388-
if k in self._queues:
393+
if k in self._queues and k != ACTION:
389394
batch[k] = torch.stack(list(self._queues[k]), dim=1)
390395

391396
images, img_masks = self.prepare_images(batch)
@@ -631,7 +636,7 @@ class VLAFlowMatching(nn.Module):
631636
└──────────────────────────────┘
632637
"""
633638

634-
def __init__(self, config):
639+
def __init__(self, config: SmolVLAConfig):
635640
super().__init__()
636641
self.config = config
637642

0 commit comments

Comments
 (0)