Implementation:Danijar Dreamerv3 Parallel Env
| Knowledge Sources | |
|---|---|
| Domains | Reinforcement_Learning, Distributed_Systems, Environment |
| Last Updated | 2026-02-15 09:00 GMT |
Overview
Concrete tool for running an individual environment process that communicates with the actor inference server via RPC in distributed DreamerV3 training.
Description
The parallel_env() function in embodied/run/parallel.py deserializes the environment factory, creates the environment instance, connects to the actor server via portal.Client, and runs an infinite step loop. On each step, it sends the observation (with envid and is_eval tags) to the actor and receives an action. On disconnection, it reconnects and resets the episode.
Environment 0 additionally creates a logger client to report FPS and usage statistics.
Usage
Spawned as a separate process by combined() for each training and evaluation environment. Can also be launched independently as config.script == 'parallel_env'.
Code Reference
Source Location
- Repository: dreamerv3
- File: embodied/run/parallel.py
- Lines: L416-473
Signature
def parallel_env(make_env, envid, args, is_eval=False):
"""
Run a single environment process.
Args:
make_env: bytes or Callable(int) -> Env
envid: int - Unique environment index.
args: elements.Config with actor_addr, logger_addr, log_every.
is_eval: bool - Whether this is an evaluation environment.
"""
Import
from embodied.run.parallel import parallel_env
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| make_env | bytes or Callable | Yes | Factory for environment (cloudpickle-serialized) |
| envid | int | Yes | Unique environment index |
| args | elements.Config | Yes | actor_addr, logger_addr, log_every |
| is_eval | bool | No | Whether this is an evaluation environment (default False) |
Outputs
| Name | Type | Description |
|---|---|---|
| Observations | RPC calls | Sent to actor server via portal.Client.act() |
| Episode stats | RPC calls | Env 0 sends FPS and usage to logger server |
Usage Examples
# Spawned by combined():
import portal
import cloudpickle
for i in range(args.envs):
portal.Process(parallel_env, cloudpickle.dumps(make_env), i, args)
# Or standalone:
# python dreamerv3/main.py --script parallel_env --replica 0