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
44 changes: 32 additions & 12 deletions .github/workflows/pytest-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1 pinned commit
uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0 pinned commit
continue-on-error: true
with:
miniforge-version: latest
use-mamba: true
auto-update-conda: true
channels: conda-forge, defaults
channels: conda-forge
python-version: ${{ matrix.python-version }}
- name: Output conda info
run: |
Expand All @@ -50,19 +50,38 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --requirement build-requirements.txt
- name: Probe Windows PyTorch environment
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
hatch --env hatch-test.torch run python -c "import sys, torch; print('Python:', sys.version); print('Torch:', torch.__version__); print('CUDA build:', torch.version.cuda); print('CUDA available:', torch.cuda.is_available()); print('CUDA devices:', torch.cuda.device_count()); print(torch.__config__.show())"
Get-CimInstance Win32_Processor |
Select-Object Name, Manufacturer, NumberOfCores, NumberOfLogicalProcessors
- name: Probe bfloat16 add
if: ${{ matrix.os == 'windows-latest' }}
run: hatch --env hatch-test.torch run python -c "import torch; print(torch.ones(4,4,dtype=torch.bfloat16) + 1)"
- name: Probe bfloat16 matmul
if: ${{ matrix.os == 'windows-latest' }}
run: hatch --env hatch-test.torch run python -c "import torch; print(torch.ones(4,4,dtype=torch.bfloat16) @ torch.ones(4,4,dtype=torch.bfloat16))"
- name: Show installed packages
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
hatch --env hatch-test.torch run uv pip show torch
hatch --env hatch-test.torch run uv pip freeze | Select-String "torch|numpy|scipy"
- name: Test All backend
run: hatch test --all --cover -- -vx
run: hatch test --all --cover
- name: Rename file
run: mv coverage/.coverage coverage/.coverage.${{ matrix.python-version }}.${{ matrix.os }}
- name: Upload coverage data
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: .coverage.${{ matrix.python-version }}.${{ matrix.os }}
path: coverage/.coverage.${{ matrix.python-version }}.${{ matrix.os }}
include-hidden-files: true
if-no-files-found: ignore
coverage:
name: Combine & check coverage
name: Upload coverage
if: always()
needs: tests
runs-on: ubuntu-latest
Expand All @@ -72,16 +91,16 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: actions/setup-python@v5
with:
# Use latest Python, so it understands all syntax.
python-version: "3.12"
- name: Install a specific version of uv
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: "0.4.4"
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v8
with:
pattern: .coverage.*
- name: Install coverage.py
Expand All @@ -95,16 +114,17 @@ jobs:

coverage xml -o desolver-coverage.xml
- name: Upload XML report if check failed
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: xml-report
path: desolver-coverage.xml
- name: Upload coverage report to codecov
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
uses: codecov/codecov-action@v7
if: ${{ !cancelled() }}
with:
fail_ci_if_error: true # optional (default = false)
flags: pr-tests-${{ github.head_ref }} # optional
name: desolver-combined-reports # optional
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true # optional (default = false)

3 changes: 1 addition & 2 deletions desolver/differential_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __local_ev_f(t):
down & (direction < 0) |
either & (direction == 0))

active_events = D.ar_numpy.reshape(D.ar_numpy.nonzero(mask), (-1,))
active_events = D.ar_numpy.nonzero(mask)[0]

roots = roots[active_events]
evs = [events[idx] for idx in active_events]
Expand Down Expand Up @@ -1253,4 +1253,3 @@ def __step_cb(ode_sys):
y_events=ode_system.events, nfev=ode_system.nfev, njev=ode_system.njev,
status=ode_system.integration_status, message=ode_system.integration_status,
success=ode_system.success, ode_system=ode_system)

26 changes: 20 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ test = [

[tool.uv.sources]
torch = [
{ index = "pytorch-cu126", marker = "sys_platform == 'win32'" },
{ index = "pytorch-cu126", marker = "sys_platform == 'linux'" },
{ index = "pytorch-cu130", marker = "sys_platform == 'win32'" },
{ index = "pytorch-cu130", marker = "sys_platform == 'linux'" },
{ index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
]

Expand All @@ -76,10 +76,24 @@ url = "https://download.pytorch.org/whl/cpu"
explicit = true

[[tool.uv.index]]
name = "pytorch-cu126"
url = "https://download.pytorch.org/whl/cu126"
name = "pytorch-cu130"
url = "https://download.pytorch.org/whl/cu130"
explicit = true

[tool.hatch.envs.default]
dependencies = [
'numpy>=2',
'tqdm>=4.47.0',
'scipy>=1.15.0',
'autoray>=0.7.0',
'einops>=0.8.0'
]

[tool.hatch.envs.torch]
extra-dependencies = [
"torch>=2.5.0"
]

[tool.hatch.envs.dev]
installer = "uv"
extra-dependencies = [
Expand All @@ -95,7 +109,7 @@ extra-dependencies = [

[tool.hatch.envs.hatch-test]
installer = "uv"
parallel = true
#parallel = true
default-args = ["desolver"]
features = [
"test"
Expand Down Expand Up @@ -133,7 +147,7 @@ exclude = [
packages = ["desolver/"]

[tool.coverage.run]
parallel = true
#parallel = true
branch = true
relative_files = true
source = ["desolver"]
Expand Down
Loading