Skip to content

Commit e2d2f1c

Browse files
committed
Branch put_params_on_devices on sharding.is_fully_addressable
1 parent db21f3c commit e2d2f1c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/maxdiffusion/generate_flux2klein.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,12 @@ def unbox_fn(x):
381381
max_logging.log("🚀 Pinning all parameters to TPU HBM permanently...")
382382
max_logging.log("=" * 80 + "\n")
383383
def put_params_on_devices(params_tree, shardings_tree):
384-
return jax.device_put(params_tree, shardings_tree)
384+
def _put_leaf(param, sharding):
385+
if hasattr(sharding, "is_fully_addressable") and sharding.is_fully_addressable:
386+
return jax.device_put(param, sharding)
387+
return device_put_replicated(param, sharding)
388+
389+
return jax.tree_util.tree_map(_put_leaf, params_tree, shardings_tree)
385390

386391
max_logging.log("Putting params on TPU HBM...")
387392
with mesh, nn_partitioning.axis_rules(config.logical_axis_rules):

0 commit comments

Comments
 (0)