Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime tests #475

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add runtime tests #475

wants to merge 10 commits into from

Conversation

michaeldeistler
Copy link
Contributor

@michaeldeistler michaeldeistler commented Oct 29, 2024

Note that the tests are disabled in the workflow: pytest -m "not runtime"

Copy link
Contributor

@jnsbck jnsbck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for implementing this, I think this will be really useful. I had also worked on the same thing, but was pursuing sth slightly different. I have added my proof of concept to this branch. (see also my comments). Feel free to work off of it or remove it. I think having a seperate CI for regressions might be useful in the long run.

Happy to discuss this more.

.github/workflows/regression_tests.yml Show resolved Hide resolved
tests/regression_test_runner.py Outdated Show resolved Hide resolved
tests/test_regression.py Outdated Show resolved Hide resolved
tests/test_runtime.py Outdated Show resolved Hide resolved
tests/test_runtime.py Outdated Show resolved Hide resolved
@jnsbck jnsbck linked an issue Nov 4, 2024 that may be closed by this pull request
@jnsbck

This comment was marked as resolved.

@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 4, 2024
@jnsbck

This comment was marked as resolved.

@jnsbck jnsbck force-pushed the runtimetests branch 2 times, most recently from 5b0281b to 2855ff7 Compare November 21, 2024 19:03
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 21, 2024
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 21, 2024
@jnsbck jnsbck force-pushed the runtimetests branch 4 times, most recently from eb50f1b to 8e6de5a Compare November 22, 2024 10:53
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 22, 2024
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 22, 2024
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 22, 2024
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 22, 2024
@jnsbck jnsbck force-pushed the runtimetests branch 2 times, most recently from 8cfc276 to 824a83f Compare November 22, 2024 14:00
@jaxleyverse jaxleyverse deleted a comment from github-actions bot Nov 22, 2024
Copy link
Contributor

New Baselines

test_runtime(num_cells=1, artificial=False, connect=False, connection_prob=0.0, voltage_solver=jaxley.stone)
🆕 build_time: (0.566s).
🆕 compile_time: (18.334s).
🆕 run_time: (2.804s).

test_runtime(num_cells=1, artificial=False, connect=False, connection_prob=0.0, voltage_solver=jax.sparse)
🆕 build_time: (0.394s).
🆕 compile_time: (3.041s).
🆕 run_time: (2.451s).

test_runtime(num_cells=10, artificial=False, connect=True, connection_prob=0.1, voltage_solver=jaxley.stone)
🆕 build_time: (1.836s).
🆕 compile_time: (29.308s).
🆕 run_time: (18.758s).

test_runtime(num_cells=10, artificial=False, connect=True, connection_prob=0.1, voltage_solver=jax.sparse)
🆕 build_time: (1.256s).
🆕 compile_time: (26.581s).
🆕 run_time: (25.064s).

test_runtime(num_cells=1000, artificial=True, connect=True, connection_prob=0.001, voltage_solver=jaxley.stone)
🆕 build_time: (109.680s).
🆕 compile_time: (45.643s).
🆕 run_time: (41.482s).

test_runtime(num_cells=1000, artificial=True, connect=True, connection_prob=0.001, voltage_solver=jax.sparse)
🆕 build_time: (108.686s).
🆕 compile_time: (61.090s).
🆕 run_time: (58.329s).

@jnsbck
Copy link
Contributor

jnsbck commented Nov 22, 2024

@michaeldeistler This should be ready for review. The following is implemented and works:

  • tests/test_regression.py contains the regression tests that are run using pytest -m regression
  • automates writing results to database, comparing results stored baselines and producing a report (see above).
  • regression_tests.yml runs the regression tests.
  • update_regression_baseline.yml to update the baseline
  • idea is to trigger this on comment
  • comments with updated baseline report
  • pushes the updated baselines to the branch in which the workflow is run.

If you want to run this locally do you can do NEW_BASELINE=1 pytest -m regression i.e. on main and then run pytest -m regression on feature.

Some thoughts I had: Even with a 20% tolerance the regression tests frequently fail for some reason. (might need to average across several runs or take the max across several runs for the baseline, but currently the regression tests take quite long. Would be good to merge #489 to speed this up).

Lemme know if anything is unclear

@jnsbck jnsbck self-requested a review November 22, 2024 15:20
jnsbck

This comment was marked as resolved.

Copy link
Contributor Author

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow this is amazing!!!

I don't think I understand when exactly the updating of the times is being run. On a comment to this particular PR (i.e., #475)? Or some other PR/issue? Also, what should the comment be? Anything? Who would the comment have to be by? Anyone? (BTW I am commenting now, so does this trigger the regression tests :D ?)

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need dev?

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev needed?

on:
issue_comment: # trigger from comment; event runs on the default branch
types: [created]
# pull_request:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

git commit -m "Update regression test baselines"
git push origin HEAD:${{ github.head_ref }}

# Needed when workflow is triggered from a comment
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete?

@@ -55,6 +55,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
tests/regression_test_results.json
tests/regression_test_baselines.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this. Why do we first put it in the gitignore just to then force add it?

json.dump(result_data, f, indent=2)


class compare_to_baseline:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompareToBaseline to follow PEP style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add runtime tests
2 participants