Skip to content

Add treeless checkout ability to checkout-pytorch - #172544

Closed
zklaus wants to merge 3 commits into
gh/zklaus/25/basefrom
gh/zklaus/25/head
Closed

zklaus wants to merge 3 commits into
gh/zklaus/25/basefrom
gh/zklaus/25/head

Conversation

@zklaus

@zklaus zklaus commented Jan 15, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes use of the recently added test-infra/checkout action to provide treeless checkout abilities in the local checkout-pytorch action. It's use is demonstrated in the second PR in this stack.

Stack from ghstack (oldest at bottom):

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jan 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5aca110 with merge base ed18b31 (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 topic: not user facing topic category label Jan 15, 2026
@zklaus
zklaus marked this pull request as ready for review January 15, 2026 14:04
@zklaus
zklaus requested a review from a team as a code owner January 15, 2026 14:04
@zklaus
zklaus requested a review from atalman January 15, 2026 14:04
[ghstack-poisoned]
SergeyTyshkevich pushed a commit to SergeyTyshkevich/chart2 that referenced this pull request Jan 19, 2026
@zklaus
zklaus requested a review from atalman January 19, 2026 17:49

@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

@zklaus

zklaus commented Jan 20, 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 Jan 20, 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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@atalman
atalman self-requested a review January 20, 2026 16:42
@atalman

atalman commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Looks like same lint issue as in #172815 lets fix it.

suncapitalllc007-star pushed a commit to suncapitalllc007-star/pytorch that referenced this pull request Jan 25, 2026
[ghstack-poisoned]

@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

@zklaus

zklaus commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@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

kapilsh pushed a commit to kapilsh/pytorch that referenced this pull request Feb 2, 2026
This PR makes use of the recently added test-infra/checkout action to provide treeless checkout abilities in the local checkout-pytorch action. It's use is demonstrated in the second PR in this stack.

Pull Request resolved: pytorch#172544
Approved by: https://github.com/atalman
pytorchmergebot pushed a commit that referenced this pull request Feb 17, 2026
This PR uses the treeless checkout mode introduced in the first PR in this stack to do a (faster) treeless checkout in the `_linux-build` and `_linux-test` workflows.

~It is a draft for now because until the first PR in this stack (#172544) has made it into `main`, it needs to refer to a temporary branch.~

Pull Request resolved: #172545
Approved by: https://github.com/atalman
@github-actions
github-actions Bot deleted the gh/zklaus/25/head branch February 28, 2026 02:21
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
This PR uses the treeless checkout mode introduced in the first PR in this stack to do a (faster) treeless checkout in the `_linux-build` and `_linux-test` workflows.

~It is a draft for now because until the first PR in this stack (pytorch#172544) has made it into `main`, it needs to refer to a temporary branch.~

Pull Request resolved: pytorch#172545
Approved by: https://github.com/atalman
atalman added a commit to atalman/pytorch that referenced this pull request Apr 15, 2026
The addition of `single-branch: true` in pytorch#172544 prevented git tags from
being fetched during checkout. This caused `binary_populate_env.sh` to
fail to detect release candidate tags (e.g. v2.12.0-rc1) via
`git describe --tags --exact`, falling back to dev nightly versions.

Authored with Claude.
pytorchmergebot pushed a commit that referenced this pull request Apr 15, 2026
…180504)

## Summary

  Release candidate builds triggered by tags (e.g. `v2.12.0-rc1`) are incorrectly producing dev nightly versions instead of RC versions.

  The root cause is that #172544 added `single-branch: true` to the `checkout-pytorch` action when switching from `actions/checkout@v4` to `pytorch/test-infra/.github/actions/checkout@main`. With `single-branch: true`, git restricts the fetch refspec and tags are no longer fetched — even with `fetch-depth: 0`.

  This causes `binary_populate_env.sh` to fail at: git describe --tags --match 'v[0-9].[0-9].[0-9]*' --exact
  fatal: No names found, cannot describe anything.

  and fall through to the dev version path, producing `2.12.0.dev20260415+cpu` instead of `2.12.0+cpu`.

  The fix adds `fetch-tags: true` to both checkout steps (primary and retry) in the `checkout-pytorch` action, ensuring tags are explicitly fetched regardless of `single-branch` mode.

  Failing build: https://github.com/pytorch/pytorch/actions/runs/24474783525/job/71524093912

  ## Test plan

  - Verify that a workflow triggered by an RC tag (e.g. `v2.12.0-rc1`) correctly sets `PYTORCH_BUILD_VERSION=2.12.0+cpu` instead of
  `2.12.0.dev<date>+cpu`
  - Verify that nightly builds on the `nightly` branch are unaffected (they should still produce dev versions)
Pull Request resolved: #180504
Approved by: https://github.com/seemethere
pytorchbot pushed a commit that referenced this pull request Apr 15, 2026
…180504)

## Summary

  Release candidate builds triggered by tags (e.g. `v2.12.0-rc1`) are incorrectly producing dev nightly versions instead of RC versions.

  The root cause is that #172544 added `single-branch: true` to the `checkout-pytorch` action when switching from `actions/checkout@v4` to `pytorch/test-infra/.github/actions/checkout@main`. With `single-branch: true`, git restricts the fetch refspec and tags are no longer fetched — even with `fetch-depth: 0`.

  This causes `binary_populate_env.sh` to fail at: git describe --tags --match 'v[0-9].[0-9].[0-9]*' --exact
  fatal: No names found, cannot describe anything.

  and fall through to the dev version path, producing `2.12.0.dev20260415+cpu` instead of `2.12.0+cpu`.

  The fix adds `fetch-tags: true` to both checkout steps (primary and retry) in the `checkout-pytorch` action, ensuring tags are explicitly fetched regardless of `single-branch` mode.

  Failing build: https://github.com/pytorch/pytorch/actions/runs/24474783525/job/71524093912

  ## Test plan

  - Verify that a workflow triggered by an RC tag (e.g. `v2.12.0-rc1`) correctly sets `PYTORCH_BUILD_VERSION=2.12.0+cpu` instead of
  `2.12.0.dev<date>+cpu`
  - Verify that nightly builds on the `nightly` branch are unaffected (they should still produce dev versions)
Pull Request resolved: #180504
Approved by: https://github.com/seemethere

(cherry picked from commit ba240c9)
atalman added a commit that referenced this pull request Apr 15, 2026
…180508)

Enable fetch-tags in checkout-pytorch to fix release tag detection (#180504)

## Summary

  Release candidate builds triggered by tags (e.g. `v2.12.0-rc1`) are incorrectly producing dev nightly versions instead of RC versions.

  The root cause is that #172544 added `single-branch: true` to the `checkout-pytorch` action when switching from `actions/checkout@v4` to `pytorch/test-infra/.github/actions/checkout@main`. With `single-branch: true`, git restricts the fetch refspec and tags are no longer fetched — even with `fetch-depth: 0`.

  This causes `binary_populate_env.sh` to fail at: git describe --tags --match 'v[0-9].[0-9].[0-9]*' --exact
  fatal: No names found, cannot describe anything.

  and fall through to the dev version path, producing `2.12.0.dev20260415+cpu` instead of `2.12.0+cpu`.

  The fix adds `fetch-tags: true` to both checkout steps (primary and retry) in the `checkout-pytorch` action, ensuring tags are explicitly fetched regardless of `single-branch` mode.

  Failing build: https://github.com/pytorch/pytorch/actions/runs/24474783525/job/71524093912

  ## Test plan

  - Verify that a workflow triggered by an RC tag (e.g. `v2.12.0-rc1`) correctly sets `PYTORCH_BUILD_VERSION=2.12.0+cpu` instead of
  `2.12.0.dev<date>+cpu`
  - Verify that nightly builds on the `nightly` branch are unaffected (they should still produce dev versions)
Pull Request resolved: #180504
Approved by: https://github.com/seemethere

(cherry picked from commit ba240c9)

Co-authored-by: atalman <[email protected]>
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ytorch#180504)

## Summary

  Release candidate builds triggered by tags (e.g. `v2.12.0-rc1`) are incorrectly producing dev nightly versions instead of RC versions.

  The root cause is that pytorch#172544 added `single-branch: true` to the `checkout-pytorch` action when switching from `actions/checkout@v4` to `pytorch/test-infra/.github/actions/checkout@main`. With `single-branch: true`, git restricts the fetch refspec and tags are no longer fetched — even with `fetch-depth: 0`.

  This causes `binary_populate_env.sh` to fail at: git describe --tags --match 'v[0-9].[0-9].[0-9]*' --exact
  fatal: No names found, cannot describe anything.

  and fall through to the dev version path, producing `2.12.0.dev20260415+cpu` instead of `2.12.0+cpu`.

  The fix adds `fetch-tags: true` to both checkout steps (primary and retry) in the `checkout-pytorch` action, ensuring tags are explicitly fetched regardless of `single-branch` mode.

  Failing build: https://github.com/pytorch/pytorch/actions/runs/24474783525/job/71524093912

  ## Test plan

  - Verify that a workflow triggered by an RC tag (e.g. `v2.12.0-rc1`) correctly sets `PYTORCH_BUILD_VERSION=2.12.0+cpu` instead of
  `2.12.0.dev<date>+cpu`
  - Verify that nightly builds on the `nightly` branch are unaffected (they should still produce dev versions)
Pull Request resolved: pytorch#180504
Approved by: https://github.com/seemethere
pytorchmergebot pushed a commit that referenced this pull request Jul 27, 2026
…y fetch (#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in #172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in #166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom #189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. #189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. #189444 tried to instead bump the probe
timeout to wait the lazy fetch out; #189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply #189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: #191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ytorch#180504)

## Summary

  Release candidate builds triggered by tags (e.g. `v2.12.0-rc1`) are incorrectly producing dev nightly versions instead of RC versions.

  The root cause is that pytorch#172544 added `single-branch: true` to the `checkout-pytorch` action when switching from `actions/checkout@v4` to `pytorch/test-infra/.github/actions/checkout@main`. With `single-branch: true`, git restricts the fetch refspec and tags are no longer fetched — even with `fetch-depth: 0`.

  This causes `binary_populate_env.sh` to fail at: git describe --tags --match 'v[0-9].[0-9].[0-9]*' --exact
  fatal: No names found, cannot describe anything.

  and fall through to the dev version path, producing `2.12.0.dev20260415+cpu` instead of `2.12.0+cpu`.

  The fix adds `fetch-tags: true` to both checkout steps (primary and retry) in the `checkout-pytorch` action, ensuring tags are explicitly fetched regardless of `single-branch` mode.

  Failing build: https://github.com/pytorch/pytorch/actions/runs/24474783525/job/71524093912

  ## Test plan

  - Verify that a workflow triggered by an RC tag (e.g. `v2.12.0-rc1`) correctly sets `PYTORCH_BUILD_VERSION=2.12.0+cpu` instead of
  `2.12.0.dev<date>+cpu`
  - Verify that nightly builds on the `nightly` branch are unaffected (they should still produce dev versions)
Pull Request resolved: pytorch#180504
Approved by: https://github.com/seemethere
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…y fetch (pytorch#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in pytorch#172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in pytorch#166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom pytorch#189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. pytorch#189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. pytorch#189444 tried to instead bump the probe
timeout to wait the lazy fetch out; pytorch#189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply pytorch#189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: pytorch#191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
MelindaTan pushed a commit to MelindaTan/pytorch that referenced this pull request Jul 31, 2026
…y fetch (pytorch#191228)

The STABLE_SHIM_VERSION linter intermittently fails in CI with
`subprocess.TimeoutExpired` on `git diff <merge_base>..HEAD -- shim.h`,
reported as an internal linter bug.

Root cause: CI checks out a blobless partial clone (`--filter=blob:none`, added
in pytorch#172544; see .github/actions/checkout-pytorch/action.yml). The 5s diff
timeout predates that (added with the linter in pytorch#166995) and was correct then --
the diff was purely local. `merge_base_with_main()` fetches the merge-base
*commit* ahead of time, but the blobless filter deliberately omits file contents
even for explicitly fetched commits, so the merge-base blob of the linted file
is never local. When `git diff` needs it, git triggers an on-demand lazy fetch
in the middle of the command -- an uncontrolled network round-trip that races
the 5s timeout under the network contention of lintrunner running adapters
concurrently.

This is the same partial-clone symptom pytorch#189419 already fixed for the sibling
`git cat-file` probe in `merge_base_with_main()`, which was simply never applied
to the `git diff`/`git show` paths. pytorch#189419 established the design: keep a short
timeout as a fast "is it local?" probe and, on absence, fall back to an
explicit, controlled `git fetch`. pytorch#189444 tried to instead bump the probe
timeout to wait the lazy fetch out; pytorch#189946 reverted that, on the grounds that a
timeout is the signal that the object is not present, not something to wait out.
So bumping the diff timeout (or wrapping the diff in the retrying fetch helper to
wait it out) would repeat the already-reverted mistake.

Fix: apply pytorch#189419's design to the missing blob. `ensure_diff_blob_local()`
resolves the blob OID offline (trees are present under blob:none) and, only if
it is missing locally, fetches that single object through the existing retrying
network helper; the diff/show then runs entirely from local objects with a
short, honest timeout. `GIT_NO_LAZY_FETCH=1` guards the resolution and presence
checks so they cannot themselves trigger a fetch -- a deterministic improvement
over the cat-file probe's timeout race. In a full clone the blob is already
present and this is a no-op with no network access. The generated-shims linter's
prior 60s `git show` workaround is replaced by the same prefetch + 5s timeout.

Test Plan:
Verified locally in a full clone that the helper is a no-op and the git command
stays local and fast:

```
python tools/linter/adapters/stable_shim_version_linter.py \
    torch/csrc/inductor/aoti_torch/c/shim.h
```

End-to-end validation on a blobless partial clone still needs to run (the
sandbox has no network); it must confirm the single-blob
`git fetch --no-write-fetch-head origin <oid>` succeeds against GitHub's
promisor endpoint. If the explicit single-object fetch is rejected there, the
fallback is to trigger git's native lazy fetch through the same retry wrapper
(e.g. `git cat-file -p <oid>`).

Authored-with: Claude (AI assistant)
Pull Request resolved: pytorch#191228
Approved by: https://github.com/albanD, https://github.com/Skylion007, https://github.com/janeyx99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants