Skip to content

[pytorch] address violations of warning unreachable-code-return (#177897) - #177897

Closed
yfeldblum wants to merge 1 commit into
pytorch:mainfrom
yfeldblum:export-D95726764
Closed

yfeldblum wants to merge 1 commit into
pytorch:mainfrom
yfeldblum:export-D95726764

Conversation

@yfeldblum

@yfeldblum yfeldblum commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

TSIA.

Test Plan: CI.

Differential Revision: D95726764

cc @mcarilli @ptrblck @leslie-fang-intel @jgong5 @EikanWang

@pytorch-bot

pytorch-bot Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit edbbdb9 with merge base ea0a353 (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

@meta-codesync

meta-codesync Bot commented Mar 19, 2026

Copy link
Copy Markdown

@yfeldblum has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95726764.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 19, 2026

@malfet malfet left a comment

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.

SW development moves in circles: one adds return to squash compiler errors, only to remove them later to squash another errors

Comment on lines 122 to 135
} else {
// We only support simple and static autocast expressions. For example,
// the following should report an error (since the autocast would not
// work as expected)
//
// autocast_on = autocast(enabled=True)
// autocast_off = autocast(enabled=False)
// with autocast_on if condition else autocast_off:
// ...
//
// TODO: better error message
//
TORCH_CHECK(false, "Unsupported autocast syntax");
}

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.

Nit, why not delete an else branch here

Suggested change
}
}
// We only support simple and static autocast expressions. For example,
// the following should report an error (since the autocast would not
// work as expected)
//
// autocast_on = autocast(enabled=True)
// autocast_off = autocast(enabled=False)
// with autocast_on if condition else autocast_off:
// ...
//
// TODO: better error message
//
TORCH_CHECK(false, "Unsupported autocast syntax");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with the pytorch codebase. My intention is simply to do the changes which are strictly required to avoid triggering the warning, and to limit all other changes.

return alloc<Rshift>(lhs, rhs);
default:
LOG(FATAL) << "unsupported expr_type: " << static_cast<int>(expr_type);
return nullptr;

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.

Please guard the return, or replace use of LOG with TORCH_CHECK

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The latest version of the PR fixes the non-glog implementation of LOG(FATAL) so that it is marked [[noreturn]]. It already would always throw or abort and never return, but that contract was not part of the interface. The current PR makes it part of the interface so that return; does not need a guard and so we do not need to replace uses, which can be a change of behavior.

@meta-codesync meta-codesync Bot changed the title [pytorch] address violations of warning unreachable-code-return [pytorch] address violations of warning unreachable-code-return (#177897) Mar 21, 2026
pytorch-bot Bot pushed a commit that referenced this pull request Mar 21, 2026
)

Summary:
Pull Request resolved: #177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
yfeldblum added a commit to yfeldblum/pytorch that referenced this pull request Mar 21, 2026
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
yfeldblum added a commit to yfeldblum/pytorch that referenced this pull request Mar 22, 2026
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
yfeldblum added a commit to yfeldblum/pytorch that referenced this pull request Mar 22, 2026
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
yfeldblum added a commit to yfeldblum/pytorch that referenced this pull request Mar 22, 2026
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
yfeldblum added a commit to yfeldblum/pytorch that referenced this pull request Mar 22, 2026
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
Comment on lines 17 to -19
return false;
}
return false;

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.

Not that it matters much, but why no default: break;} return false;? This makes it more explicit in case some other cases would also break

py::pickle(
/* __getstate__ */
[](const PyRRef& /* unused */) {
[](const PyRRef& /* unused */) -> py::tuple {

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.

Why not that? (To be consistent with return signature on line 407?)

Suggested change
[](const PyRRef& /* unused */) -> py::tuple {
[](const PyRRef& /* unused */) -> std::nullptr_t {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Below should have been PyRRef.

pytorch-bot Bot pushed a commit that referenced this pull request Mar 24, 2026
)

Summary:
Pull Request resolved: #177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764
…rch#177897)

Summary:
Pull Request resolved: pytorch#177897

TSIA.

Test Plan: CI.

Differential Revision: D95726764

@malfet malfet left a comment

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.

Let's not make any changes to FatalLogger, I'm going to submit a quick PR that removes Fatal from the codebase

@albanD
albanD removed their request for review March 27, 2026 18:49
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 6, 2026
Summary:
TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 7, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 7, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 7, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 7, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 13, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 13, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 13, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 13, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Reviewed By: malfet

Differential Revision: D95726764
ingridwang added a commit to ingridwang/pytorch that referenced this pull request Apr 14, 2026
…ytorch#179518)

Summary:
Pull Request resolved: pytorch#179518

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: pytorch#177897

Test Plan: CI.

Reviewed By: malfet

Differential Revision: D95726764
pytorchmergebot pushed a commit that referenced this pull request Apr 14, 2026
…179518) (#179518)

Summary:

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: #177897

Test Plan: CI.

Reviewed By: malfet

Differential Revision: D95726764

Pull Request resolved: #179518
Approved by: https://github.com/Skylion007, https://github.com/malfet
BoyuanFeng pushed a commit that referenced this pull request Apr 15, 2026
…179518) (#179518)

Summary:

TSIA. New PR to take over the changes while yfeldblum is on leave.

Old PR: #177897

Test Plan: CI.

Reviewed By: malfet

Differential Revision: D95726764

Pull Request resolved: #179518
Approved by: https://github.com/Skylion007, https://github.com/malfet
pytorchmergebot pushed a commit to scotts/pytorch that referenced this pull request Apr 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the Stale label May 26, 2026
@github-actions github-actions Bot closed this Jun 25, 2026
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants