Skip to content

Conversation

@sebimarkgraf
Copy link

Description

This reorders the function calls to make the device lookup, right before usage.
Also, this uses torch.zeros_like as argument for the torch.where call instead
of relying on autocasting.

Motivation and Context

We are observing issues to export the module into ONNX on intel devices.
This seems to be due to the tracer having issues to match the inserted constant for the 0 to constant zero node autocast.

Error:

<class 'AssertionError'>: Expected same OpOverload packet, got prim.device != aten.where
While executing %where : [num_users=1] = call_function[target=torch.ops.aten.where.ScalarSelf](args = (%expand, %scalar_tensor_default, %unsqueeze_2), kwargs = {})

Interestingly this issue only appears intermittently, we believe due to our CI landing on intel cpus with specific features activated.
Therefore, a direct reproduction is hard to detail.

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3239

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 24, 2025
Copy link
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@vmoens vmoens added the bug Something isn't working label Nov 25, 2025
@vmoens vmoens changed the title Use torch.zeros for argument in torch.where [BugFix] Use torch.zeros for argument in torch.where Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants