diff --git a/docs/source/experimental-features/rlinf_vla_posttraining.rst b/docs/source/experimental-features/rlinf_vla_posttraining.rst index 81e72d0ea8d..490185dfe3f 100644 --- a/docs/source/experimental-features/rlinf_vla_posttraining.rst +++ b/docs/source/experimental-features/rlinf_vla_posttraining.rst @@ -33,11 +33,8 @@ Prerequisites - **Isaac Lab** installed and configured - **Isaac-GR00T** repo (for VLA inference and data transforms) - A **pretrained VLA checkpoint** in HuggingFace format. A pretrained GR00T checkpoint for - ``assemble_trocar`` is available and can be downloaded via: - - .. code-block:: bash - - hf download --repo-type model nvidia/Assemble_Trocar --local-dir /path/to/local/models + ``assemble_trocar`` is available on Hugging Face; download it after installing the dependency + pins (see :ref:`rlinf-assemble-trocar-checkpoint`). - Multi-GPU setup recommended (FSDP requires at least 1 GPU) Installation @@ -63,7 +60,7 @@ the alternative model dependencies below. # Step 2: Install packages with conflicting constraints (--no-deps to bypass resolver) uv pip install transformers==4.51.3 "tokenizers>=0.21,<0.22" \ - "huggingface-hub>=0.30,<1.0" --no-deps + "huggingface-hub>=0.34,<1.0" --no-deps # Use the official PyTorch3D v0.7.9 tag instead of the older pipablepytorch3d package. # GR00T N1.5 only uses pytorch3d.transforms, so skip the compiled extension. PYTORCH3D_NO_EXTENSION=1 uv pip install --no-build-isolation \ @@ -87,6 +84,20 @@ The packages installed above intentionally differ from the versions in the Isaac Lab lockfile. Use ``uv run --no-sync`` for the commands below so that ``uv`` does not replace these GR00T-compatible versions before launching. +.. _rlinf-assemble-trocar-checkpoint: + +Assemble Trocar checkpoint +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Download the pretrained GR00T N1.5 checkpoint for ``assemble_trocar`` after Step 2. With the +``huggingface-hub`` 1.x and ``typer`` 0.27 releases of the Isaac Lab lockfile, the ``hf`` command downloads +the files but then exits with a non-zero status and a ``click.exceptions.Exit`` traceback, so run it with the +pinned ``huggingface-hub`` release: + +.. code-block:: bash + + uv run --no-sync hf download --repo-type model nvidia/Assemble_Trocar --local-dir /path/to/local/models + .. _rlinf-skipping-flash-attn: Skipping flash-attn for N1.5 @@ -100,7 +111,7 @@ If Step 4 fails, skip installation of flash-attn and apply this patch instead: git apply /path/to/IsaacLab/scripts/imitation_learning/locomanipulation_sdg/gr00t/no_flash_attn.patch The patch switches GR00T to PyTorch SDPA, so flash-attn is no longer required. -The training and evaluation commands below work unchanged. This patch does not apply to N1.7. +The training and evaluation commands below work unchanged. N1.7 does not need this patch (see below). GR00T N1.7 ~~~~~~~~~~ @@ -113,6 +124,8 @@ package with incompatible APIs. After Step 1 above, replace Steps 2–4 with: uv pip install --no-deps \ "git+https://github.com/NVIDIA/Isaac-GR00T.git@1a1837f20538b7d7e21f977a11a5aee14f99803c" \ "transformers==4.57.3" "tokenizers>=0.22,<0.23" "huggingface-hub>=0.34,<1.0" + # Optional: building flash-attn requires a CUDA 13 nvcc. Without it, N1.7 logs a warning + # and runs the backbone with PyTorch SDPA attention instead. uv pip install --no-deps --no-build-isolation "flash-attn==2.8.3" Set ``actor.model.model_type: gr00t_n1d7`` in the task YAML. RLinf loads the model and @@ -151,18 +164,6 @@ The H2 examples use N1.7. Download the checkpoint for either task and the shared Authenticate with ``uv run --no-sync hf auth login`` if required, using an account with access to the selected checkpoint repositories. -The recorded evaluations used the task author's checkpoints below. Repository access is required; -anonymous requests return HTTP 401. - -* Apple: repository ``LiFanxing/pnp_apple``, revision ``1f136aee682574518e8fc36e20a091211f10c8b4``, - directory ``checkpoint_1``. -* Pack AGX: repository ``LiFanxing/pack_agx``, revision ``40a2c24c04e58a66d1c703dd0cb3027c696eb76c``, - directory ``rl_pack_agx_orin_contR_004pos_10ang-1/global_step_800``. - -To use either with the shared Cosmos backbone, authenticate and download the indicated directory at -its revision, then pass its local path to ``isaaclab play`` with ``--model_path``. The directory must -contain ``config.json``. - The H2 + Sharpa robot, NuRec capture, and scene objects are hosted on the official Isaac asset server under :attr:`~isaaclab.utils.assets.ISAACLAB_NUCLEUS_DIR`. To use a local mirror, configure the shared Isaac asset root before launching: @@ -172,7 +173,8 @@ Isaac asset root before launching: export ISAACSIM_ASSET_ROOT=/path/to/mirror The mirror must retain the ``Isaac/IsaacLab`` subtree, including ``Robots/Unitree/H2``, -``Environments/NuRec``, and ``Objects``. For example, the robot USD must be located at +``Environments/Grid`` (the default ground plane), ``Environments/NuRec``, and ``Objects``. +For example, the robot USD must be located at ``/path/to/mirror/Isaac/IsaacLab/Robots/Unitree/H2/H2_with_sharpa_flat.usd``. @@ -392,7 +394,8 @@ Key Files └── extension.py # Task registration, obs/action conversion For detailed configuration options, CLI arguments, and how to add new tasks, -use the unified ``uv run isaaclab train --rl_library rlinf`` and ``uv run isaaclab play --rl_library rlinf`` commands. +use the unified ``uv run --no-sync isaaclab train --rl_library rlinf`` and +``uv run --no-sync isaaclab play --rl_library rlinf`` commands. Attribution and Citation ------------------------ diff --git a/source/isaaclab_rl/changelog.d/rlinf-play-checkpoint-selectors.fixed.rst b/source/isaaclab_rl/changelog.d/rlinf-play-checkpoint-selectors.fixed.rst new file mode 100644 index 00000000000..41002fbcd54 --- /dev/null +++ b/source/isaaclab_rl/changelog.d/rlinf-play-checkpoint-selectors.fixed.rst @@ -0,0 +1,3 @@ +* Resolved ``--checkpoint latest`` and ``best`` in RLinf playback against the training task id recorded in + run manifests, so recipes with a separate evaluation task id find their checkpoints. +* Resolved a relative RLinf ``--config_path`` to an absolute directory, which Hydra requires. diff --git a/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/cli_args_rlinf.py b/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/cli_args_rlinf.py index cd81f6abccc..f84dd14a514 100644 --- a/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/cli_args_rlinf.py +++ b/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/cli_args_rlinf.py @@ -64,12 +64,13 @@ def resolve_config_dir(config_name: str, explicit_path: str | None) -> str: Resolution order: - 1. *explicit_path* if provided (``--config_path``). + 1. *explicit_path* if provided (``--config_path``), resolved to an absolute path. 2. The ``isaaclab_tasks`` package tree, searched for a matching YAML. 3. The directory containing the RLinf entrypoint implementation. """ if explicit_path is not None: - return explicit_path + # Hydra's initialize_config_dir() rejects relative directories + return str(Path(explicit_path).expanduser().resolve()) spec = importlib.util.find_spec("isaaclab_tasks") if spec is not None and spec.origin is not None: matches = list(Path(spec.origin).parent.rglob(f"{config_name}.yaml")) diff --git a/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/play_rlinf.py b/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/play_rlinf.py index 4d7374de577..6490a4d16f5 100644 --- a/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/play_rlinf.py +++ b/source/isaaclab_rl/isaaclab_rl/entrypoints/backends/play_rlinf.py @@ -96,10 +96,11 @@ def run(argv: list[str]) -> None: if args_cli.model_path: cfg.rollout.model.model_path = args_cli.model_path if args_cli.checkpoint: + # training runs record env.train.init_params.id in their manifests, which may differ from the eval id cfg.runner.ckpt_path = cli_args.resolve_rlinf_checkpoint( args_cli.checkpoint, log_root_path=str(Path("logs") / "rlinf"), - task=args_cli.task or task_id, + task=args_cli.task or cfg.env.train.init_params.id, config_name=config_name, ) if args_cli.video: diff --git a/source/isaaclab_rl/test/test_entrypoints.py b/source/isaaclab_rl/test/test_entrypoints.py index 220a3c4a4d9..bff680af2d1 100644 --- a/source/isaaclab_rl/test/test_entrypoints.py +++ b/source/isaaclab_rl/test/test_entrypoints.py @@ -512,9 +512,13 @@ def test_rlinf_rejects_pretrained_checkpoint() -> None: resolve_rlinf_checkpoint("pretrained", log_root_path="logs/rlinf", task="Isaac-Task", config_name="ppo") -@pytest.mark.parametrize("backend", [train_rlinf, play_rlinf], ids=["train", "play"]) -def test_rlinf_launch_passes_checkpoint_and_model_config_to_workers(tmp_path: Path, monkeypatch, backend) -> None: - """Real CLI composition supplies the native RLinf weight/resume hooks before workers start.""" +def test_rlinf_launch_passes_checkpoint_and_model_config_to_workers(tmp_path: Path, monkeypatch) -> None: + """Real CLI composition supplies the native RLinf weight/resume hooks before workers start. + + The config directory is given relative to the working directory. Training records its run manifest, and + playback resolves ``latest`` through that manifest although the recipe's eval task id differs from its + training id. + """ validate = mock.Mock(side_effect=RuntimeError("worker boundary")) modules = { "rlinf": {}, @@ -534,10 +538,6 @@ def test_rlinf_launch_passes_checkpoint_and_model_config_to_workers(tmp_path: Pa monkeypatch.chdir(tmp_path) for variable in ("PYTHONPATH", "RLINF_CONFIG_FILE", "RLINF_EXT_MODULE", "RAY_ENABLE_UV_RUN_RUNTIME_ENV"): monkeypatch.delenv(variable, raising=False) - step_dir = tmp_path / "checkpoints" / "global_step_400" - weights = step_dir / "actor" / "model_state_dict" / "full_weights.pt" - weights.parent.mkdir(parents=True) - weights.touch() cfg = OmegaConf.create( { "runner": {"logger": {"log_path": "unused"}}, @@ -545,23 +545,37 @@ def test_rlinf_launch_passes_checkpoint_and_model_config_to_workers(tmp_path: Pa "model": {"model_path": "./base", "model_type": "gr00t", "rl_head_config": {"add_value_head": True}} }, "rollout": {"model": {"model_path": "./rollout", "rl_head_config": {"disable_dropout": True}}}, - "env": {"train": {"init_params": {"id": "Test"}}, "eval": {"init_params": {"id": "Test"}}}, + "env": {"train": {"init_params": {"id": "Test"}}, "eval": {"init_params": {"id": "Test-Eval"}}}, } ) OmegaConf.save(cfg, tmp_path / "ppo.yaml") - checkpoint = step_dir if backend is train_rlinf else weights - args = ["--config_path", str(tmp_path), "--config_name", "ppo"] - args += ["--checkpoint", str(checkpoint.relative_to(tmp_path))] - with pytest.raises(RuntimeError, match="worker boundary"): - backend.run(args) - GlobalHydra.instance().clear() + + def launch(backend, checkpoint: str): + with pytest.raises(RuntimeError, match="worker boundary"): + backend.run(["--config_path", ".", "--config_name", "ppo", "--checkpoint", checkpoint]) + GlobalHydra.instance().clear() + resolved = validate.call_args.args[0] + assert resolved.actor.model.model_path == str(tmp_path / "base") + assert resolved.rollout.model.model_path == str(tmp_path / "rollout") + assert resolved.rollout.model.model_type == "gr00t" + assert dict(resolved.rollout.model.rl_head_config) == {"add_value_head": True, "disable_dropout": True} + return resolved + + resume_dir = tmp_path / "previous" / "global_step_400" + resume_weights = resume_dir / "actor" / "model_state_dict" / "full_weights.pt" + resume_weights.parent.mkdir(parents=True) + resume_weights.touch() + trained = launch(train_rlinf, str(resume_dir.relative_to(tmp_path))) assert os.environ["RAY_ENABLE_UV_RUN_RUNTIME_ENV"] == "0" - resolved = validate.call_args.args[0] - assert resolved.runner["resume_dir" if backend is train_rlinf else "ckpt_path"] == str(checkpoint) - assert resolved.actor.model.model_path == str(tmp_path / "base") - assert resolved.rollout.model.model_path == str(tmp_path / "rollout") - assert resolved.rollout.model.model_type == "gr00t" - assert dict(resolved.rollout.model.rl_head_config) == {"add_value_head": True, "disable_dropout": True} + assert trained.runner.resume_dir == str(resume_dir) + + # the training launch above created the only manifested run; RLinf saves checkpoints below its run directory + (run_dir,) = (tmp_path / "logs" / "rlinf").iterdir() + weights = run_dir / "checkpoints" / "global_step_8" / "actor" / "model_state_dict" / "full_weights.pt" + weights.parent.mkdir(parents=True) + weights.touch() + played = launch(play_rlinf, "latest") + assert played.runner.ckpt_path == str(weights) def test_run_backend_restores_sys_argv_after_training(monkeypatch) -> None: