1 of 20

Jax for scaling ALife tutorial: Biomaker CA

Ettore Randazzo* and Bert Chan**

*Google, Paradigms of Intelligence Team

**Google DeepMind

2 of 20

The environment

3 of 20

That is the core…

But if you want to see how to add more complex properties such as gradients of colors, here is the full implementation

4 of 20

key, env and programs are NOT static.

5 of 20

Highlights of the logic

  • All materials operations (air and earth) are executed for the entire grid, and then masked if the material is wrong.
    • This is because in jax you would anyway execute all conditions when vmapping.
  • Agent ops are more expensive, so instead we have a fixed budget of number of agents to run and we sparsely compute the updates.
    • We make sure that in our simulations the budget is always > #alive agents.
  • Exclusive operations (acting on somebody else) can cause conflicts, so they are atomically executed:
    • You propose an action, and we execute a subset of non-conflicting actions at each step.

The code is quite complex, but it is jittable. If you are brave, here it is.

6 of 20

Implementing exclusive ops

7 of 20

Implementing exclusive ops

8 of 20

Implementing exclusive ops

Implementation of AIR and EARTH ops

9 of 20

Now let’s implement some new materials

  • Disable earth nutrient generation from IMMUTABLE materials.
  • Create WATER: it falls, and if it touches EARTH, it gives it earth nutrients.
  • Create a WATER_GENERATOR: it creates WATER under it with a certain chance.

10 of 20

Extra material

Cut for time…

11 of 20

This is a variable input. As long as the size is the same, any function taking this as input won’t recompile.

12 of 20

13 of 20

14 of 20

15 of 20

This is a static input.

If you change it, the function recompiles.

16 of 20

Example on how to create environments and configs

17 of 20

A jittable function.

It detects where to place the seed.

18 of 20

The position is dynamic, so at-set doesn’t compile.

It needs to know the exact size of the update

19 of 20

Agent logic

You just think about what to do yourself.

Then, we vmap it twice to create the logic for a grid.

We can also (and do) optimize it for sparse computations.

20 of 20

Example: performing meta-evolution