Skip to content

test: add tests like tket2 "guppy_optimization" - #2522

Open
acl-cqc wants to merge 12 commits into
mainfrom
acl/test_optimization
Open

acl-cqc wants to merge 12 commits into
mainfrom
acl/test_optimization

Conversation

@acl-cqc

@acl-cqc acl-cqc commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Modelled on Quantinuum/tket2#2144 but without the offline generation or Hugrs from older versions of guppy: the idea is to detect if we change guppy in a way that breaks optimization.

The other idea was that we'd use standard OptimizationLevel.Default code already in guppy to drive the optimizer, rather than tket2's test_guppy_opt.py having its own code to drive what optimizations to do, which I expected to largely duplicate guppylang's OptimizationLevel. Turns out tket2 uses pytket CliffordSimp rather than the RemoveRedundancies used by OptimizationLevel.Default, but in many cases either works, so there is some difference vs the tket2 tests here.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectguppylang
Branchacl/test_optimization
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes
(Result Δ%)
Upper Boundary
nodes
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
59.84 x 1e3
(0.00%)Baseline: 59.84 x 1e3
60.44 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
4,514.00
(0.00%)Baseline: 4,514.00
4,559.14
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
26.87 x 1e3
(0.00%)Baseline: 26.87 x 1e3
27.14 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
1,182.00
(0.00%)Baseline: 1,182.00
1,193.82
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
6.70 x 1e3
(0.00%)Baseline: 6.70 x 1e3
6.77 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
279.00
(0.00%)Baseline: 279.00
281.79
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
9.22 x 1e3
(0.00%)Baseline: 9.22 x 1e3
9.31 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
371.00
(0.00%)Baseline: 371.00
374.71
(99.01%)
🐰 View full continuous benchmarking report in Bencher

@codspeed

codspeed Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 7 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 11 untouched benchmarks


Comparing acl/test_optimization (647b1a3) with main (698b9a4)

Open in CodSpeed

@acl-cqc
acl-cqc force-pushed the acl/test_optimization branch from 5b36adf to f91b6c0 Compare November 10, 2026 21:55
@codecov-commenter

codecov-commenter commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.40%. Comparing base (dfaffd9) to head (647b1a3).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2522      +/-   ##
==========================================
+ Coverage   93.36%   93.40%   +0.04%     
==========================================
  Files         167      167              
  Lines       16947    17050     +103     
==========================================
+ Hits        15823    15926     +103     
  Misses       1124     1124              

☔ View full report in Codecov by Harness.
📢 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.

@acl-cqc
acl-cqc marked this pull request as ready for review November 11, 2026 12:00
@acl-cqc
acl-cqc requested a review from a team as a code owner November 11, 2026 12:00
@@ -0,0 +1,569 @@
"""Tests optimizing Hugrs generated offline by Guppy programs."""

# ALAN TODO Should be integrated into either tests/test_optimization.py

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thoughts here? I was a bit unclear about why tests/test_optimization.py wasn't already in tests/integration/...

This branch has not been deployed

No deployments
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