Repository navigation
[cpu-offload] Fix wait_tensor dep edge for non-Tensor consumers - #3523
Merged
Merged
Conversation
[ghstack-poisoned]
mlazos
requested review from
IvanKobzarev,
SherlockNoMad,
aditvenk,
sanketpurandare,
tianyu-l,
xmfan and
yiming0416
as code owners
June 4, 2026 04:02
mlazos
added a commit
that referenced
this pull request
Jun 4, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: d604d77 Pull-Request: #3523
[ghstack-poisoned]
mlazos
added a commit
that referenced
this pull request
Jun 4, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: b153711 Pull-Request: #3523
mlazos
added a commit
that referenced
this pull request
Jun 4, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: b153711 Pull-Request: #3523
[ghstack-poisoned]
mlazos
added a commit
that referenced
this pull request
Jun 4, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: 9e5da19 Pull-Request: #3523
mlazos
added a commit
that referenced
this pull request
Jun 5, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: d912de2 Pull-Request: #3523
mlazos
added a commit
that referenced
this pull request
Jun 5, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: a3e7b0d Pull-Request: #3523
mlazos
added a commit
that referenced
this pull request
Jun 5, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: a3e7b0d Pull-Request: #3523
[ghstack-poisoned]
mlazos
added a commit
that referenced
this pull request
Jun 5, 2026
When the last forward consumer of an offloaded tensor's storage produces a non-Tensor value (e.g. aten.sort returns a tuple), the wait_tensor's last_use_of_storage arg cannot reference it directly (schema requires Optional[Tensor]). Previously this passed the node directly, causing a schema checker error at runtime. Fix: find a Tensor-producing child of the non-Tensor consumer (e.g. getitem after sort) and use that as the dep arg. This preserves the data dependency chain (tensor -> sort -> getitem -> wait_tensor) so the wait is always ordered after the real last consumer. ghstack-source-id: f7f063b Pull-Request: #3523
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
When the last forward consumer of an offloaded tensor's storage
produces a non-Tensor value (e.g. aten.sort returns a tuple), the
wait_tensor's last_use_of_storage arg cannot reference it directly
(schema requires Optional[Tensor]).
Previously this passed the node directly, causing a schema checker
error at runtime. Fix: find a Tensor-producing child of the
non-Tensor consumer (e.g. getitem after sort) and use that as the
dep arg. This preserves the data dependency chain
(tensor -> sort -> getitem -> wait_tensor) so the wait is always
ordered after the real last consumer.