From a77051dc774e99719fb50b9e4222a0040b527d4f Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Tue, 28 Jul 2026 11:56:56 +0100 Subject: [PATCH 01/10] Use a machine.dev runner to get GPU testing --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index 37c2c40..224a4b0 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: machine/id=${{ github.run_id }}/gpu=t4g/tenancy=spot strategy: fail-fast: false matrix: From e8b34e0c3719e3c3f9b82310b2460f69606d0463 Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Wed, 29 Jul 2026 09:41:47 +0100 Subject: [PATCH 02/10] Use the T4 GPU to get x86 architecture CPU, which is more compatible with torch/CUDA capabilities. --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index 224a4b0..0b8b249 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: machine/id=${{ github.run_id }}/gpu=t4g/tenancy=spot + runs-on: machine/id=${{ github.run_id }}/gpu=t4/tenancy=spot strategy: fail-fast: false matrix: From 99e3d67cfc4360d5a6a37064e0d9492f88285ceb Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Thu, 30 Jul 2026 14:35:35 +0100 Subject: [PATCH 03/10] Make sure the GeneralScatteringDust-specific ML models end up on the correct device. Add device transfer for scattering models and scalers. --- pinballrt/dust.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pinballrt/dust.py b/pinballrt/dust.py index 9e99cac..b55e6d3 100644 --- a/pinballrt/dust.py +++ b/pinballrt/dust.py @@ -1544,6 +1544,14 @@ def __init__(self, lam=None, kabs=None, ksca=None, scattering_phase_function=Non def to_device(self, device): super().to_device(device) + for model in ["scattering_phase_function","random_direction"]: + if hasattr(self, f"{model}_model"): + getattr(self, f"{model}_model").to(device) + if hasattr(self, f"{model}_x_scaler"): + getattr(self, f"{model}_x_scaler").to(device) + if hasattr(self, f"{model}_y_scaler"): + getattr(self, f"{model}_y_scaler").to(device) + def scatter(self, photon_list, iphotons): nphotons = iphotons.size(0) From 3ed81a11faae3e50dbadf54cccc7c55044ed981f Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Thu, 30 Jul 2026 21:57:12 +0100 Subject: [PATCH 04/10] Change GPU tenancy from spot to ondemand to avoid job failures --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index 0b8b249..ca51971 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: machine/id=${{ github.run_id }}/gpu=t4/tenancy=spot + runs-on: machine/id=${{ github.run_id }}/gpu=t4/tenancy=ondemand strategy: fail-fast: false matrix: From 9723d4435e67c082e287b1a5faad87c45b57f58d Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Thu, 30 Jul 2026 22:00:28 +0100 Subject: [PATCH 05/10] Just remove tenancy because on demand is default anyways. Removed 'tenancy=ondemand' from the GPU configuration. --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index ca51971..824bf20 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: machine/id=${{ github.run_id }}/gpu=t4/tenancy=ondemand + runs-on: machine/id=${{ github.run_id }}/gpu=t4 strategy: fail-fast: false matrix: From 0770e3746eeac2602be78559186b12ee24b3ca33 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 07:09:50 +0000 Subject: [PATCH 06/10] Split E2E workflow into CUDA and non-CUDA jobs --- .github/workflows/run_E2E_tests.yml | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index 37c2c40..efbb6cd 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -10,8 +10,7 @@ on: branches: [ "main" ] jobs: - build: - + non-cuda-tests: runs-on: ubuntu-latest strategy: fail-fast: false @@ -38,9 +37,38 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + - name: Test non-CUDA with pytest + run: | + pytest -s --cov=pinballrt --cov-report xml --cov-report term -k "not cuda" + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + cuda-tests: + runs-on: machine.dev + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest pytest-cov + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install -e .[train] + + - name: Test CUDA with pytest run: | - pytest -s --cov=pinballrt --cov-report xml --cov-report term + pytest -s --cov=pinballrt --cov-report xml --cov-report term -k "cuda" - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 From 09abe22fc9b6148b788064704b548d54266f647c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 07:10:32 +0000 Subject: [PATCH 07/10] Add explicit workflow permissions for GITHUB_TOKEN --- .github/workflows/run_E2E_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index efbb6cd..8284ae0 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -9,6 +9,9 @@ on: pull_request: branches: [ "main" ] +permissions: + contents: read + jobs: non-cuda-tests: runs-on: ubuntu-latest From e0f70dd435c80b6f25c583223e8d131440bcd36f Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Fri, 31 Jul 2026 09:54:35 +0100 Subject: [PATCH 08/10] Put the proper runs-on for GPU tests back in --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index 8284ae0..d008934 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -50,7 +50,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} cuda-tests: - runs-on: machine.dev + runs-on: machine/id=${{ github.run_id }}/gpu=t4 strategy: fail-fast: false matrix: From a4d128425b35e5c41ae735bb090ab6541f5f2e06 Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Fri, 31 Jul 2026 09:08:26 +0000 Subject: [PATCH 09/10] Put tenancy back to spot to see if running just the cuda tests is fast enough to not be cancelled. --- .github/workflows/run_E2E_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_E2E_tests.yml b/.github/workflows/run_E2E_tests.yml index d008934..340fa1c 100644 --- a/.github/workflows/run_E2E_tests.yml +++ b/.github/workflows/run_E2E_tests.yml @@ -50,7 +50,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} cuda-tests: - runs-on: machine/id=${{ github.run_id }}/gpu=t4 + runs-on: machine/id=${{ github.run_id }}/gpu=t4/tenancy=spot strategy: fail-fast: false matrix: From 7b02356784e7ee65fbae7f1104e37fc1c1ab750c Mon Sep 17 00:00:00 2001 From: Patrick Sheehan Date: Fri, 31 Jul 2026 09:11:08 +0000 Subject: [PATCH 10/10] Adjust temperature tolerance to 1.046 because occassionally the difference gets just above the 1.045 number with the non-isothermal dust. --- pinballrt/tests/test_E2E.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinballrt/tests/test_E2E.py b/pinballrt/tests/test_E2E.py index 17f5aea..addfe78 100644 --- a/pinballrt/tests/test_E2E.py +++ b/pinballrt/tests/test_E2E.py @@ -93,7 +93,7 @@ def test_E2E(grid_class, grid_kwargs, dust, percentile, device, return_vals=Fals # Load the comparison data. temperature = np.load(os.path.join(os.path.dirname(__file__), f"data/{grid_class.__name__}_E2E_temperature.npz"))['temperature'] Q = calculate_Qvalue(temperature, model.grid.grid.temperature.numpy(), percentile=99.0) - assert Q < 1.045, f"Temperature difference exceeds tolerance: {Q}" + assert Q < 1.046, f"Temperature difference exceeds tolerance: {Q}" scattering = np.load(os.path.join(os.path.dirname(__file__), f"data/{grid_class.__name__}_E2E_scattering.npz"))['scattering'] Q = calculate_Qvalue(scattering, model.grid.scattering.cpu().numpy(), percentile=percentile, clip=0.1)