Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions .github/workflows/run_E2E_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ on:
pull_request:
branches: [ "main" ]

jobs:
build:
permissions:
contents: read

jobs:
non-cuda-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -38,9 +40,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/id=${{ github.run_id }}/gpu=t4/tenancy=spot
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
Expand Down
8 changes: 8 additions & 0 deletions pinballrt/dust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pinballrt/tests/test_E2E.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading