Conversation
|
This PR contains breaking changes to the public Python API. Breaking changes summary |
|
| Project | guppylang |
| Branch | codex/abstract-qubit-protocol |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 61.81 x 1e3(-0.47%)Baseline: 62.10 x 1e3 | 62.72 x 1e3 (98.55%) | 📈 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.86 x 1e3(+0.13%)Baseline: 27.83 x 1e3 | 28.11 x 1e3 (99.13%) | 📈 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%) |
Merging this PR will degrade performance by 51.16%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | test_circuit_comptime_check |
1.4 s | 7.1 s | -79.76% |
| ❌ | test_many_ctrl_flow_check |
1.3 s | 3.1 s | -58.23% |
| ❌ | test_big_array_check |
11.9 s | 26.2 s | -54.4% |
| ❌ | test_circuit_comptime_compile |
10 s | 16.1 s | -37.74% |
| ❌ | test_big_array_compile |
35.4 s | 50.7 s | -30.2% |
| ❌ | test_many_ctrl_flow_compile |
8.2 s | 10.2 s | -18.99% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing codex/abstract-qubit-protocol (741b46c) with main (ec1e2e4)
| @@ -1,5 +1,5 @@ | |||
| # See https://docs.astral.sh/ruff/rules/ | |||
| target-version = "py310" | |||
| target-version = "py312" | |||
There was a problem hiding this comment.
this is outside the scope of the PR, you can make an exception for your test files at the bottom of ruff.toml
There was a problem hiding this comment.
yes sorry pushed local change accidentally
| q.crz(self.inner, target.inner, theta) | ||
|
|
||
| @guppy(unitary=True) | ||
| def toffoli(self, control2: Self, target: Self) -> None: |
There was a problem hiding this comment.
toffoli would make more sense as a method that takes something implementing AbstractProtocol.
Generally, we need to think about what the minimal api surface for a qubit should be if we're going to add it to std. Something that's way too broad like seems like a big pain for abstracting logical qubits
There was a problem hiding this comment.
yeah - hence why I'm unsure about this without defaults
There was a problem hiding this comment.
going extreme we could take tket1's approach: implement CX and an arbitrary single qubit gate and that's it (I guess also alloc/measure/discard)
There was a problem hiding this comment.
I would prefer that approach, it just makes things useless for codes that have a different set of native gates (e.g. if CX is costly but CZ is cheap). Maybe we shouldn't spend too much time worry about these cases, since writing around the stdlib for high performance code is the norm
| q.toffoli(self.inner, control2.inner, target.inner) | ||
|
|
||
| @guppy(unitary=True) | ||
| def controlled_hadamard(self, target: Self) -> None: |
There was a problem hiding this comment.
if we have unitary hadamard, we don't need this, we can write
with control(...):
q.hadamard()
Summary
AbstractQubitprotocol with descriptive (more verbose than stdlib functions),Self-typed quantum operationsqubitimplement the protocol and retain the existing short-formstd.quantumAPI as generic delegatesruffstill checking against python 3.10 #2119Follow-up
Derived quantum operations such as Toffoli are currently required protocol members. Providing defaults for these operations is tracked by #2205; the protocol contains a matching TODO.