Skip to content

Fetch tags in unified manywheel build job so release tags are detected - #187001

Merged
atalman merged 1 commit into
pytorch:release/2.13from
atalman:fix_nightly_builds
Jun 11, 2026
Merged

atalman merged 1 commit into
pytorch:release/2.13from
atalman:fix_nightly_builds

Conversation

@atalman

@atalman atalman commented Jun 11, 2026 •

Copy link
Copy Markdown
Collaborator

Cherry-pick of ce9267a to release/2.13 branch

Fetch tags in unified manywheel build job so release tags are detected
Release candidate builds triggered by a tag (e.g. v2.13.0-rc1) were
producing wheels that pinned triton to a dev-style version such as
triton==3.7.1+git5d6048aa instead of the release triton==3.7.1, which
then fails to install in the test job because that version does not
exist on the test index.

Root cause: the unified inline manywheel build job (cpu/cpu-aarch64/
cuda/cuda-aarch64) checks out the raw commit via ref: github.sha with
fetch-depth: 2. Checking out a bare SHA does not fetch the tag ref, so
tagged_version() in .ci/pytorch/binary_populate_env.sh
(git describe --tags --exact) fails and the build falls through to the
<version>.dev<DATE> default. binary_populate_env.sh then takes its
.*dev.* branch and appends +git<triton-shorthash> to the triton
requirement that gets baked into the wheel metadata.

Fix: add fetch-tags: true to the inline build job checkout in the
linux binary build template so the tag pointing at the checked-out
commit is fetched, letting git describe --tags --exact succeed and the
build resolve to the release version. The ROCm/XPU/s390x builds use the
reusable _binary-build-linux.yml whose checkout has no pinned ref (it
uses the default tag ref for a tag push) and are unaffected.

This is the same class of bug fixed for the older checkout-pytorch path
in #180508; this covers the inlined unified build job introduced since.

Test Plan:

Regenerated the workflows from the template and confirmed only the two
linux manywheel workflows change, each gaining fetch-tags: true on its
four unified build jobs:

python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c 'fetch-tags: true' \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml

Validated the regenerated YAML parses and passes actionlint (the only
reported shellcheck warnings are pre-existing on the base files):

python3 -c "import yaml; yaml.safe_load(open(f)) for f in (...)"
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml

This PR was authored with the assistance of an AI coding assistant.

Release candidate builds triggered by a tag (e.g. v2.13.0-rc1) were
producing wheels that pinned triton to a dev-style version such as
triton==3.7.1+git5d6048aa instead of the release triton==3.7.1, which
then fails to install in the test job because that version does not
exist on the test index.

Root cause: the unified inline manywheel build job (cpu/cpu-aarch64/
cuda/cuda-aarch64) checks out the raw commit via `ref: github.sha` with
`fetch-depth: 2`. Checking out a bare SHA does not fetch the tag ref, so
`tagged_version()` in .ci/pytorch/binary_populate_env.sh
(`git describe --tags --exact`) fails and the build falls through to the
`<version>.dev<DATE>` default. binary_populate_env.sh then takes its
`.*dev.*` branch and appends `+git<triton-shorthash>` to the triton
requirement that gets baked into the wheel metadata.

Fix: add `fetch-tags: true` to the inline build job checkout in the
linux binary build template so the tag pointing at the checked-out
commit is fetched, letting `git describe --tags --exact` succeed and the
build resolve to the release version. The ROCm/XPU/s390x builds use the
reusable _binary-build-linux.yml whose checkout has no pinned ref (it
uses the default tag ref for a tag push) and are unaffected.

This is the same class of bug fixed for the older checkout-pytorch path
in pytorch#180508; this covers the inlined unified build job introduced since.

Test Plan:

Regenerated the workflows from the template and confirmed only the two
linux manywheel workflows change, each gaining `fetch-tags: true` on its
four unified build jobs:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c 'fetch-tags: true' \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only
reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml; yaml.safe_load(open(f)) for f in (...)"
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
@atalman
atalman requested a review from a team as a code owner June 11, 2026 01:35
@pytorch-bot

pytorch-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 Jun 11, 2026
@atalman
atalman merged commit d7a7b7d into pytorch:release/2.13 Jun 11, 2026
38 of 52 checks passed
pytorchmergebot pushed a commit that referenced this pull request Jun 11, 2026
…ag (#187042)

The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh (`git describe --tags --exact`) fails and the build falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

Root cause: #187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow; git does not write the tag ref locally. The proven path (the checkout-pytorch action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

Fix: in the linux binary build template, set `fetch-depth` to 0 on tag pushes (`github.ref_type == 'tag'`) and keep 2 for nightlies so they stay fast. With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 for the RC builds to pick it up.

Test Plan:

PR: #187047

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each unified build job getting the conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type == 'tag' && 0 || 2" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml, sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
Pull Request resolved: #187042
Approved by: https://github.com/NicolasHug, https://github.com/albanD, https://github.com/jeanschmidt
atalman added a commit that referenced this pull request Jun 11, 2026
…ag (#187055)

Full git fetch on tag pushes so release manywheel builds detect the tag (#187042)

The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh (`git describe --tags --exact`) fails and the build falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

Root cause: #187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow; git does not write the tag ref locally. The proven path (the checkout-pytorch action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

Fix: in the linux binary build template, set `fetch-depth` to 0 on tag pushes (`github.ref_type == 'tag'`) and keep 2 for nightlies so they stay fast. With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 for the RC builds to pick it up.

Test Plan:

PR: #187047

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each unified build job getting the conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type == 'tag' && 0 || 2" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml, sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
Pull Request resolved: #187042
Approved by: https://github.com/NicolasHug, https://github.com/albanD, https://github.com/jeanschmidt

(cherry picked from commit 80bd062)

Co-authored-by: atalman <[email protected]>
atalman added a commit to atalman/pytorch that referenced this pull request Jun 11, 2026
The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64)
check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release
tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow
checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh
(`git describe --tags --exact`) fails. The build then falls through to the
`<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD`
and pinning triton to a `+git<hash>` version that does not exist on the test
index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`.
`fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow --
git does not write the tag ref locally. The proven path (the checkout-pytorch
action) works because it uses `fetch-depth: 0`, where a full fetch brings all
tags regardless.

Fix: do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow
`fetch-depth: 2` for nightlies. The condition is expressed as:

    fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}

NOTE on the expression form: GitHub Actions has no ternary, so people emulate
one with `A && B || C`. That idiom only works when B is truthy. The naive
`github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real
tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it ALWAYS
yields 2 and the full-fetch branch is unreachable. (An earlier revision shipped
this broken form, which is why tag builds kept getting fetch-depth 2.) Negating
the condition keeps the truthy literal (2) as the `&&` operand so the result is
never swallowed:
  - tag:    `false && 2` -> false -> `false || 0` -> 0  (full fetch)
  - branch: `true && 2`  -> 2     ->                 2  (shallow)

With a full fetch the tag is present, `git describe --tags --exact` succeeds,
and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 (superseding the broken expression)
for the RC builds to pick it up.

Test Plan:

Regenerated the workflows from the template and confirmed only the two linux
manywheel workflows change, each of the 4 unified build jobs getting the
conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported
shellcheck warnings are pre-existing SC1090 on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
atalman added a commit to atalman/pytorch that referenced this pull request Jun 11, 2026
The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64)
check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release
tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow
checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh
(`git describe --tags --exact`) fails. The build then falls through to the
`<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD`
and pinning triton to a `+git<hash>` version that does not exist on the test
index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`.
`fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow --
git does not write the tag ref locally. The proven path (the checkout-pytorch
action) works because it uses `fetch-depth: 0`, where a full fetch brings all
tags regardless.

Fix: do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow
`fetch-depth: 2` for nightlies. The condition is expressed as:

    fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}

NOTE on the expression form: GitHub Actions has no ternary, so people emulate
one with `A && B || C`. That idiom only works when B is truthy. The naive
`github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real
tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it ALWAYS
yields 2 and the full-fetch branch is unreachable. (An earlier revision shipped
this broken form, which is why tag builds kept getting fetch-depth 2.) Negating
the condition keeps the truthy literal (2) as the `&&` operand so the result is
never swallowed:
  - tag:    `false && 2` -> false -> `false || 0` -> 0  (full fetch)
  - branch: `true && 2`  -> 2     ->                 2  (shallow)

With a full fetch the tag is present, `git describe --tags --exact` succeeds,
and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 (superseding the broken expression)
for the RC builds to pick it up.

Test Plan:

Regenerated the workflows from the template and confirmed only the two linux
manywheel workflows change, each of the 4 unified build jobs getting the
conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported
shellcheck warnings are pre-existing SC1090 on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
atalman added a commit to atalman/pytorch that referenced this pull request Jun 11, 2026
The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64)
check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release
tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow
checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh
(`git describe --tags --exact`) fails. The build then falls through to the
`<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD`
and pinning triton to a `+git<hash>` version that does not exist on the test
index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`.
`fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow --
git does not write the tag ref locally. The proven path (the checkout-pytorch
action) works because it uses `fetch-depth: 0`, where a full fetch brings all
tags regardless.

Fix: do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow
`fetch-depth: 2` for nightlies. The condition is expressed as:

    fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}

NOTE on the expression form: GitHub Actions has no ternary, so people emulate
one with `A && B || C`. That idiom only works when B is truthy. The naive
`github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real
tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it ALWAYS
yields 2 and the full-fetch branch is unreachable. (An earlier revision shipped
this broken form, which is why tag builds kept getting fetch-depth 2.) Negating
the condition keeps the truthy literal (2) as the `&&` operand so the result is
never swallowed:
  - tag:    `false && 2` -> false -> `false || 0` -> 0  (full fetch)
  - branch: `true && 2`  -> 2     ->                 2  (shallow)

With a full fetch the tag is present, `git describe --tags --exact` succeeds,
and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 (superseding the broken expression)
for the RC builds to pick it up.

Test Plan:

Regenerated the workflows from the template and confirmed only the two linux
manywheel workflows change, each of the 4 unified build jobs getting the
conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported
shellcheck warnings are pre-existing SC1090 on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
pytorchmergebot pushed a commit that referenced this pull request Jun 11, 2026
…etect the tag (#187047)

## Problem

The unified inline manywheel build jobs (`cpu` / `cpu-aarch64` / `cuda` / `cuda-aarch64`) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. `v2.13.0-rc1`) the tag ref is never written into that shallow checkout, so `tagged_version()` in `.ci/pytorch/binary_populate_env.sh` (`git describe --tags --exact`) fails. The build then falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

## Root cause

#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow -- git does not write the tag ref locally. The proven path (the `checkout-pytorch` action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

## Fix

Do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow `fetch-depth: 2` for nightlies:

```yaml
fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}
fetch-tags: ${{ github.ref_type == 'tag' }}
```

### Why the expression is written this way

GitHub Actions has no ternary, so the `A && B || C` idiom is used -- but it only works when `B` is **truthy**. The naive `github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it **always** yields `2` and the full-fetch branch is unreachable. An earlier revision shipped this broken form, which is why tag builds kept getting `fetch-depth: 2`.

Negating the condition keeps the truthy literal (`2`) as the `&&` operand so the value is never swallowed:

| trigger | expression | result |
|---|---|---|
| tag | `false && 2` -> false -> `false \|\| 0` | **0** (full fetch) |
| branch / nightly | `true && 2` -> 2 | **2** (shallow) |

With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

> Needs to be cherry-picked onto `release/2.13` (superseding the broken expression) for the RC builds to pick it up.

## Test Plan

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each of the 4 unified build jobs getting the conditional `fetch-depth` and `fetch-tags`:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing `SC1090` on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.

Pull Request resolved: #187047
Approved by: https://github.com/jeanschmidt, https://github.com/albanD
atalman added a commit that referenced this pull request Jun 11, 2026
…etect the tag (#187058)

Followup - Full git fetch on tag pushes so release manywheel builds detect the tag (#187047)

## Problem

The unified inline manywheel build jobs (`cpu` / `cpu-aarch64` / `cuda` / `cuda-aarch64`) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. `v2.13.0-rc1`) the tag ref is never written into that shallow checkout, so `tagged_version()` in `.ci/pytorch/binary_populate_env.sh` (`git describe --tags --exact`) fails. The build then falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

## Root cause

#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow -- git does not write the tag ref locally. The proven path (the `checkout-pytorch` action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

## Fix

Do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow `fetch-depth: 2` for nightlies:

```yaml
fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}
fetch-tags: ${{ github.ref_type == 'tag' }}
```

### Why the expression is written this way

GitHub Actions has no ternary, so the `A && B || C` idiom is used -- but it only works when `B` is **truthy**. The naive `github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it **always** yields `2` and the full-fetch branch is unreachable. An earlier revision shipped this broken form, which is why tag builds kept getting `fetch-depth: 2`.

Negating the condition keeps the truthy literal (`2`) as the `&&` operand so the value is never swallowed:

| trigger | expression | result |
|---|---|---|
| tag | `false && 2` -> false -> `false \|\| 0` | **0** (full fetch) |
| branch / nightly | `true && 2` -> 2 | **2** (shallow) |

With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

> Needs to be cherry-picked onto `release/2.13` (superseding the broken expression) for the RC builds to pick it up.

## Test Plan

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each of the 4 unified build jobs getting the conditional `fetch-depth` and `fetch-tags`:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing `SC1090` on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.

Pull Request resolved: #187047
Approved by: https://github.com/jeanschmidt, https://github.com/albanD

(cherry picked from commit 1e97809)

Co-authored-by: atalman <[email protected]>
jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
…ag (pytorch#187042)

The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh (`git describe --tags --exact`) fails and the build falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow; git does not write the tag ref locally. The proven path (the checkout-pytorch action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

Fix: in the linux binary build template, set `fetch-depth` to 0 on tag pushes (`github.ref_type == 'tag'`) and keep 2 for nightlies so they stay fast. With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 for the RC builds to pick it up.

Test Plan:

PR: pytorch#187047

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each unified build job getting the conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type == 'tag' && 0 || 2" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml, sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
Pull Request resolved: pytorch#187042
Approved by: https://github.com/NicolasHug, https://github.com/albanD, https://github.com/jeanschmidt
jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
…etect the tag (pytorch#187047)

## Problem

The unified inline manywheel build jobs (`cpu` / `cpu-aarch64` / `cuda` / `cuda-aarch64`) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. `v2.13.0-rc1`) the tag ref is never written into that shallow checkout, so `tagged_version()` in `.ci/pytorch/binary_populate_env.sh` (`git describe --tags --exact`) fails. The build then falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

## Root cause

pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow -- git does not write the tag ref locally. The proven path (the `checkout-pytorch` action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

## Fix

Do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow `fetch-depth: 2` for nightlies:

```yaml
fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}
fetch-tags: ${{ github.ref_type == 'tag' }}
```

### Why the expression is written this way

GitHub Actions has no ternary, so the `A && B || C` idiom is used -- but it only works when `B` is **truthy**. The naive `github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it **always** yields `2` and the full-fetch branch is unreachable. An earlier revision shipped this broken form, which is why tag builds kept getting `fetch-depth: 2`.

Negating the condition keeps the truthy literal (`2`) as the `&&` operand so the value is never swallowed:

| trigger | expression | result |
|---|---|---|
| tag | `false && 2` -> false -> `false \|\| 0` | **0** (full fetch) |
| branch / nightly | `true && 2` -> 2 | **2** (shallow) |

With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

> Needs to be cherry-picked onto `release/2.13` (superseding the broken expression) for the RC builds to pick it up.

## Test Plan

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each of the 4 unified build jobs getting the conditional `fetch-depth` and `fetch-tags`:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing `SC1090` on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.

Pull Request resolved: pytorch#187047
Approved by: https://github.com/jeanschmidt, https://github.com/albanD
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ag (pytorch#187042)

The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh (`git describe --tags --exact`) fails and the build falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow; git does not write the tag ref locally. The proven path (the checkout-pytorch action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

Fix: in the linux binary build template, set `fetch-depth` to 0 on tag pushes (`github.ref_type == 'tag'`) and keep 2 for nightlies so they stay fast. With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 for the RC builds to pick it up.

Test Plan:

PR: pytorch#187047

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each unified build job getting the conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type == 'tag' && 0 || 2" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml, sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
Pull Request resolved: pytorch#187042
Approved by: https://github.com/NicolasHug, https://github.com/albanD, https://github.com/jeanschmidt
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…etect the tag (pytorch#187047)

## Problem

The unified inline manywheel build jobs (`cpu` / `cpu-aarch64` / `cuda` / `cuda-aarch64`) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. `v2.13.0-rc1`) the tag ref is never written into that shallow checkout, so `tagged_version()` in `.ci/pytorch/binary_populate_env.sh` (`git describe --tags --exact`) fails. The build then falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

## Root cause

pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow -- git does not write the tag ref locally. The proven path (the `checkout-pytorch` action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

## Fix

Do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow `fetch-depth: 2` for nightlies:

```yaml
fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}
fetch-tags: ${{ github.ref_type == 'tag' }}
```

### Why the expression is written this way

GitHub Actions has no ternary, so the `A && B || C` idiom is used -- but it only works when `B` is **truthy**. The naive `github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it **always** yields `2` and the full-fetch branch is unreachable. An earlier revision shipped this broken form, which is why tag builds kept getting `fetch-depth: 2`.

Negating the condition keeps the truthy literal (`2`) as the `&&` operand so the value is never swallowed:

| trigger | expression | result |
|---|---|---|
| tag | `false && 2` -> false -> `false \|\| 0` | **0** (full fetch) |
| branch / nightly | `true && 2` -> 2 | **2** (shallow) |

With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

> Needs to be cherry-picked onto `release/2.13` (superseding the broken expression) for the RC builds to pick it up.

## Test Plan

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each of the 4 unified build jobs getting the conditional `fetch-depth` and `fetch-tags`:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing `SC1090` on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.

Pull Request resolved: pytorch#187047
Approved by: https://github.com/jeanschmidt, https://github.com/albanD
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ag (pytorch#187042)

The unified inline manywheel build jobs (cpu/cpu-aarch64/cuda/cuda-aarch64) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. v2.13.0-rc1) the tag ref is never written into that shallow checkout, so `tagged_version()` in .ci/pytorch/binary_populate_env.sh (`git describe --tags --exact`) fails and the build falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

Root cause: pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow; git does not write the tag ref locally. The proven path (the checkout-pytorch action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

Fix: in the linux binary build template, set `fetch-depth` to 0 on tag pushes (`github.ref_type == 'tag'`) and keep 2 for nightlies so they stay fast. With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

Needs to be cherry-picked onto release/2.13 for the RC builds to pick it up.

Test Plan:

PR: pytorch#187047

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each unified build job getting the conditional fetch-depth and fetch-tags:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type == 'tag' && 0 || 2" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing on the base files):

```
python3 -c "import yaml, sys; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.
Pull Request resolved: pytorch#187042
Approved by: https://github.com/NicolasHug, https://github.com/albanD, https://github.com/jeanschmidt
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…etect the tag (pytorch#187047)

## Problem

The unified inline manywheel build jobs (`cpu` / `cpu-aarch64` / `cuda` / `cuda-aarch64`) check out a pinned commit SHA with a shallow `fetch-depth: 2`. On a release tag push (e.g. `v2.13.0-rc1`) the tag ref is never written into that shallow checkout, so `tagged_version()` in `.ci/pytorch/binary_populate_env.sh` (`git describe --tags --exact`) fails. The build then falls through to the `<version>.dev<DATE>` default, producing wheels versioned `2.13.0.devYYYYMMDD` and pinning triton to a `+git<hash>` version that does not exist on the test index.

## Root cause

pytorch#187001 added `fetch-tags: true` but kept `fetch-depth: 2`. `fetch-tags` is ineffective when `ref` is a bare SHA and the fetch is shallow -- git does not write the tag ref locally. The proven path (the `checkout-pytorch` action) works because it uses `fetch-depth: 0`, where a full fetch brings all tags regardless.

## Fix

Do a full fetch (`fetch-depth: 0`) on tag pushes and keep the shallow `fetch-depth: 2` for nightlies:

```yaml
fetch-depth: ${{ github.ref_type != 'tag' && 2 || 0 }}
fetch-tags: ${{ github.ref_type == 'tag' }}
```

### Why the expression is written this way

GitHub Actions has no ternary, so the `A && B || C` idiom is used -- but it only works when `B` is **truthy**. The naive `github.ref_type == 'tag' && 0 || 2` is broken because `0` is falsy: on a real tag push it evaluates `true && 0` -> `0`, then `0 || 2` -> `2`, so it **always** yields `2` and the full-fetch branch is unreachable. An earlier revision shipped this broken form, which is why tag builds kept getting `fetch-depth: 2`.

Negating the condition keeps the truthy literal (`2`) as the `&&` operand so the value is never swallowed:

| trigger | expression | result |
|---|---|---|
| tag | `false && 2` -> false -> `false \|\| 0` | **0** (full fetch) |
| branch / nightly | `true && 2` -> 2 | **2** (shallow) |

With a full fetch the tag is present, `git describe --tags --exact` succeeds, and the build resolves to the release version with a clean triton requirement.

> Needs to be cherry-picked onto `release/2.13` (superseding the broken expression) for the RC builds to pick it up.

## Test Plan

Regenerated the workflows from the template and confirmed only the two linux manywheel workflows change, each of the 4 unified build jobs getting the conditional `fetch-depth` and `fetch-tags`:

```
python3 .github/scripts/generate_ci_workflows.py
git diff --stat .github/workflows
grep -c "github.ref_type != 'tag' && 2 || 0" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

Validated the regenerated YAML parses and passes actionlint (the only reported shellcheck warnings are pre-existing `SC1090` on `source "${BINARY_ENV_FILE}"`):

```
python3 -c "import yaml,sys;[yaml.safe_load(open(f)) for f in sys.argv[1:]]" \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
lintrunner --take ACTIONLINT \
  .github/workflows/generated-linux-binary-manywheel-nightly.yml \
  .github/workflows/generated-linux-aarch64-binary-manywheel-nightly.yml
```

This PR was authored with the assistance of an AI coding assistant.

Pull Request resolved: pytorch#187047
Approved by: https://github.com/jeanschmidt, https://github.com/albanD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants