Log inStart free
LESSON 16.23 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Vector environments: sync vs async

Watch copies of one env step as a batch, in one process or in many.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 16.23 · VECTOR ENV4 ENVS · FIRST BATCH 4 ROWS
01
Stage 1 of 5 · One batch
A vector environment holds 4 copies of the walk. One step call takes 4 actions and returns 4 observations.
Explain it simply

Each row on the left is one copy of the same small walk, and each copy has its own seed. The policy hands over a batch of actions, one for each copy. The batch below holds what comes back: one observation, one reward and one done flag for each copy.

4 env rows. First batch env ids: 0, 1, 2, 3. Actions: 1, 1, 0, 1. Observations: 3, 1, 1, 3.

env steppipe messageidle waitbatch back
0204060msmain processenv 0+1env 1+1env 2+1env 3+1env idactionobsrewarddone0130F1110F2010F3130Fenvstime → (async)0204060msmain processenv 0+1env 1+1env 2+1env 3+1env idactionobsrewarddone0130F1110F2010F3130Fenvstime → (async)
Toy: 2 to 8 copies of a 5-cell walk; times from a cost model
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
o, r, d=step(a)\sy{o}{out}{\mathbf{o}},\ \sy{r}{out}{\mathbf{r}},\ \sy{d}{out}{\mathbf{d}} = \text{step}(\sy{a}{data}{\mathbf{a}})
a=[1,1,0,1]  →  o=[3,1,1,3]\mathbf{a} = [1, 1, 0, 1] \;\to\; \mathbf{o} = [3, 1, 1, 3]

One call maps a batch of actions to a batch of results.

Common mix-ups

MYTHAsync vectorization always runs faster than sync.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With fast env steps, does async run faster or slower than sync?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.