Skip to content

Add flaky pytest infrastructure and weekend runners #1799

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

Merged
merged 26 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bb4634e
Add flaky test infra in `make pytest`
paul0403 Jun 10, 2025
931db6a
5 runs
paul0403 Jun 10, 2025
d61ea62
add weekly flaky test runner script
paul0403 Jun 10, 2025
cc61117
try skipping cuda
paul0403 Jun 10, 2025
298a9ab
don't ask when pip uninstall
paul0403 Jun 10, 2025
41ca911
testpypi catalyst follows dep versions already
paul0403 Jun 10, 2025
76eab9d
Merge remote-tracking branch 'origin/main' into paul0403/add_flaky_runs
paul0403 Jun 11, 2025
ec82572
Merge remote-tracking branch 'origin/main' into paul0403/add_flaky_runs
paul0403 Jun 11, 2025
fdcd8f3
set read-only permission on job
paul0403 Jun 11, 2025
b61f2db
popping capabilities should be per custom device class, NOT per insta…
paul0403 Jun 11, 2025
a981a4a
remove unused flaky import
paul0403 Jun 11, 2025
91f9c47
Merge remote-tracking branch 'origin/main' into paul0403/add_flaky_runs
paul0403 Jun 11, 2025
38b8753
add reset fixture to autograph `Failing` test util class
paul0403 Jun 11, 2025
35feb0f
add failure notif
paul0403 Jun 11, 2025
4d78c8e
codefactor
paul0403 Jun 11, 2025
a804c32
test failure notif
paul0403 Jun 11, 2025
29e82b8
remove temporary PR testings
paul0403 Jun 11, 2025
d2f87e1
Merge remote-tracking branch 'origin/main' into paul0403/add_flaky_runs
paul0403 Jun 12, 2025
86755fb
remove unnecessary line
paul0403 Jun 12, 2025
05421ef
add docstring for the mysterious `Failing` class in autograph test
paul0403 Jun 12, 2025
6b6a564
test_whileloop_no_warning passes
paul0403 Jun 13, 2025
de5e9ab
remove unused argument
paul0403 Jun 13, 2025
b6f27f9
Merge remote-tracking branch 'origin/main' into paul0403/add_flaky_runs
paul0403 Jun 13, 2025
e4f5a79
Update frontend/test/pytest/test_autograph.py
paul0403 Jun 13, 2025
c8f7956
line too long
paul0403 Jun 13, 2025
d26d043
remove test_whileloop_no_warning
paul0403 Jun 13, 2025
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
32 changes: 32 additions & 0 deletions .github/workflows/check-weekly-flaky.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run Catalyst pytests for flaky test checking

on:
pull_request: # temporarily set this on PR to check this script
types:
- opened
- reopened
- synchronize
- ready_for_review
schedule:
# Run every weekend on Saturday at 23:40 EDT (cron is in UTC)
# https://crontab.cronhub.io/
- cron: "40 23 * * SAT"
workflow_dispatch:

jobs:
install-dependencies:
name: Install dependencies
runs-on: ubuntu-24.04

steps:
- name: Checkout Catalyst repo
uses: actions/checkout@v4

- name: Install Deps
run: |
python3 -m pip install -r requirements.txt
pip install --pre -U --extra-index-url https://test.pypi.org/simple/ PennyLane-Catalyst

- name: Run Python Pytest Tests with flaky Checks
run: |
make pytest ENABLE_FLAKY=ON
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ TEST_BACKEND ?= "lightning.qubit"
TEST_BRAKET ?= NONE
ENABLE_ASAN ?= OFF
TOML_SPECS ?= $(shell find ./runtime ./frontend -name '*.toml' -not -name 'pyproject.toml')
ENABLE_FLAKY ?= OFF

PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM),Linux)
Expand Down Expand Up @@ -54,7 +55,11 @@ endif
# with the ASAN runtime. Since we don't exert much control over the "user" compiler, skip them.
TEST_EXCLUDES := -k "not test_executable_generation"
endif
PYTEST_FLAGS := $(PARALLELIZE) $(TEST_EXCLUDES)
FLAKY :=
ifeq ($(ENABLE_FLAKY),ON)
FLAKY := --force-flaky --max-runs=5 --min-passes=5
endif
PYTEST_FLAGS := $(PARALLELIZE) $(TEST_EXCLUDES) $(FLAKY)

# TODO: Find out why we have container overflow on macOS.
ASAN_OPTIONS := ASAN_OPTIONS="detect_leaks=0,detect_container_overflow=0"
Expand Down
2 changes: 2 additions & 0 deletions frontend/test/pytest/device/test_decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np
import pennylane as qml
import pytest
from flaky import flaky
from pennylane.devices.capabilities import DeviceCapabilities, OperatorProperties

from catalyst import CompileError, ctrl, qjit
Expand Down Expand Up @@ -136,6 +137,7 @@ def f():
with pytest.raises(CompileError, match="could not be decomposed, it might be unsupported."):
qjit(f, target="jaxpr")

@flaky(max_runs=1, min_passes=1)
def test_no_unitary_support(self):
"""Test that unknown controlled operations without QubitUnitary support raise an error."""

Expand Down
2 changes: 2 additions & 0 deletions frontend/test/pytest/test_autograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import numpy as np
import pennylane as qml
import pytest
from flaky import flaky
from jax.errors import TracerBoolConversionError
from numpy.testing import assert_allclose

Expand Down Expand Up @@ -1685,6 +1686,7 @@ def test_logical_mixture_static_dynamic_default(self, s, d):
class TestMixed:
"""Test a mix of supported autograph conversions and Catalyst control flow."""

@flaky(max_runs=1, min_passes=1)
def test_force_python_fallbacks(self):
"""Test fallback modes of control-flow primitives."""

Expand Down
2 changes: 2 additions & 0 deletions frontend/test/pytest/test_measurement_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import pennylane as qml
import pytest
from conftest import CONFIG_CUSTOM_DEVICE
from flaky import flaky
from pennylane.devices import Device
from pennylane.devices.capabilities import OperatorProperties
from pennylane.transforms import split_non_commuting, split_to_single_terms
Expand Down Expand Up @@ -741,6 +742,7 @@ def test_split_non_commuting_is_added_for_full_diagonalization(

assert split_non_commuting in transform_program

@flaky(max_runs=1, min_passes=1)
def test_measurements_are_split(self, mocker):
"""Test that the split_to_single_terms or split_non_commuting transform
are added to the transform program from preprocess as expected, based on the
Expand Down
2 changes: 2 additions & 0 deletions frontend/test/pytest/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pennylane as qml
import pytest
from conftest import CONFIG_CUSTOM_DEVICE
from flaky import flaky
from pennylane.devices import Device, NullQubit
from pennylane.devices.capabilities import DeviceCapabilities, OperatorProperties
from pennylane.tape import QuantumScript
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_decompose_ops_to_unitary(self):
assert isinstance(decomposed_ops[0], qml.QubitUnitary)
assert isinstance(decomposed_ops[1], qml.RX)

@flaky(max_runs=1, min_passes=1)
def test_decompose_ops_to_unitary_integration(self):
"""Test the decompose ops to unitary transform as part of the Catalyst pipeline."""
dev = CustomDevice(wires=4, shots=None)
Expand Down