Skip to main content

Async Gym Agents

Drop-in asynchronous data collection for Stable Baselines 3 agents.

Known framework callbacks are processed from complete episode batches when their timing permits. Off-policy checkpointing and unrecognized Stable Baselines callbacks retain their normal per-step behavior.

Usage

from functools import partial

import gymnasium as gym
from stable_baselines3 import TD3

from async_gym_agents.agents.async_agent import get_injected_agent
from async_gym_agents.envs.multi_env import IndexableMultiEnv

env = IndexableMultiEnv(
    [partial(gym.make, "Pendulum-v1") for _ in range(8)]
)
model = get_injected_agent(TD3)(
    "MlpPolicy",
    env,
    use_mp=False,
    max_episodes_in_buffer=8,
)

model.learn(total_timesteps=10)
model.shutdown()

Workers send complete episodes, so on-policy rollouts may exceed n_steps by the final episode. max_episodes_in_buffer limits buffered episodes across all workers. queue_put_timeout defaults to None; set a finite timeout to allow episode drops instead of waiting for buffer capacity.

Episodes are decoded in a background assembler. On-policy agents prepare the next rollout buffer, while off-policy agents prepare one episode ahead and keep replay-buffer insertion on the trainer thread.

On-policy episode packets retain both the environment reward and the time-limit-bootstrapped training reward. Stable Baselines callbacks, batched logging, and pruning receive the environment reward; rollout-buffer returns and advantages use the training reward. Off-policy episodes retain their existing single reward view.

Use get_profiler_report() to inspect trainer, worker, buffer, transport, and policy statistics. transport.utilization is the current fraction of bounded episode slots in use. Episode-send backpressure is reported once as buffer.avg_push_wait_seconds; the buffer section does not contain historical queue utilization or emptiness estimates.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async_gym_agents-0.4.0.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_gym_agents-0.4.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file async_gym_agents-0.4.0.tar.gz.

File metadata

  • Download URL: async_gym_agents-0.4.0.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.8 Windows/10

File hashes

Hashes for async_gym_agents-0.4.0.tar.gz
Algorithm Hash digest
SHA256 7f4af3137ad47704c36a64d0d1bee08f9f899b89e6b61581536bed5b929f9106
MD5 a08a75033827574e21b719450c198999
BLAKE2b-256 e40510c152a0dac10fe6b90ae74acc53a1728a04fc0230d2013f6c0fe34bc620

See more details on using hashes here.

File details

Details for the file async_gym_agents-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: async_gym_agents-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.8 Windows/10

File hashes

Hashes for async_gym_agents-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59398290aa01a6fe84579663cc95ad5bd51a29548d456ae3859ff7eb935236d0
MD5 e537cff7b7268cbab4d3d9b2ae66f328
BLAKE2b-256 55ea46495664617f262baa4905d6046e541af2270bb81258521d954a0a36df11

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page