liveBook · Manning

LayoutMap

As explained in Deep Learning with R, Third Edition

LayoutMap is a Keras API class that maps model-variable paths to sharding or replication specifications over a device mesh.

LayoutMap is a Keras API class that maps model-variable paths to tuples describing how each variable dimension is sharded or replicated across a device mesh. section 18.2.2

Assign layouts to model variables

Create a LayoutMap for a device mesh, then assign layouts by variable path: kernels use tuple(NULL, "model") to shard their second dimension, while biases use tuple("model") to distribute their dimension. 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")

The R example shows LayoutMap construction and path-based assignments for Dense-layer kernels and biases. section 18.2.2

A layout specifies one entry for each variable dimension:

  • NULL leaves a dimension unassigned to a mesh axis, while a named axis such as "model" controls its distribution. section 18.2.2
  • Variable paths are string identifiers such as sequential/dense_1/kernel. section 18.2.2

How Deep Learning with R, Third Edition covers it

How deep it goes
Defines path-to-tuple mappings and demonstrates assignments, without detailing compiler internals.
Examples
Uses Dense-layer kernel and bias paths with tuple(NULL, "model") and tuple("model") layouts.
What it assumes
Assumes a device mesh and familiarity with model variables and their string paths.
What you can do after
Operate Keras distribution configuration by assigning sharding layouts to model-variable paths.
How it connects
Connects variable paths, device meshes, sharding, replication, data parallelism, and model parallelism.

Also explained in

Compare how 2 books explain LayoutMap →

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.