diff --git a/.github/workflows/release-diagnostic.yml b/.github/workflows/release-diagnostic.yml index 7902fbf9..4223fbf2 100644 --- a/.github/workflows/release-diagnostic.yml +++ b/.github/workflows/release-diagnostic.yml @@ -3,8 +3,20 @@ name: Release Diagnostic (not validation) on: workflow_dispatch: inputs: + incident: + description: "Immutable incident to investigate (never release validation)" + type: choice + options: + - "37199991757" + - "37217670612" + - "37286150846" + default: "37199991757" + disable_cpu_eigen_threads: + description: "Test FFT pool workaround (shapelet incident only)" + type: boolean + default: false repeats: - description: "Alternating control/candidate processes (2, 4 or 6)" + description: "Old incident comparison processes (2, 4 or 6); new incidents use fixed fresh-fit counts" type: number default: 6 @@ -17,7 +29,7 @@ jobs: timeout-minutes: 40 env: PYTHONPATH: "" - MANIFEST: diagnostics/release-37199991757.json + MANIFEST: diagnostics/release-${{ inputs.incident || '37199991757' }}.json steps: - uses: actions/checkout@v4 - name: Validate immutable manifest and write requirements @@ -50,6 +62,14 @@ jobs: --report diagnostic-results/pip-install.json \ -r diagnostic-results/requirements.txt diagnostic-env/bin/python -m pip install py-spy + echo "$PWD/diagnostic-env/bin" >> "$GITHUB_PATH" + sudo apt-get update -qq + sudo apt-get install -y -qq gdb + # Ephemeral runner only; allow sibling debuggers to attach to Python. + sudo sysctl -w kernel.yama.ptrace_scope=0 + - name: Install candidate for the original runtime comparison + if: (inputs.incident || '37199991757') == '37199991757' + run: | python .github/scripts/release_diagnostic.py prepare --candidate \ --manifest "$MANIFEST" --output diagnostic-results/candidate-install python -m venv diagnostic-candidate @@ -58,12 +78,8 @@ jobs: --extra-index-url https://pypi.org/simple \ --report diagnostic-results/candidate-install/pip-install.json \ -r diagnostic-results/candidate-install/requirements.txt - echo "$PWD/diagnostic-env/bin" >> "$GITHUB_PATH" - sudo apt-get update -qq - sudo apt-get install -y -qq gdb - # Ephemeral runner only; allow sibling debuggers to attach to Python. - sudo sysctl -w kernel.yama.ptrace_scope=0 - name: Interleaved runtime comparison against the same release wheels + if: (inputs.incident || '37199991757') == '37199991757' env: REPEATS: ${{ inputs.repeats || 6 }} run: >- @@ -72,6 +88,30 @@ jobs: --workspace diagnostic-workspace --hands diagnostic-hands --candidate-python diagnostic-candidate/bin/python --repeats "$REPEATS" + - name: Capture the current incident in one fresh bounded fit + if: inputs.incident == '37217670612' + run: >- + diagnostic-env/bin/python .github/scripts/release_diagnostic.py run + --manifest "$MANIFEST" --output diagnostic-results + --workspace diagnostic-workspace --hands diagnostic-hands + --repeats 1 + - name: Capture repeated shapelet stalls in isolated fresh fits + if: inputs.incident == '37286150846' + env: + DISABLE_CPU_EIGEN_THREADS: ${{ inputs.disable_cpu_eigen_threads }} + run: | + if [ "$DISABLE_CPU_EIGEN_THREADS" = "true" ]; then + export XLA_FLAGS="${XLA_FLAGS:+$XLA_FLAGS }--xla_cpu_multi_thread_eigen=false" + fi + # Each process gets a pristine checkout: a prior completed fit must + # never turn a subsequent repetition into a resume/readback check. + for attempt in 1 2 3; do + cp -a diagnostic-workspace "diagnostic-workspace-$attempt" + diagnostic-env/bin/python .github/scripts/release_diagnostic.py run \ + --manifest "$MANIFEST" --output "diagnostic-results/fresh-$attempt" \ + --workspace "diagnostic-workspace-$attempt" --hands diagnostic-hands \ + --repeats 1 + done - name: Preserve diagnostic evidence, including failure and native stacks if: always() uses: actions/upload-artifact@v4 @@ -80,4 +120,6 @@ jobs: path: | diagnostic-results/ diagnostic-workspace/dataset/multi_dataset/lens_sersic/*.fits + diagnostic-workspace/dataset/imaging/asymmetric/*.fits + diagnostic-workspace-*/dataset/multi_galaxy/simple/ if-no-files-found: error diff --git a/.github/workflows/workspace-validation.yml b/.github/workflows/workspace-validation.yml index 4408e1d9..c63a738c 100644 --- a/.github/workflows/workspace-validation.yml +++ b/.github/workflows/workspace-validation.yml @@ -394,6 +394,9 @@ jobs: # so autonerves resolves the workspace's own config/ + dataset/, not # the wheel's packaged defaults (closes Gap 4). set -e + # Avoid FFT/ducc0 re-entering the occupied Eigen pool on CPU runners. + # Exact-wheel witness and comparison: docs/release_validation.md. + export XLA_FLAGS="${XLA_FLAGS:+$XLA_FLAGS }--xla_cpu_multi_thread_eigen=false" pushd workspace # Use the canonical profile_release.yaml (PyAutoHands#161/#181 step # 6 rename). @@ -717,6 +720,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.12" + - name: Install report dependencies + run: python3 -m pip install "PyYAML>=6.0" - name: Emit the integrate stage report env: PYTHONPATH: ${{ github.workspace }} diff --git a/diagnostics/release-37217670612.json b/diagnostics/release-37217670612.json new file mode 100644 index 00000000..b1bdbf9c --- /dev/null +++ b/diagnostics/release-37217670612.json @@ -0,0 +1,140 @@ +{ + "hands_sha": "cdd10d64a1387c091b6f97503b9b7c7a5db67916", + "library_shas": { + "PyAutoArray": "9a6237f09a4cc26abad0e8e0742f4da955631033", + "PyAutoFit": "83844c526ef3fd5d9015e1dd2de6c6182e53f909", + "PyAutoGalaxy": "1aa5aa7f2d52d61c6554e0dc7d7cbc70d0b85eb5", + "PyAutoLens": "b695e57b69d168e33b760b169c29cfcf0d9cd8f9", + "PyAutoNerves": "82a60579a1e715e62094c9d3e14f3a8e10540970" + }, + "limitations": [ + "Package versions recovered from successful pip installation log lines; original wheel hashes and native runner stacks were not recorded.", + "The original runner OS image and CPU hardware are not pinned. Record diagnostic topology; a passing fit does not clear release validation.", + "Dataset generated by the unchanged workspace bootstrap; original generated FITS bytes were not retained in the failed run.", + "One fresh standalone fit, not the full preceding integration shard sequence. A pass is non-reproduction, not evidence that the execution stall is repaired." + ], + "packages": { + "MarkupSafe": "3.0.4", + "PyYAML": "6.0.3", + "SQLAlchemy": "2.0.54", + "absl-py": "2.5.0", + "alabaster": "1.0.0", + "anesthetic": "2.16.0", + "array_api_compat": "1.15.0", + "astropy": "8.0.1", + "astropy-iers-data": "0.2026.9.28.0.59.37", + "asttokens": "3.0.2", + "astunparse": "1.6.3", + "attrs": "26.1.0", + "autoarray": "2026.10.4.2.dev80301", + "autofit": "2026.10.4.2.dev80301", + "autogalaxy": "2026.10.4.2.dev80301", + "autolens": "2026.10.4.2.dev80301", + "autonerves": "2026.10.4.2.dev80301", + "babel": "2.18.0", + "blackjax": "1.7.1", + "certifi": "2026.7.22", + "charset_normalizer": "3.5.2", + "cloudpickle": "3.1.2", + "contourpy": "1.4.0", + "coolest": "0.1.11", + "corner": "2.2.2", + "cycler": "0.12.1", + "decorator": "5.3.1", + "dill": "0.4.1", + "dm-tree": "0.1.10", + "docutils": "0.22.4", + "dynesty": "2.1.5", + "emcee": "3.1.6", + "executing": "2.2.1", + "fonttools": "4.66.1", + "gast": "0.7.0", + "getdist": "1.4", + "gprof2dot": "2021.2.21", + "greenlet": "3.5.6", + "h5py": "3.16.0", + "idna": "3.20", + "imageio": "2.38.0", + "imagesize": "2.0.1", + "iniconfig": "2.3.0", + "ipython": "9.12.0", + "ipython-pygments-lexers": "1.1.1", + "jax": "0.11.2", + "jax_zero_contour": "2.0.0", + "jaxlib": "0.11.2", + "jaxnnls": "1.0.1", + "jedi": "0.20.0", + "jinja2": "3.1.6", + "joblib": "1.6.0", + "jsonpickle": "4.1.3", + "kiwisolver": "1.5.1", + "lazy-loader": "0.6", + "llvmlite": "0.50.0", + "matplotlib": "3.11.2", + "matplotlib-inline": "0.2.2", + "ml_dtypes": "0.6.0", + "mypy-extensions": "1.1.0", + "nautilus-sampler": "1.0.5", + "networkx": "3.1", + "nufftax": "0.6.1", + "numba": "0.68.0", + "numpy": "2.5.3", + "numpydoc": "1.11.0", + "opt_einsum": "3.4.0", + "optax": "0.2.8", + "packaging": "26.3", + "pandas": "3.0.6", + "parso": "0.8.7", + "pexpect": "4.9.0", + "pillow": "12.3.0", + "pluggy": "1.6.0", + "prompt_toolkit": "3.0.53", + "psutil": "6.1.0", + "ptyprocess": "0.7.0", + "pure-eval": "0.2.4", + "pyerfa": "2.0.1.5", + "pygments": "2.21.0", + "pyparsing": "3.3.3", + "pytest": "9.1.1", + "python-dateutil": "3.9.0", + "pyvis": "0.3.2", + "requests": "2.34.2", + "roman-numerals": "4.1.0", + "scikit-image": "0.26.0", + "scikit-learn": "1.8.0", + "scipy": "1.17.1", + "seaborn": "0.13.2", + "setuptools": "84.0.0", + "six": "1.17.0", + "snowballstemmer": "3.1.1", + "sphinx": "9.1.0", + "sphinxcontrib-applehelp": "2.0.0", + "sphinxcontrib-devhelp": "2.0.0", + "sphinxcontrib-htmlhelp": "2.1.0", + "sphinxcontrib-jsmath": "1.0.1", + "sphinxcontrib-qthelp": "2.0.0", + "sphinxcontrib-serializinghtml": "2.0.0", + "stack_data": "0.6.3", + "tfp-nightly": "0.26.0.dev20260713", + "threadpoolctl": "3.7.0", + "tifffile": "2026.9.20", + "timeout-decorator": "0.5.0", + "tqdm": "4.70.1", + "traitlets": "5.16.1", + "typing-extensions": "4.16.0", + "typing-inspect": "0.9.0", + "urllib3": "2.8.0", + "wcwidth": "0.9.1", + "wheel": "0.48.0", + "wrapt": "2.5.0", + "xxhash": "3.4.1", + "zeus-mcmc": "2.5.4" + }, + "python": "3.12.14", + "schema_version": 1, + "script": "imaging/features/multi_gaussian_expansion/modeling.py", + "source_job": "integrate / run_scripts (3.12, autogalaxy, imaging)", + "source_run": "https://github.com/PyAutoLabs/PyAutoHeart/actions/runs/37217670612", + "workspace_repo": "PyAutoLabs/autogalaxy_workspace", + "workspace_sha": "0cd6a6fbeb62703e10b34eaa6b9284bd4f7165f0" +} diff --git a/diagnostics/release-37286150846-native.txt b/diagnostics/release-37286150846-native.txt new file mode 100644 index 00000000..c1f1c7bc --- /dev/null +++ b/diagnostics/release-37286150846-native.txt @@ -0,0 +1,42 @@ +# Native witness: release diagnostic 37310709808 + +Source: https://github.com/PyAutoLabs/PyAutoHeart/actions/runs/37310709808 +Artifact: release-diagnostic-37310709808 / diagnostic-results/fresh-1/trial-1.native.txt +Raw native file SHA256: 6c8d9837a5fd773384cbda21a4b3a7f3ced1af958768cffc2a21c172c76a804c +Manifest: diagnostics/release-37286150846.json + +Fresh shapelet fit TIMEOUT300.047s; native py-spy and gdb both exited0. +Python3.12.14, JAX/JAXlib0.11.2, four CPUs; zero provenance errors. +Four Eigen workers wait in FFT/ducc0 fan-out. No BlockingCounter::Wait, +ParallelBatchMap or CholeskyFactorization frames occur in the raw capture. +This is distinct from the older JAX0.10.2 LAPACK witness. + +Below: thread headings and selected frames, runner paths and long signatures trimmed. + +Thread 20 (Thread 0x7fa6b74e86c0 (LWP 3486) "tf_XLAEigen"): +#5 0x00007fa6c1bb36b3 in ducc0::detail_threading::latch::wait() +#6 0x00007fa6c1bb35b6 in ducc0::detail_threading::Distribution::thread_map(std::function) +#7 0x00007fa6c1bb3c34 in ducc0::detail_threading::Distribution::execParallel(unsigned long, std::function) +#12 0x00007fa6c1ae8165 in xla::cpu::FftThunk::Execute(xla::cpu::Thunk::ExecuteParams const&) +#16 0x00007fa6bfebe044 in Eigen::ThreadPoolTempl::WorkerLoop(int) + +Thread 19 (Thread 0x7fa6b6ce76c0 (LWP 3487) "tf_XLAEigen"): +#5 0x00007fa6c1bb36b3 in ducc0::detail_threading::latch::wait() +#6 0x00007fa6c1bb35b6 in ducc0::detail_threading::Distribution::thread_map(std::function) +#7 0x00007fa6c1bb3c34 in ducc0::detail_threading::Distribution::execParallel(unsigned long, std::function) +#12 0x00007fa6c1ae8165 in xla::cpu::FftThunk::Execute(xla::cpu::Thunk::ExecuteParams const&) +#20 0x00007fa6bfebe044 in Eigen::ThreadPoolTempl::WorkerLoop(int) + +Thread 18 (Thread 0x7fa6b64e66c0 (LWP 3488) "tf_XLAEigen"): +#5 0x00007fa6c1bb36b3 in ducc0::detail_threading::latch::wait() +#6 0x00007fa6c1bb35b6 in ducc0::detail_threading::Distribution::thread_map(std::function) +#7 0x00007fa6c1bb3c34 in ducc0::detail_threading::Distribution::execParallel(unsigned long, std::function) +#12 0x00007fa6c1ae8165 in xla::cpu::FftThunk::Execute(xla::cpu::Thunk::ExecuteParams const&) +#16 0x00007fa6bfebe044 in Eigen::ThreadPoolTempl::WorkerLoop(int) + +Thread 17 (Thread 0x7fa6b5ce56c0 (LWP 3489) "tf_XLAEigen"): +#5 0x00007fa6c1bb36b3 in ducc0::detail_threading::latch::wait() +#6 0x00007fa6c1bb35b6 in ducc0::detail_threading::Distribution::thread_map(std::function) +#7 0x00007fa6c1bb3c34 in ducc0::detail_threading::Distribution::execParallel(unsigned long, std::function) +#12 0x00007fa6c1ae8165 in xla::cpu::FftThunk::Execute(xla::cpu::Thunk::ExecuteParams const&) +#16 0x00007fa6bfebe044 in Eigen::ThreadPoolTempl::WorkerLoop(int) diff --git a/diagnostics/release-37286150846.json b/diagnostics/release-37286150846.json new file mode 100644 index 00000000..2861d352 --- /dev/null +++ b/diagnostics/release-37286150846.json @@ -0,0 +1,140 @@ +{ + "hands_sha": "3e8bc5efb2e27b2f7798738ff41c18168dffcacb", + "library_shas": { + "PyAutoArray": "9a6237f09a4cc26abad0e8e0742f4da955631033", + "PyAutoFit": "83844c526ef3fd5d9015e1dd2de6c6182e53f909", + "PyAutoGalaxy": "1aa5aa7f2d52d61c6554e0dc7d7cbc70d0b85eb5", + "PyAutoLens": "dffea805824196a002ccb90a57687a82467af5a5", + "PyAutoNerves": "82a60579a1e715e62094c9d3e14f3a8e10540970" + }, + "limitations": [ + "Package versions recovered from successful pip installation log lines; original wheel hashes and native runner stacks were not recorded.", + "The original runner OS image and CPU hardware are not pinned. Record diagnostic topology; a passing fit does not clear release validation.", + "Dataset generated by the unchanged workspace bootstrap; original generated FITS bytes were not retained in the failed run.", + "Three independent fresh standalone fits, stopping at first failure; not the full preceding integration shard sequence. Passing trials are non-reproduction, not evidence that the execution stall is repaired." + ], + "packages": { + "MarkupSafe": "3.0.4", + "PyYAML": "6.0.3", + "SQLAlchemy": "2.0.54", + "absl-py": "2.5.0", + "alabaster": "1.0.0", + "anesthetic": "2.16.0", + "array_api_compat": "1.15.0", + "astropy": "8.0.1", + "astropy-iers-data": "0.2026.10.5.1.0.7", + "asttokens": "3.0.2", + "astunparse": "1.6.3", + "attrs": "26.1.0", + "autoarray": "2026.10.5.1.dev80401", + "autofit": "2026.10.5.1.dev80401", + "autogalaxy": "2026.10.5.1.dev80401", + "autolens": "2026.10.5.1.dev80401", + "autonerves": "2026.10.5.1.dev80401", + "babel": "2.18.0", + "blackjax": "1.7.1", + "certifi": "2026.7.22", + "charset_normalizer": "3.5.2", + "cloudpickle": "3.1.2", + "contourpy": "1.4.0", + "coolest": "0.1.11", + "corner": "2.2.2", + "cycler": "0.12.1", + "decorator": "5.3.1", + "dill": "0.4.1", + "dm-tree": "0.1.10", + "docutils": "0.22.4", + "dynesty": "2.1.5", + "emcee": "3.1.6", + "executing": "2.2.1", + "fonttools": "4.66.1", + "gast": "0.7.0", + "getdist": "1.4", + "gprof2dot": "2021.2.21", + "greenlet": "3.5.6", + "h5py": "3.16.0", + "idna": "3.20", + "imageio": "2.38.0", + "imagesize": "2.0.1", + "iniconfig": "2.3.0", + "ipython": "9.12.0", + "ipython-pygments-lexers": "1.1.1", + "jax": "0.11.2", + "jax_zero_contour": "2.0.0", + "jaxlib": "0.11.2", + "jaxnnls": "1.0.1", + "jedi": "0.20.0", + "jinja2": "3.1.6", + "joblib": "1.6.0", + "jsonpickle": "4.1.3", + "kiwisolver": "1.5.1", + "lazy-loader": "0.6", + "llvmlite": "0.50.0", + "matplotlib": "3.11.2", + "matplotlib-inline": "0.2.2", + "ml_dtypes": "0.6.0", + "mypy-extensions": "1.1.0", + "nautilus-sampler": "1.0.5", + "networkx": "3.1", + "nufftax": "0.6.1", + "numba": "0.68.0", + "numpy": "2.5.3", + "numpydoc": "1.11.0", + "opt_einsum": "3.4.0", + "optax": "0.2.8", + "packaging": "26.3", + "pandas": "3.0.6", + "parso": "0.8.7", + "pexpect": "4.9.0", + "pillow": "12.3.0", + "pluggy": "1.6.0", + "prompt_toolkit": "3.0.53", + "psutil": "6.1.0", + "ptyprocess": "0.7.0", + "pure-eval": "0.2.4", + "pyerfa": "2.0.1.5", + "pygments": "2.21.0", + "pyparsing": "3.3.3", + "pytest": "9.1.1", + "python-dateutil": "3.9.0", + "pyvis": "0.3.2", + "requests": "2.34.2", + "roman-numerals": "4.1.0", + "scikit-image": "0.26.0", + "scikit-learn": "1.8.0", + "scipy": "1.17.1", + "seaborn": "0.13.2", + "setuptools": "84.0.0", + "six": "1.17.0", + "snowballstemmer": "3.1.1", + "sphinx": "9.1.0", + "sphinxcontrib-applehelp": "2.0.0", + "sphinxcontrib-devhelp": "2.0.0", + "sphinxcontrib-htmlhelp": "2.1.0", + "sphinxcontrib-jsmath": "1.0.1", + "sphinxcontrib-qthelp": "2.0.0", + "sphinxcontrib-serializinghtml": "2.0.0", + "stack_data": "0.6.3", + "tfp-nightly": "0.26.0.dev20260713", + "threadpoolctl": "3.7.0", + "tifffile": "2026.9.20", + "timeout-decorator": "0.5.0", + "tqdm": "4.70.1", + "traitlets": "5.16.1", + "typing-extensions": "4.16.0", + "typing-inspect": "0.9.0", + "urllib3": "2.8.0", + "wcwidth": "0.9.2", + "wheel": "0.48.0", + "wrapt": "2.5.0", + "xxhash": "3.4.1", + "zeus-mcmc": "2.5.4" + }, + "python": "3.12.14", + "schema_version": 1, + "script": "multi_galaxy/features/advanced/shapelets/modeling.py", + "source_job": "integrate / run_scripts (3.12, autolens, multi_galaxy)", + "source_run": "https://github.com/PyAutoLabs/PyAutoHeart/actions/runs/37286150846", + "workspace_repo": "PyAutoLabs/autolens_workspace", + "workspace_sha": "068317794749ea3f8a7b9f67f94ae9816d819483" +} diff --git a/docs/release_validation.md b/docs/release_validation.md index cd8d1ac3..bb6599a0 100644 --- a/docs/release_validation.md +++ b/docs/release_validation.md @@ -236,6 +236,41 @@ The interleaved comparison [37206724174](https://github.com/PyAutoLabs/PyAutoHea The smoke, integration and notebook dependency recipes now require matching JAX/JAXlib `>=0.11.2,<0.12`, preventing the old `<0.11` override from downgrading into the captured LAPACK deadlock. The original 115-package diagnostic control remains pinned to 0.10.2. No timeout, test selection or release-readiness rule changes. Full release integration has not been repeated: the failed validation remains authoritative until a separately authorized post-merge validation succeeds. +### FFT pool stalls on the 2026-10-05 release wheels + +The later integration `37286150846` still timed out after compilation on +JAX/JAXlib 0.11.2. Diagnostic incident `37286150846` preserves its 115 package +pins, Python 3.12.14 and workspace/Hands commits. It runs the multi-galaxy +shapelet fit in three pristine workspace copies, stopping on the first failure. +Incident `37217670612` separately replays one Galaxy MGE fit; its passing +replay did not reproduce the full integration failure. + +[Control 37310709808](https://github.com/PyAutoLabs/PyAutoHeart/actions/runs/37310709808) +timed out at 300.047 seconds with zero provenance errors. Its +[native witness](../diagnostics/release-37286150846-native.txt) records four +Eigen workers waiting in `ducc0::detail_threading::latch::wait` beneath +`xla::cpu::FftThunk::Execute`. The older LAPACK signatures are absent. This +supports FFT pool re-entry as the cause of this reproduced stall; it does not +establish that every timed-out script has the same cause. + +The optional `disable_cpu_eigen_threads: true` input applies only to the +shapelet diagnostic. It appends `--xla_cpu_multi_thread_eigen=false`, retaining +existing flags; the default control and older incident routes are unchanged. +The release script runner applies the same flag before resolving workspace +profiles. This extends the existing test-workspace workaround to release CI +without changing user-library defaults, package pins, script selection or +timeouts. It can reduce CPU parallelism; timing should be assessed separately. + +[Workaround replay 37312018327](https://github.com/PyAutoLabs/PyAutoHeart/actions/runs/37312018327) +passed all three fresh fits in 47.383, 45.188 and 45.237 seconds, with zero +provenance errors and the flag recorded for each child. The package pins and +source revisions match the native-confirmed control. These separate hosted +runs support the mitigation for this reproduced FFT stall; they are not a +same-run interleaved failure-rate measurement or a full-matrix result. + +Diagnostic success is not release clearance. A complete integration run and +canonical ingestion must still replace the failed validation evidence. + ### User-facing compatibility policy (2026-10-04) The package repair preserves `>=0.7,<0.12` while excluding `0.10.*` and `0.11.0`. diff --git a/tests/test_release_diagnostic.py b/tests/test_release_diagnostic.py index 603b465b..722230dd 100644 --- a/tests/test_release_diagnostic.py +++ b/tests/test_release_diagnostic.py @@ -8,6 +8,7 @@ import sys import pytest +import yaml ROOT = Path(__file__).resolve().parents[1] @@ -22,6 +23,56 @@ def manifest(): return diag.load_manifest(ROOT / "diagnostics/release-37199991757.json") +@pytest.mark.parametrize("fail_second", [False, True]) +@pytest.mark.parametrize("disable_eigen", [False, True]) +def test_shapelet_replay_uses_fresh_fits_and_stops_on_failure(tmp_path, fail_second, disable_eigen): + workflow = yaml.safe_load( + (ROOT / ".github/workflows/release-diagnostic.yml").read_text() + ) + step = next( + step for step in workflow["jobs"]["diagnose"]["steps"] + if step.get("name") == "Capture repeated shapelet stalls in isolated fresh fits" + ) + workspace = tmp_path / "diagnostic-workspace" + workspace.mkdir() + (workspace / "input.txt").write_text("original dataset") + executable = tmp_path / "diagnostic-env/bin/python" + executable.parent.mkdir(parents=True) + executable.write_text( + f"#!{sys.executable}\n" + "import os, sys\nfrom pathlib import Path\n" + "assert os.environ['XLA_FLAGS'] == os.environ['EXPECTED_XLA_FLAGS']\n" + "workspace = Path(sys.argv[sys.argv.index('--workspace') + 1])\n" + "assert (workspace / 'input.txt').read_text() == 'original dataset'\n" + "assert not (workspace / 'completed-fit').exists(), 'resumed prior output'\n" + "(workspace / 'completed-fit').write_text('preserve evidence')\n" + "with Path('attempts.txt').open('a') as log: log.write(str(workspace) + '\\n')\n" + "if os.environ['FAIL_SECOND'] == '1' and workspace.name.endswith('-2'): sys.exit(7)\n" + ) + executable.chmod(0o755) + result = subprocess.run( + ["bash", "-e", "-c", step["run"]], + cwd=tmp_path, + env={ + **os.environ, + "MANIFEST": "incident.json", + "FAIL_SECOND": str(int(fail_second)), + "DISABLE_CPU_EIGEN_THREADS": str(disable_eigen).lower(), + "XLA_FLAGS": "--existing-flag", + "EXPECTED_XLA_FLAGS": "--existing-flag" + ( + " --xla_cpu_multi_thread_eigen=false" if disable_eigen else "" + ), + }, + capture_output=True, + text=True, + ) + assert result.returncode == (7 if fail_second else 0), result.stderr + attempts = (tmp_path / "attempts.txt").read_text().splitlines() + assert attempts == [f"diagnostic-workspace-{n}" for n in range(1, 3 if fail_second else 4)] + assert not (workspace / "completed-fit").exists() + assert all((tmp_path / path / "completed-fit").is_file() for path in attempts) + + @pytest.mark.parametrize( "key,value", [ diff --git a/tests/test_workflow_wiring.py b/tests/test_workflow_wiring.py index f3e41e6e..f05673b1 100644 --- a/tests/test_workflow_wiring.py +++ b/tests/test_workflow_wiring.py @@ -349,3 +349,24 @@ def test_the_guard_is_a_quiet_no_op_on_a_clean_checkout(tmp_path): (other / "a__script.json").write_text("{}") res = _run_discard(step, tmp_path, env={"WORKSPACE_DIR": "elsewhere"}) assert res.returncode == 0 and not (other / "a__script.json").exists() + + +def test_release_fft_workaround_preserves_flags_and_is_scoped_to_release(tmp_path): + import os + import subprocess + + steps = _load("workspace-validation.yml")["jobs"]["run_scripts"]["steps"] + release = next(s for s in steps if s.get("name", "").startswith("Run Python scripts [mode=release")) + smoke = next(s for s in steps if s.get("name", "").startswith("Run Python scripts [mode=smoke")) + assert release["if"] == "needs.find_scripts.outputs.mode == 'release'" + assert "xla_cpu_multi_thread_eigen" not in smoke["run"] + prefix = release["run"].split("pushd workspace", 1)[0] + for existing in (None, "", "--existing-flag"): + env = {k: v for k, v in os.environ.items() if k != "XLA_FLAGS"} + if existing is not None: + env["XLA_FLAGS"] = existing + result = subprocess.run( + ["bash", "-e", "-c", prefix + '\nprintf "%s" "$XLA_FLAGS"'], + cwd=tmp_path, env=env, capture_output=True, text=True, check=True, + ) + assert result.stdout == ((existing + " ") if existing else "") + "--xla_cpu_multi_thread_eigen=false"