diff --git a/.github/workflows/pytest-ubuntu.yml b/.github/workflows/pytest-ubuntu.yml index d4da438..fb1253b 100644 --- a/.github/workflows/pytest-ubuntu.yml +++ b/.github/workflows/pytest-ubuntu.yml @@ -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: | @@ -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 @@ -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 @@ -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) - \ No newline at end of file + diff --git a/desolver/differential_system.py b/desolver/differential_system.py index 1c2724a..a0d26c8 100644 --- a/desolver/differential_system.py +++ b/desolver/differential_system.py @@ -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] @@ -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) - \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 11d0eeb..876f353 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'" }, ] @@ -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 = [ @@ -95,7 +109,7 @@ extra-dependencies = [ [tool.hatch.envs.hatch-test] installer = "uv" -parallel = true +#parallel = true default-args = ["desolver"] features = [ "test" @@ -133,7 +147,7 @@ exclude = [ packages = ["desolver/"] [tool.coverage.run] -parallel = true +#parallel = true branch = true relative_files = true source = ["desolver"]