Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198915
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Unclassified FailureAs of commit 2cdb862 with merge base 9a9b93a ( 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. |
…nx job
ONNX Runtime sizes its intra-op thread pool from
std::thread::hardware_concurrency(), which reads _SC_NPROCESSORS_ONLN and
counts every CPU on the machine. On a Kubernetes runner the job holds an
exclusive cpuset a fraction that size, so ORT starts a thread per host CPU and
then fails to pin each one past the cpuset edge:
[E:onnxruntime:Default, env.cc:226 ThreadMain] pthread_setaffinity_np
failed for thread: 110251, index: 46, mask: {47, }, error code: 22
error msg: Invalid argument. Specify the number of threads explicitly so
the affinity is not set.
In a recent run that was 18,938 lines of a 24,895-line job log, alongside a
bidirectional-RNN test failing on numerics -- which a thread pool in that
state is a plausible cause of, though that is not proven here.
sched_getaffinity is cpuset-aware and reports the number ORT should have used,
so torch.onnx._internal._ort_threads returns it and the five places that build
a session pass it as intra_op_num_threads. This is what ORT's own error
message asks for. Two of those places are in torch.onnx rather than the tests,
so it also covers anyone running an exported model inside a container with a
CPU limit. Off a cpuset the two counts agree and nothing changes; the helper
falls back to os.cpu_count() where sched_getaffinity does not exist.
pytorch#198706 commented the onnx entry out of pull.yml, naming this as the thing
that had to be fixed first. That reason is now addressed, so the entry comes
back, on the runner it had before.
Authored with Claude Code.
huydhn
force-pushed
the
osdc/onnx-ort-threads
branch
from
September 28, 2026 19:04
ab8267f to
2cdb862
Compare
huydhn
added a commit
that referenced
this pull request
Sep 28, 2026
With every workflow naming its pod, the mapper has nothing left to translate. Its other behaviours are gone too: the ROCm and XPU passthroughs return their input unchanged, and the H100 `mt-` forcing is now literal in the workflows. One behaviour does disappear with it. The script dropped `config: "onnx"` from every ARC matrix, so that job has not run since the ARC switch. The entry is removed outright here rather than left behind commented out, and the reason it is gone -- onnxruntime sizes its intra-op thread pool from `hardware_concurrency()`, which reads `_SC_NPROCESSORS_ONLN` and counts the node rather than the pod's cpuset -- is recorded in #198915, which fixes that and restores the entry. An earlier version of this change did leave a commented-out entry with a prose comment above it, and that is what got it reverted. A test-matrix is a literal block scalar, interpolated verbatim into a double-quoted shell argument: --test-matrix "{ include: [ ... ]}" Every `"` inside toggles shell quoting. The live entries survive because their quotes wrap tokens with no spaces, so the fragments re-concatenate into one argument; the comment contained a quoted phrase with a space in it, the shell split there, and filter_test_configs.py got a stray argument: error: unrecognized arguments: failed in a 24k-line log, and a Letting onnx run first was still worth it, because it found a second reason it could not have passed. The OSDC pod exports `HF_HOME=/mnt/hf_cache`, the read-only mount, and .ci/pytorch/test.sh is what redirects it to the writable `HF_CACHE` the workflow prepares -- except it skipped onnx, a carve-out from #178928 when the old .ci/onnx/test.sh (which never set HF_HOME) was folded in. On EC2 that was harmless, since HF_HOME was unset and huggingface fell back to a writable home; on a pod onnx alone writes to the read-only mount and dies on `[Errno 30]`. That carve-out is dropped: it is wrong for any config. arc.yaml stays: it documents the naming scheme and the EC2 correspondence, which is still worth having as reference. ghstack-source-id: c44c11d Pull-Request: #198706
pytorchmergebot
pushed a commit
that referenced
this pull request
Sep 28, 2026
With every workflow naming its pod, the mapper has nothing left to translate. Its other behaviours are gone too: the ROCm and XPU passthroughs return their input unchanged, and the H100 `mt-` forcing is now literal in the workflows. One behaviour does disappear with it. The script dropped `config: "onnx"` from every ARC matrix, so that job has not run since the ARC switch. The entry is removed outright here rather than left behind commented out, and the reason it is gone -- onnxruntime sizes its intra-op thread pool from `hardware_concurrency()`, which reads `_SC_NPROCESSORS_ONLN` and counts the node rather than the pod's cpuset -- is recorded in #198915, which fixes that and restores the entry. An earlier version of this change did leave a commented-out entry with a prose comment above it, and that is what got it reverted. A test-matrix is a literal block scalar, interpolated verbatim into a double-quoted shell argument: --test-matrix "{ include: [ ... ]}" Every `"` inside toggles shell quoting. The live entries survive because their quotes wrap tokens with no spaces, so the fragments re-concatenate into one argument; the comment contained a quoted phrase with a space in it, the shell split there, and filter_test_configs.py got a stray argument: error: unrecognized arguments: failed in a 24k-line log, and a Letting onnx run first was still worth it, because it found a second reason it could not have passed. The OSDC pod exports `HF_HOME=/mnt/hf_cache`, the read-only mount, and .ci/pytorch/test.sh is what redirects it to the writable `HF_CACHE` the workflow prepares -- except it skipped onnx, a carve-out from #178928 when the old .ci/onnx/test.sh (which never set HF_HOME) was folded in. On EC2 that was harmless, since HF_HOME was unset and huggingface fell back to a writable home; on a pod onnx alone writes to the read-only mount and dies on `[Errno 30]`. That carve-out is dropped: it is wrong for any config. arc.yaml stays: it documents the naming scheme and the EC2 correspondence, which is still worth having as reference. Pull Request resolved: #198706 Approved by: https://github.com/jeanschmidt ghstack dependencies: #198704
This branch has not been deployed
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.
ONNX Runtime sizes its intra-op thread pool from
std::thread::hardware_concurrency(), which reads_SC_NPROCESSORS_ONLNand counts every CPU on the machine. On a Kubernetes runner the job holds an exclusive cpuset a fraction that size, so ORT starts a thread per host CPU and then fails to pin each one past the cpuset edge:In this run that was 18,938 lines of a 24,895-line job log, alongside a bidirectional-RNN test failing on numerics — which a thread pool in that state is a plausible cause of, though this PR does not prove that.
sched_getaffinityis cpuset-aware and reports the number ORT should have used, sotorch.onnx._internal._ort_threadsreturns it and the five places that build a session pass it asintra_op_num_threads— which is what ORT's own error message asks for. Two of those are intorch.onnxrather than the tests, so this also covers anyone running an exported model inside a container with a CPU limit. Off a cpuset the two counts agree and nothing changes; the helper falls back toos.cpu_count()wheresched_getaffinitydoes not exist.#198706 commented the onnx entry out of
pull.yml, naming this as the thing that had to be fixed first. That reason is now addressed, so the entry comes back, on the runner it had before.Testing
Draft, because the real test is CI: the onnx job runs again on this PR, and the question is whether the affinity spam is gone and the RNN test passes. If the spam clears but that test still fails, it is a separate bug and this should not re-enable onnx on its own.
Locally verified:
tools/linter/adapters/pyfmt_linter.py) clean on all 6 Python filesruff check/ruff format --checkclean, baselined against the unmodified files frommainpull.ymlparses; the clang21 matrix is back to 24 entries withonnxpresent_ort_threads.intra_op_num_threads()use has a matching importAuthored with Claude Code.