Commit 2914f22
authored
### Ticket
#23224
### Problem description
We need to achieve parity between 2D and ND sharding by adding support
for specifying BufferRegion for ND sharded reads / writes.
Currently buffer dispatch internally handles BufferRegion logic, which
relies on getting 2D ShardSpec and utilizing the fact that
BufferPageMapping isn't arbitrary. Moreover buffer dispatch logic
utilizes ShardSpec to perform some optimizations for sharded buffer
dispatch instead of relying on BufferPageMapping.
This PR drastically changes sharded buffer dispatch by making it rely
only on the provided page mapping (not on the kind of sharding or shard
specs), and making BufferRegion handling completely universal and
separate from the dispatch.
### What's changed
BufferPageMapping used to contain a lot of duplicated and redundant
fields with different kinds of mappings, after this PR it only has a
single mapping, and it was renamed to UncompressedBufferPageMapping.
This PR introduces new BufferPageMapping which can be created from
UncompressedBufferPageMapping, and it basically identifies consecutive
lists of pages into ranges. This allows to perform the same kind of
optimizations in buffer dispatch in generic manner. Now
BufferPageMapping handles the logic to apply a BufferRegion and do the
appropriate filtering.
Buffer now holds and returns BufferPageMapping instead of
UncompressedBufferPageMapping.
Added `Buffer::view(BufferRegion)` method which returns a Buffer
corresponding to a region of the underlying root buffer while keeping
the root buffer alive. `bank_local_page_address` and
`sharded_page_address` were removed as obscure and not needed.
Updated the buffer dispatch logic, drastically simplifying it and
removing lots of edge cases
Updated all of the related usages to accommodate the new
BufferPageMapping API
Added new tests for BufferRegion read/writes for ND sharding
### Checklist
- [x] [All post commit CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/15697895877)
- [x] [Model regression CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/15661742169)
- [x] [Device performance regression CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/15661743686)
- [x] [Single-card demo tests CI
passes](https://github.com/tenstorrent/tt-metal/actions/runs/15661745385)
- [x] New/Existing tests provide coverage for changes
1 parent d61c4d2 commit 2914f22
File tree
21 files changed
+790
-631
lines changed- tests
- tt_metal/tt_metal/api
- circular_buffer
- distribution_spec
- ttnn/unit_tests/gtests/tensor
- tt_metal
- api/tt-metalium
- distributed
- impl
- buffers
- dispatch
- ttnn
- core
- cpp/ttnn/operations
- data_movement/sharded/reshard/device
- experimental/reshape
- sliding_window/halo/device
21 files changed
+790
-631
lines changedLines changed: 1 addition & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | 132 | | |
Lines changed: 29 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
303 | 306 | | |
304 | 307 | | |
305 | 308 | | |
| |||
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | | - | |
| 319 | + | |
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| |||
370 | 373 | | |
371 | 374 | | |
372 | 375 | | |
373 | | - | |
| 376 | + | |
374 | 377 | | |
375 | | - | |
| 378 | + | |
376 | 379 | | |
377 | | - | |
| 380 | + | |
378 | 381 | | |
379 | | - | |
| 382 | + | |
380 | 383 | | |
381 | 384 | | |
382 | 385 | | |
| |||
395 | 398 | | |
396 | 399 | | |
397 | 400 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
| |||
416 | 419 | | |
417 | 420 | | |
418 | 421 | | |
419 | | - | |
420 | | - | |
| 422 | + | |
| 423 | + | |
421 | 424 | | |
422 | 425 | | |
423 | 426 | | |
| |||
437 | 440 | | |
438 | 441 | | |
439 | 442 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
449 | 452 | | |
450 | 453 | | |
451 | 454 | | |
| |||
464 | 467 | | |
465 | 468 | | |
466 | 469 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
472 | 475 | | |
473 | 476 | | |
474 | 477 | | |
| |||
Lines changed: 63 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 48 | | |
| 49 | + | |
| 50 | + | |
57 | 51 | | |
58 | 52 | | |
59 | 53 | | |
60 | 54 | | |
61 | | - | |
| 55 | + | |
62 | 56 | | |
63 | 57 | | |
64 | 58 | | |
65 | 59 | | |
66 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
82 | 135 | | |
83 | 136 | | |
84 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 | | |
212 | 217 | | |
213 | 218 | | |
| |||
245 | 250 | | |
246 | 251 | | |
247 | 252 | | |
248 | | - | |
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
255 | | - | |
256 | | - | |
257 | 259 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | 260 | | |
264 | 261 | | |
265 | | - | |
266 | | - | |
267 | 262 | | |
268 | | - | |
269 | 263 | | |
270 | 264 | | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
271 | 270 | | |
272 | 271 | | |
273 | 272 | | |
| |||
325 | 324 | | |
326 | 325 | | |
327 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
328 | 333 | | |
329 | 334 | | |
330 | 335 | | |
331 | 336 | | |
332 | | - | |
| 337 | + | |
333 | 338 | | |
334 | 339 | | |
335 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments