Skip to content

feat: Add global_phase method - #2228

Draft
tatiana-s wants to merge 1 commit into
mainfrom
ts/global-phase
Draft

tatiana-s wants to merge 1 commit into
mainfrom
ts/global-phase

Conversation

@tatiana-s

Copy link
Copy Markdown
Contributor

Closes #2080

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectguppylang
Branchts/global-phase
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
62.10 x 1e3
(0.00%)Baseline: 62.10 x 1e3
62.72 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
4,585.00
(0.00%)Baseline: 4,585.00
4,630.85
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
27.83 x 1e3
(0.00%)Baseline: 27.83 x 1e3
28.11 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
1,301.00
(0.00%)Baseline: 1,301.00
1,314.01
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
7.24 x 1e3
(0.00%)Baseline: 7.24 x 1e3
7.32 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
310.00
(0.00%)Baseline: 310.00
313.10
(99.01%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
9.91 x 1e3
(0.00%)Baseline: 9.91 x 1e3
10.01 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
411.00
(0.00%)Baseline: 411.00
415.11
(99.01%)
🐰 View full continuous benchmarking report in Bencher

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (ed54651) to head (a10ed82).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2228   +/-   ##
=======================================
  Coverage   93.25%   93.26%           
=======================================
  Files         160      161    +1     
  Lines       15266    15282   +16     
=======================================
+ Hits        14237    14253   +16     
  Misses       1029     1029           

☔ 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.

@codspeed-hq

codspeed-hq Bot commented Aug 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing ts/global-phase (a10ed82) with main (ed54651)

Open in CodSpeed

from guppylang.std.angles import angle


@custom_function(GlobalPhaseCompiler(), effects=[Effect.ANY])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
@custom_function(GlobalPhaseCompiler(), effects=[Effect.ANY])
@custom_function(GlobalPhaseCompiler(), effects=[Effect.ANY], unitary_flags=UnitaryFlags.Unitary)

@@ -0,0 +1,55 @@
import numpy as np

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test also:

@guppy(unitary=True)
def fun() -> None:
    global_phase(angle(0.5))

@guppy
def main_c_gp() -> None:
    c = qubit()
    h(c)
    with control(c):
        fun()
    state_result("r", c)
    discard(c)

For now, it is expected to fail because I need to change something in the modifier resolution

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.

[Feature]: Add a global phase operator to Guppy

3 participants