mirror of
https://github.com/zml/zml.git
synced 2026-11-16 19:11:09 +00:00
zml/Tensor: explicit sharding in Tensor code (#868)
In Buffer code we already have explicit sharding, but not for tensor. I'm adding a `zml.Sharding` to `.withPartitioning` to make it explicit which mesh we are working with. To simplify the migration, `.withPartitioning` in Tensor code can use `.model` syntax to lookup a sharding by name. This replace the previous logic of `selectSharding(shape)` which would look up a sharding that matches the axes of the given partitioning which could yield surprising behavior. This also modifies how sharding are stored in zml.Shape. Before it was storing a list of axis names + a tag (2 * 8 * 64bits), now I'm storing a zml.Sharding (64 bits) and a compact PartitionArray (32 bits) that references the logical axis of the sharding by offset instead of by name. There is an impact on the `TensorRegistry` because it also needs to be aware of the possible shardings, instead of delegating the matching partition spec -> sharding to loading. This means error will be detected sooner. `store.createTensor` accepts `@enumLiteral()` to lookup the relevant sharding. This also simplifies `zml.Buffer` because the full sharding is now stored in the shape, so it doesn't need to be passed independently. It also means that it will propagate from the tensor who are graph inputs, to the buffers that are eg inputs. `Placement` logic also got a bit simpler.
This commit is contained in:
parent
3831492aa0
commit
b2f0e03043
59 changed files with 2095 additions and 1708 deletions
38
stdx/fmt.zig
38
stdx/fmt.zig
189
zml/Compiler.zig
189
zml/Compiler.zig
941
zml/Sharding.zig
941
zml/Sharding.zig
37
zml/exe.zig
37
zml/exe.zig
224
zml/io.zig
224
zml/io.zig
13
zml/meta.zig
13
zml/meta.zig
35
zml/nn.zig
35
zml/nn.zig
121
zml/ops.zig
121
zml/ops.zig
566
zml/shape.zig
566
zml/shape.zig
278
zml/tensor.zig
278
zml/tensor.zig
Loading…
Add table
Add a link
Reference in a new issue