Skip to content

build: fix the next Daily CI failures (array-api-compat>=1.14, macOS OpenMP) - #3031

Open
havogt wants to merge 12 commits into
mainfrom
daily-ci-aac-torch-macos
Open

havogt wants to merge 12 commits into
mainfrom
daily-ci-aac-torch-macos

Conversation

@havogt

@havogt havogt commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes two Daily CI regressions.

  • array-api-compat>=1.14: with 1.13 (the lowest-direct floor), clip uses a boolean-mask assignment that breaks torch.compile, so the 8 tests in test_nd_array_field_with_torch_compile.py fail. 1.14 implements clip with torch.clamp.
  • No torch on macOS: torch's wheel bundles its own libomp.dylib, and import gt4py.next loads it. The compiled gtfn/dace extensions link Homebrew's libomp. Two OpenMP runtimes in one process abort with OMP: Error #15, so the macOS nox sessions no longer install the torch extra and skip requires_torch tests.

`ArrayOps.take` clips indices against a runtime shape. array-api-compat 1.13
implements `clip` through a boolean-mask assignment (`out[mask] = ...`), whose
mask length is a data-dependent SymInt under Dynamo's fake tensors, so
`torch.compile(fullgraph=True)` raises `PendingUnbackedSymbolNotFound`. 1.14
added a torch-specific `clip` that calls `torch.clamp`.

Measured on abb8300 with the lowest-direct resolution (torch 2.15.0, numpy
2.1.0): 1.13.0 fails 8 tests in test_nd_array_field_with_torch_compile.py,
1.14.0/1.15.0/1.16.0 pass.
The torch wheels ship their own `libomp.dylib` (conda's `llvm-openmp` build),
while the extension links the Homebrew one. libomp registers itself per process
and aborts on a second initialisation with `OMP: Error #15`; every macOS
failure in the Daily CI since the torch extra was added is a gtfn or dace test
aborting that way. `KMP_DUPLICATE_LIB_OK` is read at exactly that check.

The two runtimes keep separate thread pools, so this is not what we would want
in a library; it is scoped to CI, where the alternative is not running the torch
tests on macOS at all.
@havogt

havogt commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Written by an agent on behalf of @havogt

Comment thread .github/workflows/daily-ci.yml Outdated
Comment on lines +8 to +13
## TEMPORARY: enabled to verify the array-api-compat and macOS OpenMP fixes on
## this PR. Remove together with the trimmed matrix before merging.
## It only works for PRs to `main` branch from branches in the upstream gt4py repo.
# pull_request:
# branches:
# - main
pull_request:
branches:
- main

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Temporary changes

Temporary CI changes are still in the diff and must be reverted before merging,
as the in-file comments and the third commit message state. If merged as-is, the
enabled pull_request trigger makes this scheduled Daily CI workflow run on
every PR targeting main, and the trimmed matrix further down in the same file
(next module only, Python 3.12 only, plus the strategy/os excludes) silently
drops nightly coverage for the cartesian, eve and storage modules and for
Python 3.13/3.14. Revert the temporary trigger and restore the full matrix
(e.g., drop the TEMP commit) before merge; the permanent fixes (the
array-api-compat floor bump and the macOS KMP_DUPLICATE_LIB_OK setting) can
then land on their own.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
✅ Merge recommendation: Changes required
🔎 Failure modes

What: The temporary workflow changes are merged as-is: the enabled `pull_request` trigger makes this heavy scheduled Daily CI workflow run on every PR targeting `main`, and the trimmed matrix (next module only, Python 3.12 only, plus the strategy/os excludes) silently drops nightly coverage for the cartesian, eve and storage modules and for Python 3.13/3.14.
Where: .github/workflows/daily-ci.yml:daily-ci (trigger and strategy.matrix)
Trigger: Merging the PR without reverting the TEMP commit; then any PR to main or the next nightly scheduled run.
Detected by: Reviewer attention to the TEMPORARY comments in the workflow; no automated check.
Covered in this PR: No

What: `KMP_DUPLICATE_LIB_OK=TRUE` suppresses the duplicate-runtime abort, but running two libomp instances in one process is documented as able to produce crashes or incorrect results, so macOS CI tests could fail intermittently or pass while parts of the workload ran on a mismatched OpenMP runtime.
Where: .github/workflows/daily-ci.yml:macOS setup step
Trigger: macOS jobs where a test process initializes both the torch-bundled libomp and the Homebrew-linked libomp and exercises both thread pools.
Detected by: Flaky or failing macOS Daily CI runs; a single green run does not rule out intermittent issues.
Covered in this PR: No

What: Raising the array-api-compat floor from 1.13 to 1.14 changes behavior for every array-api-compat call site, not only `clip` under torch.compile; regressions in other backends (e.g., CuPy/JAX paths) would not be exercised by the trimmed matrix run used to verify this PR.
Where: pyproject.toml:dependencies
Trigger: Environments resolving array-api-compat to 1.14+ while running the full next (or other module) backend test matrix.
Detected by: The full Daily CI / nox test_next sessions once the matrix is restored.
Covered in this PR: No

🏅 Score: 78
🧪 No relevant tests
🔒 No security concerns identified
🔀 Multiple PR themes

Sub-PR theme: build: require array-api-compat>=1.14 for torch.compile-compatible clip

Relevant files:

  • pyproject.toml
  • uv.lock

Sub-PR theme: ci: allow a duplicate OpenMP runtime on macOS Daily CI jobs

Relevant files:

  • .github/workflows/daily-ci.yml


⚙️ Agent run details
  • Model: openai/zai-org/GLM-5.3-Flash
  • Tokens: 8,255 in / 9,339 out / 17,594 total
  • Time cost: 84.7s
  • AI calls: 1

The torch wheels carry their own `libomp.dylib`, which clashes with the
Homebrew libomp the extension links: the process aborts with `OMP: Error #15`
and xdist reports `KeyError: <workercontroller gwN>`. Every macOS failure in
the Daily CI since the torch extra was added is a gtfn or dace test running in
an internal-codegen session.
Without the marker the dace benchmarks were selected by the `not uses_dace`
(internal) nox sessions and never by the `uses_dace` (dace) ones.
@havogt

havogt commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

50d4373 is an unrelated finding that came up while debugging the macOS OpenMP clash. It is not needed for the CI fix in this PR.

The dace parametrizations in tests/next_tests/benchmarks/benchmark_program_call.py had no uses_dace marker. That meant they ran in the internal (-m "not uses_dace") nox sessions and never in the dace ones. For example, in this PR's Daily CI job 137805550636, all five [run_dace_cpu_opt] benchmarks passed in test_next-3.12(internal, cpu, nomesh). The commit marks them, and the test ids stay the same. pytest --collect-only -m uses_dace tests/next_tests/benchmarks now selects the 5 dace cases, and -m "not uses_dace" selects the 5 gtfn cases.

🤖 Written by an agent on behalf of @havogt

The gpu sessions select `requires_gpu`, so the unmarked gtfn_gpu and
run_dace_gpu benchmark cases ran in no nox session. Also name the compiled
extensions in the macOS torch comment in noxfile.py.
The gpu benchmark cases passed host fields to the gpu backends, which the dace
gpu backend rejects; they had never run before they got `requires_gpu`.

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

LGTM

This branch was previously deployed

1 inactive (outdated) deployment
pr-agent — 267bc373 Deployed Nov 23, 2026 by havogt via pr-agent / pr-agent #174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants