Skip to content

optim empty shard #13513#13598

Merged
chenyuxyz merged 11 commits intotinygrad:masterfrom
NinoRisteski:optimize-empty-shard
Dec 9, 2025
Merged

optim empty shard #13513#13598
chenyuxyz merged 11 commits intotinygrad:masterfrom
NinoRisteski:optimize-empty-shard

Conversation

@NinoRisteski
Copy link
Contributor

@NinoRisteski NinoRisteski commented Dec 6, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2025

This branch currently is behind tinygrad/master. The line count difference bot is disabled.

@chenyuxyz
Copy link
Collaborator

this needs some test

also it looks quite complicated, in what condition the shard can be created on each device instead of a copy?

@NinoRisteski
Copy link
Contributor Author

in what condition the shard can be created on each device instead of a copy?

Tried to simplify it. Shard can be created directly on each device only for empty tensors on a single device where the size divides evenly across all devices.

@chenyuxyz
Copy link
Collaborator

i think the correct fix is a rewrite rule that says copying empty is equivalent to creating the empty on the new device (assuming it's not used by other stuff), then you don't need a new code path in shard

@NinoRisteski
Copy link
Contributor Author

i think the correct fix is a rewrite rule that says copying empty is equivalent to creating the empty on the new device (assuming it's not used by other stuff), then you don't need a new code path in shard

Makes sense. Applied that.

@chenyuxyz chenyuxyz merged commit 76d465d into tinygrad:master Dec 9, 2025
43 checks passed
JakobSachs pushed a commit to JakobSachs/tinygrad that referenced this pull request Dec 10, 2025
* optim empty shard

* remove tuple

* simplify

* lint

* lint2

* test

* remove original buffer unique id

* new rule

* reset shard

* update

* reset shard
@NinoRisteski NinoRisteski deleted the optimize-empty-shard branch December 12, 2025 16:00
chenyuxyz added a commit to chenyuxyz/tinygrad that referenced this pull request Dec 27, 2025
chenyuxyz added a commit that referenced this pull request Dec 28, 2025
* Revert "optim empty shard #13513 (#13598)"

This reverts commit 76d465d.

* test_arange_shrink

* update test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants