unilab.base.process_device.resolve_backend_env_device_id¶
- unilab.base.process_device.resolve_backend_env_device_id(backend_type, *, devices=None, rank=0, local_rank=None, world_size=1, learner_device=None)[source]¶
Resolve the integer simulator device id for a training rank.
- Parameters:
backend_type (
str) – Selected UniSim backend.devices (
Sequence[int] |None) –training.devicesin the host-visible namespace. This is used by the off-policy launcher and by single-process PPO.rank (
int) – Off-policy data-parallel rank (rank zero by default).local_rank (
int|None) –LOCAL_RANKfrom torchrun. In a distributed PPO worker this is the logical index inside the launcher’s remappedCUDA_VISIBLE_DEVICESlist.world_size (
int) – Torchrun world size. Values greater than one select thelocal_ranknamespace; values of one selectdevices[rank].learner_device (
str|None) – Explicit learner device fallback when no topology was configured (for example APPO or a single-device play command).
- Return type:
Returns
Nonefor backends without an explicit simulator device field. For a torchrun worker the returned id is intentionally local (rather than the host index indevices), because the worker subprocess inherits the remappedCUDA_VISIBLE_DEVICESenvironment.