Skip to content
Draft
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
27 changes: 27 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,33 @@ jobs:
- name: "Run development test"
run: PYSR_TEST_JULIA_VERSION=${{ matrix.julia-version }} PYSR_TEST_PYTHON_VERSION=${{ matrix.python-version }} python -m pysr test dev

rust_backend_adapter:
name: Test Rust backend adapter
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
matrix:
python-version: ['3.13']

steps:
- uses: actions/checkout@v6
- name: "Set up Python"
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: "Install PySR test dependencies"
run: |
python -m pip install --upgrade pip
pip install -e .
python -m pip install pytest
- name: "Assert default import is Julia-free"
run: python -c "import sys; import pysr; assert 'juliacall' not in sys.modules; from pysr import PySRRegressor; assert PySRRegressor().backend == 'auto'"
- name: "Run Rust backend adapter tests"
run: python -m pysr test rust

conda_test:
runs-on: ${{ matrix.os }}
defaults:
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,27 @@ You can install PySR with pip:
pip install pysr
```

Julia dependencies will be installed at first import.
If you plan to use the experimental Rust adapter, select the Rust dependency at install time:

```bash
pip install "pysr[rust]"
```

Julia dependencies will be installed when the Julia backend is used.

PySR also includes an experimental runtime switch for the Rust adapter:

```python
PySRRegressor(backend="rust")
```

The Rust backend adapter expects the optional `symbolic_regression_rs` Python
module from the `pysr-rust-backend` package. It is installed automatically by
the `rust` extra.

The default `backend="auto"` uses the Rust backend when `pysr-rust-backend` is
installed and falls back to Julia otherwise. Set `backend="julia"` to force the
full-featured and supported Julia backend.

### Conda

Expand Down
19 changes: 19 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Benchmark 1

## Backend comparison

To compare the experimental Rust backend against the default Julia backend on
the same generated dataset, run:

```bash
python benchmarks/compare_backends.py --niterations 3 --repeats 3
```

Use `--mode subprocess` to run each trial in a fresh Python process, which is
useful when measuring startup-heavy workflows:

```bash
python benchmarks/compare_backends.py --mode subprocess --niterations 1 --repeats 3
```

The script reports wall-clock timing plus the best loss, prediction MSE, and
selected equation for each backend.

The following benchmarks were ran with this command on a node on CCA's BNL cluster (40-cores). At no time was the node fully busy. The tags were put into the file `tags.txt`, and the `benchmark.sh` was copied to the root folder. This is the command used:

```bash
Expand Down
Loading