Skip to content

[test] Add error_inputs for nn.Embedding module#174180

Closed
subinz1 wants to merge 1 commit intopytorch:mainfrom
subinz1:test-embedding-error-inputs
Closed

[test] Add error_inputs for nn.Embedding module#174180
subinz1 wants to merge 1 commit intopytorch:mainfrom
subinz1:test-embedding-error-inputs

Conversation

@subinz1
Copy link
Copy Markdown
Contributor

@subinz1 subinz1 commented Feb 3, 2026

Summary

Add module_error_inputs_torch_nn_Embedding function to test error messages for invalid inputs to nn.Embedding module.

Motivation

Currently, torch.nn.Embedding does not have module_error_inputs_func defined in common_modules.py. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

Test Cases Added

  1. Out of range indices: Tests IndexError when index exceeds num_embeddings

    • Input: Embedding(10, 3) with indices [0, 5, 15] (15 is out of range)
    • Expected: IndexError: index out of range in self
    • Note: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception
  2. Float indices: Tests RuntimeError when float tensor used instead of Long/Int

    • Input: Embedding(10, 3) with float tensor [1.5, 2.5]
    • Expected: RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int
  3. Negative num_embeddings: Tests RuntimeError when constructor has negative dimension

    • Input: Embedding(-1, 3)
    • Expected: RuntimeError: Trying to create tensor with negative dimension

Test Environment

  • Tested on H200 GPU with CUDA 12.8
  • Verified error messages match on CPU
  • CUDA tests pass for dtype and construction errors

Fixes #174179

cc @mruberry @albanD @jbschlosser

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Feb 3, 2026

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit bb6aa8e with merge base 07c056e (image):
💚 Looks good so far! There are no failures yet. 💚

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

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Feb 3, 2026

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@subinz1
Copy link
Copy Markdown
Contributor Author

subinz1 commented Feb 3, 2026

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Feb 3, 2026
Copy link
Copy Markdown
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Thanks!

samples = []

# Out of range indices: index exceeds num_embeddings
# Only test on CPU - CUDA triggers kernel assertion instead of Python exception
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cc @eqy I assume there is nothing we can do to make that behavior better on device?

@albanD
Copy link
Copy Markdown
Collaborator

albanD commented Feb 4, 2026

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 4, 2026
@albanD albanD added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 4, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: Claude Code

Details for Dev Infra team Raised by workflow job

@subinz1
Copy link
Copy Markdown
Contributor Author

subinz1 commented Feb 10, 2026

@pytorchbot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 2 jobs have failed, first few of them are: Claude Code, trunk / linux-jammy-cuda13.0-py3.10-gcc11 / test (default, 4, 5, linux.g6.4xlarge.experimental.nvidia.gpu)

Details for Dev Infra team Raised by workflow job

@albanD
Copy link
Copy Markdown
Collaborator

albanD commented Mar 27, 2026

@pytorchbot merge -r

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

Add `module_error_inputs_torch_nn_Embedding` function to test error messages
for invalid inputs to Embedding module:

1. Out of range indices: tests IndexError when index exceeds num_embeddings
   (CPU only - CUDA triggers kernel assertion instead of Python exception)
2. Float indices: tests RuntimeError when float tensor used instead of Long/Int
3. Negative num_embeddings: tests RuntimeError when constructor has negative dim

This enables regression testing for error messages and follows the existing
pattern used for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

Fixes pytorch#174179
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Successfully rebased test-embedding-error-inputs onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout test-embedding-error-inputs && git pull --rebase)

@pytorchmergebot pytorchmergebot force-pushed the test-embedding-error-inputs branch from 31ef347 to bb6aa8e Compare March 27, 2026 18:19
@pytorch-bot pytorch-bot bot removed the ciflow/trunk Trigger trunk jobs on your pull request label Mar 27, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Could not find commit that was pushed before comment 4144406938

Details for Dev Infra team Raised by workflow job

@subinz1
Copy link
Copy Markdown
Contributor Author

subinz1 commented Mar 28, 2026

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 28, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

AaronWang04 pushed a commit to AaronWang04/pytorch that referenced this pull request Mar 31, 2026
## Summary

Add `module_error_inputs_torch_nn_Embedding` function to test error messages for invalid inputs to `nn.Embedding` module.

## Motivation

Currently, `torch.nn.Embedding` does not have `module_error_inputs_func` defined in `common_modules.py`. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

## Test Cases Added

1. **Out of range indices**: Tests IndexError when index exceeds `num_embeddings`
   - Input: `Embedding(10, 3)` with indices `[0, 5, 15]` (15 is out of range)
   - Expected: `IndexError: index out of range in self`
   - **Note**: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception

2. **Float indices**: Tests RuntimeError when float tensor used instead of Long/Int
   - Input: `Embedding(10, 3)` with float tensor `[1.5, 2.5]`
   - Expected: `RuntimeError: Expected tensor for argument pytorch#1 'indices' to have one of the following scalar types: Long, Int`

3. **Negative num_embeddings**: Tests RuntimeError when constructor has negative dimension
   - Input: `Embedding(-1, 3)`
   - Expected: `RuntimeError: Trying to create tensor with negative dimension`

## Test Environment

- Tested on H200 GPU with CUDA 12.8
- Verified error messages match on CPU
- CUDA tests pass for dtype and construction errors

Fixes pytorch#174179

Pull Request resolved: pytorch#174180
Approved by: https://github.com/albanD
pytorch-bot bot pushed a commit that referenced this pull request Apr 2, 2026
## Summary

Add `module_error_inputs_torch_nn_Embedding` function to test error messages for invalid inputs to `nn.Embedding` module.

## Motivation

Currently, `torch.nn.Embedding` does not have `module_error_inputs_func` defined in `common_modules.py`. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

## Test Cases Added

1. **Out of range indices**: Tests IndexError when index exceeds `num_embeddings`
   - Input: `Embedding(10, 3)` with indices `[0, 5, 15]` (15 is out of range)
   - Expected: `IndexError: index out of range in self`
   - **Note**: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception

2. **Float indices**: Tests RuntimeError when float tensor used instead of Long/Int
   - Input: `Embedding(10, 3)` with float tensor `[1.5, 2.5]`
   - Expected: `RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int`

3. **Negative num_embeddings**: Tests RuntimeError when constructor has negative dimension
   - Input: `Embedding(-1, 3)`
   - Expected: `RuntimeError: Trying to create tensor with negative dimension`

## Test Environment

- Tested on H200 GPU with CUDA 12.8
- Verified error messages match on CPU
- CUDA tests pass for dtype and construction errors

Fixes #174179

Pull Request resolved: #174180
Approved by: https://github.com/albanD
pytorchmergebot pushed a commit that referenced this pull request Apr 2, 2026
# Motivation
#174180 introduces `nn.Embedding` module, which causes CI failures on XPU.

# Additional Context
fix #178854
fix #178762
Pull Request resolved: #178987
Approved by: https://github.com/mikaylagawarecki
IvanKobzarev pushed a commit to IvanKobzarev/pytorch that referenced this pull request Apr 3, 2026
## Summary

Add `module_error_inputs_torch_nn_Embedding` function to test error messages for invalid inputs to `nn.Embedding` module.

## Motivation

Currently, `torch.nn.Embedding` does not have `module_error_inputs_func` defined in `common_modules.py`. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

## Test Cases Added

1. **Out of range indices**: Tests IndexError when index exceeds `num_embeddings`
   - Input: `Embedding(10, 3)` with indices `[0, 5, 15]` (15 is out of range)
   - Expected: `IndexError: index out of range in self`
   - **Note**: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception

2. **Float indices**: Tests RuntimeError when float tensor used instead of Long/Int
   - Input: `Embedding(10, 3)` with float tensor `[1.5, 2.5]`
   - Expected: `RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int`

3. **Negative num_embeddings**: Tests RuntimeError when constructor has negative dimension
   - Input: `Embedding(-1, 3)`
   - Expected: `RuntimeError: Trying to create tensor with negative dimension`

## Test Environment

- Tested on H200 GPU with CUDA 12.8
- Verified error messages match on CPU
- CUDA tests pass for dtype and construction errors

Fixes pytorch#174179

Pull Request resolved: pytorch#174180
Approved by: https://github.com/albanD
weifengpy pushed a commit that referenced this pull request Apr 7, 2026
# Motivation
#174180 introduces `nn.Embedding` module, which causes CI failures on XPU.

# Additional Context
fix #178854
fix #178762
Pull Request resolved: #178987
Approved by: https://github.com/mikaylagawarecki
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
## Summary

Add `module_error_inputs_torch_nn_Embedding` function to test error messages for invalid inputs to `nn.Embedding` module.

## Motivation

Currently, `torch.nn.Embedding` does not have `module_error_inputs_func` defined in `common_modules.py`. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

## Test Cases Added

1. **Out of range indices**: Tests IndexError when index exceeds `num_embeddings`
   - Input: `Embedding(10, 3)` with indices `[0, 5, 15]` (15 is out of range)
   - Expected: `IndexError: index out of range in self`
   - **Note**: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception

2. **Float indices**: Tests RuntimeError when float tensor used instead of Long/Int
   - Input: `Embedding(10, 3)` with float tensor `[1.5, 2.5]`
   - Expected: `RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int`

3. **Negative num_embeddings**: Tests RuntimeError when constructor has negative dimension
   - Input: `Embedding(-1, 3)`
   - Expected: `RuntimeError: Trying to create tensor with negative dimension`

## Test Environment

- Tested on H200 GPU with CUDA 12.8
- Verified error messages match on CPU
- CUDA tests pass for dtype and construction errors

Fixes pytorch#174179

Pull Request resolved: pytorch#174180
Approved by: https://github.com/albanD
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
# Motivation
pytorch#174180 introduces `nn.Embedding` module, which causes CI failures on XPU.

# Additional Context
fix pytorch#178854
fix pytorch#178762
Pull Request resolved: pytorch#178987
Approved by: https://github.com/mikaylagawarecki
bobrenjc93 pushed a commit to bobrenjc93/pytorch that referenced this pull request Apr 9, 2026
## Summary

Add `module_error_inputs_torch_nn_Embedding` function to test error messages for invalid inputs to `nn.Embedding` module.

## Motivation

Currently, `torch.nn.Embedding` does not have `module_error_inputs_func` defined in `common_modules.py`. This PR adds error input tests to enable regression testing for error messages and follow the pattern already established for other modules (BatchNorm, GroupNorm, RNN cells, etc.).

## Test Cases Added

1. **Out of range indices**: Tests IndexError when index exceeds `num_embeddings`
   - Input: `Embedding(10, 3)` with indices `[0, 5, 15]` (15 is out of range)
   - Expected: `IndexError: index out of range in self`
   - **Note**: Only tested on CPU - CUDA triggers kernel assertion instead of Python exception

2. **Float indices**: Tests RuntimeError when float tensor used instead of Long/Int
   - Input: `Embedding(10, 3)` with float tensor `[1.5, 2.5]`
   - Expected: `RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int`

3. **Negative num_embeddings**: Tests RuntimeError when constructor has negative dimension
   - Input: `Embedding(-1, 3)`
   - Expected: `RuntimeError: Trying to create tensor with negative dimension`

## Test Environment

- Tested on H200 GPU with CUDA 12.8
- Verified error messages match on CPU
- CUDA tests pass for dtype and construction errors

Fixes pytorch#174179

Pull Request resolved: pytorch#174180
Approved by: https://github.com/albanD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test] Add error_inputs for nn.Embedding module

4 participants