You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is very convinient if I have a cuda or cpp primitive that I want to use in my custom partitioned function.
But for something pure jax I have to do
fromjax.experimental.shard_mapimportshard_mapdevices=mesh_utils.create_device_mesh((2,2))
mesh=Mesh(devices, axis_names=('a', 'b'))
sharding=jax.sharding.NamedSharding(mesh, P('a', 'b'))
@partial(shard_map,mesh=mesh,in_specs=(P('a', 'b'), P('a', 'b')),out_specs=P('a', 'b'))defmy_sharded_fn(x, y):
# do something with x and yreturnx+yout=my_sharded_fn(args)
Which is not as convinient as the first example.
My workaround is to define a custom partitioning rule with a pure jax implementation, but I have to rewrite the differentiation rule.
Does anyone know a better way to do this?
Can we somehow use the context mesh with shard_map
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I have been using custom_partitioning quite alot and it works very well.
But sometimes I want to define a per_shard implementation for something I can write in JAX (I don't want to rewrite the differentiation rule)
for example :
Is very convinient if I have a cuda or cpp primitive that I want to use in my custom partitioned function.
But for something pure jax I have to do
Which is not as convinient as the first example.
My workaround is to define a custom partitioning rule with a pure jax implementation, but I have to rewrite the differentiation rule.
Does anyone know a better way to do this?
Can we somehow use the context
mesh
withshard_map
Beta Was this translation helpful? Give feedback.
All reactions