Skip to content

Test audit/story 1 control flow#2474

Open
JerryChen97 wants to merge 19 commits intomainfrom
test-audit/story-1-control-flow
Open

Test audit/story 1 control flow#2474
JerryChen97 wants to merge 19 commits intomainfrom
test-audit/story-1-control-flow

Conversation

@JerryChen97
Copy link
Copy Markdown
Contributor

@JerryChen97 JerryChen97 commented Feb 10, 2026

Context:
Test Audit: to reveal those remaining incompatibility of capture + qjit.

Description of the Change:
Scope/Files to audit:

  • test_loops.py

The following have already been covered by another fixture (a global one at the file level). Since our goal here is to collect the information about what's missing for capture + catalyst environment, instead of a thorough auditing, it's safe to skip them.

  • test_conditionals.py
  • test_quantum_control.py
  • test_switch.py (do we have qml.switch? no not yet)

Apply capture_mode fixture to those tests who:

  1. not already scoped by e.g. disable_capture
  2. indeed called qjit

Adjustments:

  1. some tests used to return measure() directly. Since they were only designed to test loops, we test same thing with expval now.
  2. TestWhileLoopOperatorAccess and TestForLoopOperatorAccess were not actually changed. They were adjusted only to keep consistent with the convenient while_loop for_loop auto dispatching in the test file.
  3. Testing nested loops:

one test without the qnode to test the classical stuff, and then a second to test gates inside a qnode

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-111254]

- Add module-level pytestmark for use_both_frontend fixture
- Import for_loop, while_loop from pennylane instead of catalyst
- Add measure wrapper that switches between qml.measure and catalyst.measure
- Keep catalyst versions (c_for_loop, c_while_loop, c_measure) for old_frontend tests
- Mark old_frontend tests:
  - TestLoopToJaxpr (tests JAXPR structure)
  - test_non_bool_condition_error (error message specific)
  - test_assert_reference_outside_measure (uses MCM in loop)
  - test_while_loop_raises_compatibility_error_with_capture
  - test_while_loop_raises_compatibility_error_with_capture_integration
  - test_required_index (error message specific)
  - test_for_loop_raises_compatibility_error_with_capture
  - test_for_loop_raises_compatibility_error_with_capture_integration
  - TestForLoopOperatorAccess (.operation attribute)
  - TestWhileLoopOperatorAccess (.operation attribute)
- Mark capture_todo test:
  - test_nested_loops (returns classical value from qnode)
- Rewrite tests returning MCM to use qml.expval(qml.PauliZ(0))
- Update conftest.py to handle old_frontend marker (skip with capture)
@JerryChen97 JerryChen97 changed the title Test audit/story 1 control flow [WIP] Test audit/story 1 control flow Feb 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.00%. Comparing base (d54fdea) to head (0ab02c4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2474   +/-   ##
=======================================
  Coverage   97.00%   97.00%           
=======================================
  Files         157      157           
  Lines       17470    17470           
  Branches     1686     1686           
=======================================
  Hits        16946    16946           
  Misses        387      387           
  Partials      137      137           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JerryChen97 JerryChen97 self-assigned this Feb 11, 2026
@JerryChen97 JerryChen97 changed the title [WIP] Test audit/story 1 control flow Test audit/story 1 control flow Feb 18, 2026
@JerryChen97 JerryChen97 requested a review from albi3ro February 19, 2026 14:43
@github-actions

This comment was marked as off-topic.

Comment thread frontend/test/pytest/test_loops.py Outdated
@andrijapau andrijapau self-requested a review February 23, 2026 19:32
Comment thread frontend/test/pytest/test_loops.py Outdated
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.

2 participants