⚡Async Training: Hogwild!
This tutorial covers asynchronous training using Hogwild!—a technique for parallelizing network training across multiple processes with shared parameters.
How Hogwild! Works
Hogwild! enables lock-free parallel training by having multiple workers update shared network parameters simultaneously. SLM Lab implements this using PyTorch multiprocessing with shared memory.
Worker 1 ─┬─→ Shared Global Network ←─┬─ Worker 3
Worker 2 ─┘ (CPU) └─ Worker 4Each worker:
Collects experience from its own environment
Computes gradients on its local network
Pushes gradients to the shared global network
Pulls updated weights from global network
Global Networks on CPU: PyTorch's share_memory_() requires CPU tensors, so global networks are automatically moved to CPU. Local worker networks can still use GPU for forward/backward passes, but gradient sync happens on CPU.
Meta Spec for Hogwild!
Enable distributed training in the meta spec:
{
"meta": {
"distributed": "synced", // or "shared"
"max_session": 4 // Number of parallel workers
}
}Distributed Modes
"synced"
Sync parameters after each training step
A3C (on-policy)
"shared"
Continuous parameter sharing
Async SAC (off-policy)
false
Disabled (default)
Standard training
Key Requirements
GlobalAdamorGlobalRMSprop— Optimizers that support shared state across processesmax_session > 1— Number of parallel workers
A3C on Pong
A3C (Mnih et al., 2016) uses "synced" mode for on-policy training.
Spec: slm_lab/spec/benchmark/a3c/a3c_gae_pong.json
Run:
Async SAC on Humanoid
For off-policy algorithms like SAC, use "shared" mode for continuous parameter sharing.
Spec: slm_lab/spec/benchmark/async_sac/async_sac_mujoco.json
Run:
With 16 parallel sessions, a 50M frame run completes much faster than sequential training.
Historical Results (v4)
These graphs are from v4 async SAC training:


For validated v5 Humanoid results using synchronous PPO, see Continuous Benchmark—PPO achieves 3774 on Humanoid-v5.
Comparison: Async vs Vectorized
For most use cases, vectorized environments are simpler and faster:
Aspect
Vectorized (num_envs)
Hogwild! (distributed)
Parallelism
Environment stepping
Network training
Complexity
Simple
Complex (multiprocessing)
GPU
Full GPU acceleration
Global nets on CPU
Use case
Production
Learning, CPU-bound
When Hogwild! Helps
Hogwild! can help when:
Network training is the bottleneck (not environment stepping)
You have many CPU cores available
Learning about async RL architectures
For most RL workloads, environment stepping is the bottleneck, so vectorized environments (num_envs) are more effective.
Historical Context
A3C was groundbreaking when GPUs were expensive and CPU parallelism was the main scaling strategy. Today, GPU-accelerated vectorized training (PPO, A2C) is more practical for most use cases.
SLM Lab includes async training for:
Understanding async RL architectures
Reproducing classic papers
CPU-only training scenarios
Last updated
Was this helpful?