Conversation
pytorch#22663 added NestedCallsPreserveOuterThreadNumber, which asserts that an empty nested range never invokes its callback, and parameterized it over both parallel_for implementations. It added the guard to the threadpool one in extension/threadpool/thread_parallel.cpp but not to this one, so the release build calls f(begin, end) unconditionally and the test fails with "Empty nested range invoked its callback". Debug builds pass only by accident: they iterate c10::irange(begin, end), which is empty, so the callback is skipped as a side effect. Checking begin == end up front makes both branches agree by construction rather than by coincidence, which is why the check is above the #ifdef rather than duplicated into the release arm. This is what has been holding viable/strict since Sep 14: unittest-release fails on linux, macOS and windows, which reddens the trunk workflow, and trunk is required by update-viablestrict.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22869
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Pending, 1 Unclassified FailureAs of commit 0d06d2c with merge base 63d5e55 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review comments remain.
Pull request overview
Fixes release-only callback invocation for empty ranges in parallel_for_no_threadpool.
Changes:
- Adds a shared guard for
begin == end. - Aligns debug and release behavior.
File summaries
| File | Description |
|---|---|
runtime/kernel/thread_parallel_interface.h |
Prevents callbacks for empty ranges in all build modes. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
unittest-releasefailure that has been red onmainsince Sep 14, on linux, macOS and windows.The bug
#22663addedNestedCallsPreserveOuterThreadNumber, which asserts that an empty nested rangenever invokes its callback, and parameterized it over both
parallel_forimplementations. Itadded the guard to one of them:
extension/threadpool/thread_parallel.cpp— gotif (begin < end) { f(begin, end); }✅runtime/kernel/thread_parallel_interface.h— untouched by that PR ❌In the second,
parallel_for_no_threadpooldoes:Debug builds pass only by accident —
c10::irange(2, 2)is empty, so the callback is skipped as aside effect. Release builds call it, and the test fails ten times with
Empty nested range invoked its callback.That is exactly the observed CI signature:
unittestgreen on all three platforms,unittest-releasered on all three, on every affected commit. Platform-independent, as a pure
#ifdefdivergenceshould be.
The fix
Check
begin == endabove the#ifdefrather than duplicating the guard into the release arm, sothe two branches agree by construction instead of by coincidence.
Why it matters beyond the test
unittest-releaselives in thetrunkworkflow, andtrunkis inupdate-viablestrict'srequireslist. One red job reddens the workflow, which disqualifies the commit, soviable/stricthas not advanced since Sep 14 (51 commits). This is one of two blockers; the otheris the Samsung job, fixed separately in #22870.
Verification
Reproduced against the real header — DEBUG: 0 callback invocations, RELEASE: 1. Then built the
actual
extension/threadpool/test/thread_parallel_test.cpp:NestedCallsPreserveOuterThreadNumberFAILSNo new test is needed —
#22663's test already covers this and is the one that was failing.Caveat: my local harness linked without
ET_USE_THREADPOOL, so the/0variant routed through thesame function as
/1. The/1case, which is the actual CI failure, is faithful. I did not run iton Linux or Windows.
cc @JakeStevens @digantdesai — author and reviewer of
#22663.Authored with Claude Code.