Skip to content

Create a mechanism to trigger tests that only warn once #47624

@mruberry

Description

@mruberry

Today in PyTorch we have TORCH_WARN and TORCH_WARN_ONCE. TORCH_WARN_ONCE, as its name suggests, only throws a warning one time. This makes it tricky to test for. Our test suite, for example, has maybeWarnsRegex, but this just verifies that no other warnings are thrown.

This feature request is for a mechanism to consistently trigger warnings that use TORCH_WARN_ONCE. One mechanism for this would be to add a new context that, if set, causes these warnings to always warn. This would let us reliably test that these warnings are thrown correctly.

cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @mruberry @VitalyFedyunin @walterddr

Metadata

Metadata

Assignees

Labels

function requestA request for a new function or the addition of new arguments/modes to an existing function.high prioritymodule: testsIssues related to tests (not the torch.testing module)triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions