Skip to content

Run a test shard against an editable install - #203390

Closed
zklaus wants to merge 1 commit into
pytorch:mainfrom
zklaus:editable-install-ci
Closed

zklaus wants to merge 1 commit into
pytorch:mainfrom
zklaus:editable-install-ci

Conversation

@zklaus

@zklaus zklaus commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Linked issue or supporting maintainer

Fixes #195888
Supported by @atalman

BC-breaking?

No

Summary (human written only)

Editable installs (pip install -e) are a crucial tool for developers locally. However, up to now we are not exercising it in the CI at all. This PR adds an editable install to the test matrix along with selected tests that are likely to be affected by subtle differences in install layout between editable and non-editable installs.

Agent details (if applicable)

Adds an editable config to the linux-jammy-py3.11-gcc11 test matrix in pull.yml, one shard on the 8-vCPU runner, and a test_editable function in .ci/pytorch/test.sh. The function uninstalls the wheel the test workflow just installed, runs WERROR=1 pip install --no-build-isolation --no-deps -v -e . in the test container (same shape as backwards_compat, which also builds from source in its test job; WERROR=1 matches the build job so that the rebuild can reuse the sccache it filled, and the sccache statistics are printed afterwards), asserts from test/ that torch.__file__ is in the checkout and torch._C in the install tree under build/install/, and runs the suites that resolve installed files: test_utils, test_license, test_testing, test_public_bindings, test_cpp_extensions_jit, test_cpp_extensions_aot_ninja, test_fx, and test_serialization. The list first also had test_jit -k TestBackends (#203621 has since removed test_jit), test_type_hints (its only test is skipped on Linux) and test_import_stats (asserts nothing); all three are dropped.

The test job checks out without submodules, so the function runs the same submodule update backwards_compat does before its source build; and target determination is off for the config (NO_TD=1, as test_dynamo_cpython does), because the list is the point of the job and TD trimmed it to a quarter on the first green run.

The list was chosen by running candidates against an editable install of a fresh clone (Python 3.12, scikit-build-core 1.1.2, CPU-only). Everything listed passes there; test_testing and test_public_bindings failed locally only for environment reasons (pytest 9 instead of the pinned 7.3.2 changes the junit outcome counts; tabulate, onnxscript and tensorboard were not installed) and are expected to pass in the CI image.

Two layout gaps the job does not close yet, left for #195891: find_library_location finds libtorchbind_test.so only through its build/lib fallback, which exists because the editable build runs in-tree; and test_license.test_distinfo_license skips itself under an editable install because it globs torch-*dist-info next to torch.__file__, which is the checkout under redirect mode. test_fx and test_license stay in the list so that they start testing the layout once that issue is fixed.

The config name editable contains none of the substrings the dispatch chain in test.sh matches before the exact names (*backward*, *inductor*, *cpu*, ...). The function ends with assert_git_not_dirty; the editable build writes only gitignored paths (build/, generated .pyi, torch/version.py).

🤖 Generated with Claude Code

@pytorch-bot

pytorch-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - Ready for human review:

The PR adds an `editable` config to the linux-jammy-py3.11-gcc11 matrix in
pull.yml. Its `test_editable` function in test.sh rebuilds torch as a
redirect-mode `pip install -e .`, checks that the import layout really is
editable, and runs eight suites that depend on install paths. Recommendation:
Approve. The earlier blocking sccache finding is fixed, and the review labels
every remaining point non-blocking.

Findings (6):

[minor] .ci/pytorch/test.sh:462
Non-blocking: `sccache --show-stats || true` hides the very misconfiguration the
stats are there to reveal. `print_sccache_stats` (common_utils.sh:421-443, used
at build.sh:506) fails loudly when SCCACHE_BUCKET is set but sccache is missing,
and _linux-test.yml:303 sets the bucket in this job. Printing right after the
rebuild is still the right place to do it, because the EXIT epilogue also counts
the test_cpp_extensions_* compiles and can't isolate the rebuild's hit rate.
Fix: call `print_sccache_stats` there, or drop `|| true`.

[minor] .ci/pytorch/test.sh:474
Non-blocking: test_serialization can't catch an editable-layout regression, so
"package data" in the comment overstates what it tests. Its only lookups based
on `__file__` (test/test_serialization.py:989,1004) use `get_file_path_2`, a
plain os.path.join, to read torch/testing/_internal/data/network{1,2}.py, which
are identical in the checkout and in the wheel. Nothing else in the suite
depends on the install layout, and the default shards already run it. Fix: drop
it, or narrow it with `-k` to the container tests and correct the comment.

[minor] .ci/pytorch/test.sh:467
Non-blocking: the comment admits that test_fx and test_license add no layout
coverage until # 195891 is fixed, yet the job still runs all of test_fx with
NO_TD=1. In CI the build/lib fallback is also filled by the downloaded build
artifact (_linux-build.yml:253 zips build/lib), so libtorchbind_test.so resolves
even if the editable build never produced it. test_distinfo_license is a skipIf
that won't start running on its own once the issue is fixed; that fix has to
edit test_license.py:34-35 anyway. Suggestion: add these two suites in the PR
that fixes # 195891, or narrow test_fx to the torchbind cases with `-k`.

[minor] .github/workflows/pull.yml:100
Non-blocking, carried over (REVIEW.md advisory): a new config with no run
history now gates every PR. It rebuilds PyTorch, fetches all submodules and runs
whole suites with NO_TD=1, and the build and test wall times from a green run
that the last review asked for have not been posted yet. It also rebuilds every
night: on the `29 8 * * *` schedule, filter_test_configs.py:691-694 turns
`editable` into a rerun_disabled_tests run (_linux-test.yml:307). test_editable
never checks PYTORCH_TEST_RERUN_DISABLED_TESTS, and in that mode
run_test.py:2772-2774 never exits 1, so that nightly run can only catch a broken
build or a failed layout check. backwards_compat sets a precedent, and @​ atalman
approved the placement. Optional fix: return early when
PYTORCH_TEST_RERUN_DISABLED_TESTS=1, or stage the job in unstable.yml first.

[minor] .ci/pytorch/test.sh:456
Non-blocking: the comment "WERROR=1 matches build.sh" still leaves out the numpy
difference. build.sh:320-323 installs numpy==2.0.2 before building on py3.11,
but the test image pins numpy==1.26.4 (requirements-ci.txt:152). So the
torch_python translation units that use the numpy headers miss the cache, and
the editable torch is built against numpy 1.x, unlike the wheel the other
configs test. Building against the numpy the tests use is defensible; one clause
in the comment saying so would do.

(1 more not shown, see the review run)

Reviewed commit: 82415eb

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

✅ No Failures

As of commit 82415eb with merge base 2299a47 (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 pytorch-bot Bot added the release notes: releng release notes category label Nov 4, 2026
@zklaus
zklaus force-pushed the editable-install-ci branch 2 times, most recently from 2b7252e to 7118f09 Compare November 4, 2026 17:57
@zklaus
zklaus marked this pull request as ready for review November 5, 2026 10:53
@zklaus
zklaus requested a review from a team as a code owner November 5, 2026 10:53
@zklaus
zklaus requested a review from atalman November 5, 2026 10:53
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 5, 2026

@atalman atalman 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.

lgtm, please rebase

@janeyx99 janeyx99 added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 10, 2026
github-actions[bot]

This comment was marked as outdated.

@zklaus
zklaus force-pushed the editable-install-ci branch from 7118f09 to a96b79d Compare November 11, 2026 10:48
github-actions[bot]

This comment was marked as outdated.

Every Linux test job installs the wheel the build job produced, so no
test has ever run against the redirect-mode editable layout, where the
Python sources come from the checkout and the CMake artifacts from an
install tree beside the distribution. That is how the __file__-derived
lookups tracked in pytorch#195887 went unnoticed: each one resolves correctly in
a wheel install and wrongly in an editable one.

This adds an `editable` config to the linux-jammy-py3.11-gcc11 matrix. The
test job uninstalls the wheel, runs `pip install -e . --no-build-isolation`
in the same container, asserts that the Python sources come from the
checkout and torch._C from the install tree, and runs the suites that
resolve installed files: the resolution helpers (test_utils, test_testing),
cpp_extension (the two cpp_extensions suites), package data
(test_serialization) and the public-API import sweep
(test_public_bindings). test_fx and test_license are in the list for
pytorch#195891, see below. Target determination is off for the config, as for
test_dynamo_cpython: the list is the point, and the whole of it runs in a
few minutes. The rebuild in the test job follows the backwards_compat
precedent, including the submodule checkout the test job skips. It sets
WERROR=1 as build.sh does, so that the compile commands match and the
rebuild can reuse the sccache the build job filled, and prints the sccache
statistics afterwards.

The list was verified against an editable install of a fresh clone
(Python 3.12, scikit-build-core 1.1.2, CPU): all of it passes. Two gaps it
does not yet close are left for pytorch#195891: find_library_location only finds
the test libraries through its build/lib fallback, which exists because the
editable build runs in-tree, and test_license's distinfo test skips itself
because it globs the dist-info next to torch.__file__, i.e. the checkout.
test_fx (torchbind) and test_license stay in the list so that they start
testing the layout once that issue is fixed.

Test Plan:
Local, against the editable install of the fresh clone on a shared Linux
box:

```
python -m pip install --no-build-isolation -v -e .
for t in test_utils test_license test_type_hints test_testing test_public_bindings \
         test_cpp_extensions_jit test_cpp_extensions_aot_ninja test_fx test_serialization \
         test_import_stats; do python test/run_test.py --include "$t" --verbose; done
spin lint
```

The list in the job is shorter than the one run locally. pytorch#203621 removed
test_jit, which had supplied `-k TestBackends`. test_type_hints and
test_import_stats were dropped after review: the only test of the former is
skipped on Linux, and the latter asserts nothing.

test_testing and test_public_bindings failed locally for environment
reasons only (pytest 9 instead of the pinned 7.3, missing tabulate,
onnxscript and tensorboard); the CI image has the pinned versions. The
job itself is exercised by this PR's own CI run.

Fixes pytorch#195888

Drafted with an AI assistant; reviewed by the author.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@zklaus
zklaus force-pushed the editable-install-ci branch from a96b79d to 82415eb Compare November 11, 2026 12:38

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of 82415eb: nothing blocking; ready for human review.

The PR adds an editable config to the linux-jammy-py3.11-gcc11 matrix in pull.yml. Its test_editable function in test.sh rebuilds torch as a redirect-mode pip install -e ., checks that the import layout really is editable, and runs eight suites that depend on install paths. Recommendation: Approve. The earlier blocking sccache finding is fixed, and the review labels every remaining point non-blocking.

⚪ 6 non-blocking findings

sccache --show-stats || true

Non-blocking: sccache --show-stats || true hides the very misconfiguration the stats are there to reveal. print_sccache_stats (common_utils.sh:421-443, used at build.sh:506) fails loudly when SCCACHE_BUCKET is set but sccache is missing, and linux-test.yml:303 sets the bucket in this job. Printing right after the rebuild is still the right place to do it, because the EXIT epilogue also counts the test_cpp_extensions* compiles and can't isolate the rebuild's hit rate. Fix: call print_sccache_stats there, or drop || true.


test_cpp_extensions_aot_ninja test_fx test_serialization --verbose

Non-blocking: test_serialization can't catch an editable-layout regression, so "package data" in the comment overstates what it tests. Its only lookups based on __file__ (test/test_serialization.py:989,1004) use get_file_path_2, a plain os.path.join, to read torch/testing/_internal/data/network{1,2}.py, which are identical in the checkout and in the wheel. Nothing else in the suite depends on the install layout, and the default shards already run it. Fix: drop it, or narrow it with -k to the container tests and correct the comment.


# public-API import sweep. test_fx and test_license are here for #195891: the torchbind

Non-blocking: the comment admits that test_fx and test_license add no layout coverage until # 195891 is fixed, yet the job still runs all of test_fx with NO_TD=1. In CI the build/lib fallback is also filled by the downloaded build artifact (_linux-build.yml:253 zips build/lib), so libtorchbind_test.so resolves even if the editable build never produced it. test_distinfo_license is a skipIf that won't start running on its own once the issue is fixed; that fix has to edit test_license.py:34-35 anyway. Suggestion: add these two suites in the PR that fixes # 195891, or narrow test_fx to the torchbind cases with -k.


{ config: "editable", shard: 1, num_shards: 1, runner: "${{ needs.get-label-type.outputs.label-type }}l-x86iavx512-8-64" },

Non-blocking, carried over (REVIEW.md advisory): a new config with no run history now gates every PR. It rebuilds PyTorch, fetches all submodules and runs whole suites with NO_TD=1, and the build and test wall times from a green run that the last review asked for have not been posted yet. It also rebuilds every night: on the 29 8 * * * schedule, filter_test_configs.py:691-694 turns editable into a rerun_disabled_tests run (_linux-test.yml:307). test_editable never checks PYTORCH_TEST_RERUN_DISABLED_TESTS, and in that mode run_test.py:2772-2774 never exits 1, so that nightly run can only catch a broken build or a failed layout check. backwards_compat sets a precedent, and @ atalman approved the placement. Optional fix: return early when PYTORCH_TEST_RERUN_DISABLED_TESTS=1, or stage the job in unstable.yml first.


# WERROR=1 matches build.sh, so the rebuild can reuse the sccache the build job just

Non-blocking: the comment "WERROR=1 matches build.sh" still leaves out the numpy difference. build.sh:320-323 installs numpy==2.0.2 before building on py3.11, but the test image pins numpy==1.26.4 (requirements-ci.txt:152). So the torch_python translation units that use the numpy headers miss the cache, and the editable torch is built against numpy 1.x, unlike the wheel the other configs test. Building against the numpy the tests use is defensible; one clause in the comment saying so would do.


test_editable() {

Non-blocking: the PR description no longer matches the code. It still lists test_type_hints and test_import_stats, and "Everything listed passes there" refers to that older, longer list. It says the job prints torch.__path__, but the job now prints torch._C.__file__ and fails unless the install is editable. It still says the sccache "makes it cheap" and doesn't mention WERROR=1.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@github-actions
github-actions Bot dismissed stale reviews from themself November 11, 2026 12:56

Withdrawn: the automated review of 82415eb found nothing blocking.

@zklaus

zklaus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Wall times from the green run on 82415eb, as asked for in the automated review. With WERROR=1 the rebuild in the test job comes out of the build job's sccache.

Numbers (collected from the job logs with an AI assistant)
11-04 run (7118f09) this run (82415eb)
Editable rebuild 36 min 20 s 3 min 26 s
sccache after the rebuild not printed 99.81 % hits (3187 hits, 6 misses)
Test suites about 14 min 13 min 15 s
Whole job 58 min 23 min 20 s

The layout check passes: torch/__init__.py is imported from the checkout and torch._C from build/install/cp311-cp311-linux_x86_64/.

The remaining non-blocking points (print_sccache_stats instead of || true, narrowing test_fx, test_serialization, the nightly rerun-disabled-tests mode) I would take up together with #195891.

@zklaus

zklaus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 11, 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

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ciflow/trunk Trigger trunk jobs on your pull request Merged open source ready for review Automated review passed, ready for a final review by a maintainer. release notes: releng release notes 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.

Install PyTorch editable in a CI job

5 participants