liveBook · Manning

Replication

As explained in Deep Learning with R, Third Edition

Replication is the copying of the same variable value to multiple devices along a device-mesh axis.

Replication copies one variable value across an axis of a device mesh, so every device along that axis sees the same value. It differs from sharding, which splits a variable into separate chunks. section 18.2.2

Replication decisions apply independently to each variable dimension. In a two-by-four mesh, devices can support data parallelism along one axis while split model computation is replicated across the other. section 18.2.2

Use replication when mapping variables to a distributed Keras model:

  • Create a LayoutMap associated with the device mesh. section 18.2.2
  • Describe each variable using its path and a tuple with one entry per dimension. section 18.2.2
  • Combine replicated model copies with sub-batches when using data parallelism. section 18.2.2
layout_map <- keras$distribution$LayoutMap(device_mesh)
layout_map["sequential/dense/kernel"]   <- tuple(NULL, "model")
layout_map["sequential/dense/bias"]     <- tuple("model")
layout_map["sequential/dense_1/kernel"] <- tuple(NULL, "model")
layout_map["sequential/dense_1/bias"]   <- tuple("model")

Inspect a LayoutMap that assigns layouts to model variables by path. section 18.2.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines replication, contrasts sharding, and assigns decisions per variable dimension through LayoutMap.
Examples
Uses a 32-by-64 variable and a two-by-four device mesh with replicated split-model copies processing sub-batches.
What you can do after
Apply it via Keras LayoutMap to place model variables across a device mesh.
How it connects
Connects replication to device meshes, sharding, data parallelism, model parallelism, and LayoutMap.

Also explained in

Compare how 13 books explain replication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Deep Learning with R, Third Edition. The section links point to the parts of the book it draws on.