-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CI checks are slow, especially pytest and coverage #6211
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
Comments
cc: @nafaynajam |
@pavoljuhas Hi, I have forked repo recently, slowly learning about the project. Ran the tests for cirq-ft for different number of n. It appears to me that parallelization is not implemented for local unit tests as changing number of n is not changing execution time, I had expected it would distribute loads to multiple CPUs. For 0, it gave 413.17 seconds execution time, and gave 413.65 for n=8. Am I lacking any dependency such as xdist (problem is on my side?)? Or is parallelization not implemented at all?. |
In my case I see a different durations: 344s for
The option To be sure you are using comparable dependencies as in the CI, I'd recommend to do the test in a dedicated virtual environment for Python 3.9 and install dependencies with
PS: I am not sure why the 130s total time for |
As a temp measure, I would suggest we move the code coverage section to CI-daily? |
Coverage is actually helpful for the PR to see if the changed lines are tested. @tanujkhattar - the first 2 slowest tests in #6211 (comment) happen for a few parameters of I feel that for common unit tests we should only exercise all code lines (and branches) and collect coverage in a cheapest way possible. If we need to test correctness of some expensive calculations, we should move such tests to ci-daily; |
This sounds like a good plan to me. We currently don't have a test maker |
@pavoljuhas Can I reach you through your email to discuss the issue?. |
@nafaynajam Pavol is currently out of office but will be back in a couple of days. Feel free to ask your questions on the issue in the meantime. |
@tanujkhattar Allow me some basic questions as I am getting to know the framework. I see in the issue that pavol is only running Cirq-ft tests in the screenshot, why not others as well. I have seen that we have tests for every algo in all directories. Do we only intend to only cut Cirq-ft tests?. |
Yes, that is correct. |
@nafaynajam - the output in my initial comment shows 16 tests with the slowest duration. All but one happen in the cirq-ft package. check/pytest ran all tests in the cirq repository, they are just sorted by execution time.
I would recommend to use a Linux-like development environment, for example WSL, and then run tests with the check/pytest shell script. |
@pavoljuhas Thank you :-) |
@pavoljuhas @tanujkhattar Fetch excluded tests from the file if IGNORE_EXCLUDED_TESTS is not set
Print excluded tests
Generate a string of --ignore arguments for excluded tests
Exclude specified tests from execution
The daily CI file can be edited this way to reflect the changes in Pytest.
Fetch excluded tests from the file if IGNORE_EXCLUDED_TESTS is not set
Generate a string of --ignore arguments for excluded tests
Store the ignore_args in an environment variable for later use
I am debugging some problems I am having, let me know if the route I am taking is correct & if you have any insights. |
We already have a Line 30 in 64e1a7f
It is only provided for the dev_tools subpackage. TODO
|
Hi @pavoljuhas @tanujkhattar , I propose the following solution: Make the following changes to ci.yml line 170-171: Make the following changes to ci-daily.yml line 38-39: Exclude the tests with the following marker: To run locally without the slow tests: Let me know if this solution is feasible or there is an issue with it in your experience. |
Hi @nafaynajam, apologies about a slow response. First the The pytest setup could be cleaned up. As it is the custom markers
|
@pavoljuhas I have the following tests coming up as slowest which seem to differ from your list, which ones should I mark slow for test purposes? . |
Test durations may depend on random seed which is different from run to run because we use pytest-randomly. Please see the list below. You may want to check https://docs.pytest.org/en/stable/example/markers.html#marking-individual-tests-when-using-parametrize if only some of the parametrized tests below need to be marked slow. @tanujkhattar - are you OK with skipping these in PR checks?
|
#6328) * Move all pytest_collection_modifyitems hooks to the top conftest.py and apply mark-based test-selection there * Move custom marks definitions to pyproject.toml so they show in `pytest --markers` * Add custom pytest option `--enable-slow-tests` to run slow-marked tests. These are otherwise skipped by default. * Support a quick check of test selection using `pytest --co -m skip` and `pytest --co -m "not skip"` Partially implements #6211 --------- Co-authored-by: Pavol Juhas <[email protected]>
Yes, this is a good list. Although these tests will go away soon since we'v migrated all the Cirq-FT code to Qualtran. But as a proof of concept, let's mark these as slow for now. Thanks! |
Found 3 more tests that took well over 20 seconds (depending on random seed)
|
* Add slow marks to the unit tests with over 20 second duration. * Update the ci-daily job so it runs all slow tests. * Add ci-daily jobs for Windows and MacOS operating systems so that slow tests are tested on these platforms too. Refs: * #6211 (comment) * #6211 (comment) Resolves #6211
No change in the test execution, just a bit more output for the `Pytest Ubuntu`, `Pytest Windows`, and `Pytest MacOS` jobs. Related to quantumlib#6211
No change in the test execution, just a bit more output for the `Pytest Ubuntu`, `Pytest Windows`, and `Pytest MacOS` jobs. Related to #6211
Description of the issue
Lately the CI coverage and pytest checks slowed down and can take up to 1 hour on GitHub actions.
The duration times fluctuate and may depend on the random seed used in the test.
pytest is already run in parallel and distributes test cases over available CPUs.
Example durations from
check/pytest --durations=50 --durations-min=10
Cirq version
1.2 at e16fbf4
Ideas
check/pytest uses-n auto
by default. Is this using all runners on GHA or just 50%?This was tested in a withdrawn PR which showed no difference for
-n $(nproc)
vs-n auto
.Use all cores in CI-run pytest jobs #6215 (comment).
The text was updated successfully, but these errors were encountered: