Skip to content

[cpu-offload] Fix wait_tensor dep edge for non-Tensor consumers - #3523

Merged
mlazos merged 10 commits into
mainfrom
gh/mlazos/11/head
Jun 5, 2026
Merged

mlazos merged 10 commits into
mainfrom
gh/mlazos/11/head

Conversation

@mlazos

@mlazos mlazos commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

mlazos added 2 commits June 3, 2026 21:02
[ghstack-poisoned]
[ghstack-poisoned]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 4, 2026
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
mlazos added 2 commits June 3, 2026 21:27
[ghstack-poisoned]
[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

@SherlockNoMad SherlockNoMad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per comment

mlazos added 2 commits June 4, 2026 12:00
[ghstack-poisoned]
[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
[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: d912de2
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: 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
mlazos added 2 commits June 5, 2026 00:02
[ghstack-poisoned]
[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
@mlazos
mlazos changed the base branch from gh/mlazos/11/base to main June 5, 2026 08:00
@mlazos
mlazos merged commit 461375d into main Jun 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants