Skip to content

Conversation

jd7-tr
Copy link
Contributor

@jd7-tr jd7-tr commented Aug 28, 2025

Summary:
X-link: pytorch/pytorch#161683

  1. There are a bunch of torch.ops.aten operations that can't handle KeyedTensor: The error was occurring because these ops expects a regular Tensor but was receiving a KeyedTensor object.

  2. Implement __torch_function__ for KeyedTensor, so when these incompatible operations are called with a KeyedTensor, the __torch_function__ method automatically delegates the op to the underlying values tensor from the KeyedTensor and returns a new KeyedTensor with updated values.

Reviewed By: malaybag

Differential Revision: D81047278

@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 Aug 28, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81047278

jd7-tr added a commit to jd7-tr/torchrec that referenced this pull request Aug 28, 2025
Summary:

X-link: pytorch/pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Reviewed By: malaybag

Differential Revision: D81047278
jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329


1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329


1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81047278

jd7-tr added a commit to jd7-tr/torchrec that referenced this pull request Aug 28, 2025
Summary:
Pull Request resolved: pytorch#3329

X-link: pytorch/pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Reviewed By: malaybag

Differential Revision: D81047278
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81047278

jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329

Pull Request resolved: pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
jd7-tr added a commit to jd7-tr/torchrec that referenced this pull request Aug 28, 2025
Summary:

X-link: pytorch/pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Reviewed By: malaybag

Differential Revision: D81047278
jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329


1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
Summary:
Pull Request resolved: pytorch#3329

X-link: pytorch/pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Reviewed By: malaybag

Differential Revision: D81047278
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81047278

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D81047278

jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329

Pull Request resolved: pytorch#161683

1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
jd7-tr added a commit to jd7-tr/pytorch that referenced this pull request Aug 28, 2025
Summary:
X-link: pytorch/torchrec#3329


1.  There are a bunch of `torch.ops.aten` operations that can't handle `KeyedTensor`: The error was occurring because these ops expects a regular `Tensor` but was receiving a `KeyedTensor` object.

2.  Implement `__torch_function__` for `KeyedTensor`, so when these incompatible operations are called with a `KeyedTensor`, the `__torch_function__` method automatically delegates the op to the underlying values tensor from the `KeyedTensor` and returns a new `KeyedTensor` with updated values.

Test Plan:
```
buck2 run mode/opt fbcode//aps_models/ads/gmp:launcher_with_publish mode=mtml_mobile_cvr_model/managed/Y2025Q2/local_mode_mtml_mobile_cvr_model_733415799_v0_fork +training.ir_serializer=manifold
```

MAST job: https://fburl.com/mlhub/pp937uxf

Rollback Plan:

Reviewed By: malaybag

Differential Revision: D81047278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants