Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10558 +/- ##
==========================================
- Coverage 99.39% 99.39% -0.01%
==========================================
Files 613 613
Lines 67668 67717 +49
==========================================
+ Hits 67258 67304 +46
- Misses 410 413 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| # Keep the existing unitary fallback ahead of the PPM alternative. | ||
| _controlled_multix = _make_controlled_decomp(_multix_decomposition) | ||
| _controlled_multix.name = "_controlled_multix" | ||
| _controlled_multix.add_condition(lambda control_wires, **_: len(control_wires) == 1) |
There was a problem hiding this comment.
This may look strange but the reason of adding this is that if my C(MultiX) decomposition is the only decomposition added, it was always taking it and measurements always appears in not supported devices.
There was a problem hiding this comment.
Ah this is interesting! Can you ask core if this is the preferred way of doing this? Might be good to let them know that we hit this scenario :)
There was a problem hiding this comment.
asked in #pennylane-core and they are fine with this provisional approach ✅
dwierichs
left a comment
There was a problem hiding this comment.
looking good, nice work @KetpuntoG
Just some small comments.
| using three Pauli product measurements and one auxiliary qubit. It supports | ||
| dynamic bitstrings and controls on either ``0`` or ``1``. |
There was a problem hiding this comment.
| using three Pauli product measurements and one auxiliary qubit. It supports | |
| dynamic bitstrings and controls on either ``0`` or ``1``. | |
| using three Pauli product measurements and one auxiliary qubit. |
|
|
||
| :class:`~.X` | :math:`\sum_i b_i \leq n` (one per :math:`b_i=1`) | 2 | ||
|
|
||
| Single-control ``C(MultiX)`` supports a lattice-surgery decomposition using three |
There was a problem hiding this comment.
Can you add a regular entry to the table instead? :)
| # Keep the existing unitary fallback ahead of the PPM alternative. | ||
| _controlled_multix = _make_controlled_decomp(_multix_decomposition) | ||
| _controlled_multix.name = "_controlled_multix" | ||
| _controlled_multix.add_condition(lambda control_wires, **_: len(control_wires) == 1) |
There was a problem hiding this comment.
Ah this is interesting! Can you ask core if this is the preferred way of doing this? Might be good to let them know that we hit this scenario :)
| add_decomps("C(MultiX)", flip_zero_control2(_controlled_multix_ladder), _controlled_multix) | ||
|
|
||
|
|
||
| def _measure_z_multix(work_wire, bitstring, wires): |
There was a problem hiding this comment.
We have this logic in the recently fixed QROM PPM rule, right? :) Maybe we can reuse it. But just an optional suggestion.
There was a problem hiding this comment.
Yes, I used the same idea as QROM. I kept the helper separate for now because QROM already imports MultiX, but we could combine them later
| ) | ||
| def _controlled_multix_lattice_surgery_ppm(base, control_wires, control_values, **_): | ||
| """Implement a single-control MultiX with three PPMs and one consumed auxiliary qubit.""" | ||
| cond(math.logical_not(control_values[0]), PauliX)(control_wires[0]) |
There was a problem hiding this comment.
Could use the flip_zero_control2 wrapper here.
| work_wires = rule.get_work_wire_spec(**op.arguments) | ||
| assert work_wires.burnable == work_wires.total == 1 | ||
|
|
||
| @pytest.mark.usefixtures("enable_graph_decomposition") |
There was a problem hiding this comment.
This is no longer needed as of very recently :)
| @pytest.mark.usefixtures("enable_graph_decomposition") |
There was a problem hiding this comment.
the test fails without this fixture 🤔
|
|
||
| assert_decomposable(op) | ||
|
|
||
| @pytest.mark.usefixtures("enable_and_disable_graph_decomp") |
There was a problem hiding this comment.
graph is enabled by default now, and I think it's okay to not test without :)
| @pytest.mark.usefixtures("enable_and_disable_graph_decomp") |
| rule = qp.list_decomps(op)["_controlled_multix_lattice_surgery_ppm"] | ||
| outcomes = iter(outcomes) | ||
|
|
||
| # Catalyst does not preserve pauli_measure's postselect argument under capture. |
There was a problem hiding this comment.
Is this a bug we should report? Are we using postselect? 🤔
There was a problem hiding this comment.
We’re not using postselect here. The test uses projectors to check all possible measurement outcomes, so I’ve updated the comment to explain that
|
could we also add multi-control? should be basically the same decomp or am I missing something? |
Before submitting
Please complete the following checklist when submitting a PR:
All new features must include a unit test.
If you've fixed a bug or added code that should be tested, add a test to the
test directory!
All new functions and code must be clearly commented and documented.
If you do make documentation changes, make sure that the docs build and
render correctly by running
make docs.Ensure that the test suite passes, by running
make test.Add a new entry to the
doc/releases/changelog-dev.rstfile, summarizing thechange, and including a link back to the PR.
The PennyLane source code conforms to
PEP8 standards.
We check all of our code against Pylint.
To lint modified files, simply
pip install pylint, and thenrun
pylint pennylane/path/to/file.py.When all the above are checked, delete everything above the dashed
line and fill in the pull request template.
Context:
Working on the goal: All standard gates encountered in application_algos/workflows/ use best-in-class PPR and PPM decompositions on main pennylane
Description of the Change:
Adding lattice surgery like decomposition to c(multiX)
Benefits:
for efficient pbc level decompositions
Possible Drawbacks:
Larger PPM-weights