Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program capture sharp bits page for v0.41 #7062

Merged
merged 84 commits into from
Apr 7, 2025

Conversation

isaacdevlugt
Copy link
Contributor

@isaacdevlugt isaacdevlugt commented Mar 10, 2025

Context: Documentation for program capture (sc-84388)

Description of the Change: Adds a sharp bits page for program capture features (or lack thereof!)

Benefits: Explains the caveats, nuances, and edge cases associated with using this very new feature in PennyLane

Possible Drawbacks: Hopefully none :)

Related GitHub Issues:

@isaacdevlugt isaacdevlugt changed the title first Program capture sharp bits page for v0.41 Mar 10, 2025
@isaacdevlugt isaacdevlugt changed the title Program capture sharp bits page for v0.41 [WIP] Program capture sharp bits page for v0.41 Mar 10, 2025
@isaacdevlugt isaacdevlugt marked this pull request as ready for review March 10, 2025 18:56
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (v0.41.0-rc0@3c30d6b). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             v0.41.0-rc0    #7062   +/-   ##
==============================================
  Coverage               ?   99.64%           
==============================================
  Files                  ?      513           
  Lines                  ?    50069           
  Branches               ?        0           
==============================================
  Hits                   ?    49893           
  Misses                 ?      176           
  Partials               ?        0           

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

Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

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

Did an initial pass through :)

Note, this is a better fit in the "Release news" part of the ToC, as this is not really a quickstart guide.

We have a similar Sharp bits page for the new operators in the quickstart guide (which can probably be removed now)

Co-authored-by: Josh Izaac <josh146@gmail.com>
isaacdevlugt and others added 3 commits April 4, 2025 17:29
**Context:** To use the `default.tensor` device in PennyLane, we must
import the `quimb` Python package.

The strategy adopted for this was the same previously used for the
`default.clifford` device, which depends on the `stim` Python package.
That is, when the user imports `pennylane`, the package is imported if
installed on the system, otherwise it is not imported. An error is
raised if the user explicitly tries to instantiate the device without
the package installed.

However, `quimb` frequently raises a warning message when it is imported
if `kahypar` is not installed. This seems to be a long-standing issue
with the `contengra` package, and causes the following unpleasant
situation: if a user has `quimb` installed on the system (along with
some other packages) and imports `pennylane`, the following warning
message is raised:

```
UserWarning: Couldn't import `kahypar` - skipping from default hyper optimizer and using basic `labels` method instead.
```

**Description of the Change:** We no longer import the `DefaultTensor`
class in `pennylane/devices/__init__.py`.

**Benefits:** Now, the warning message is only raised if the user
explicitly instantiates the device, which makes more sense and is less
ambiguous:

```
qml.device("default.tensor", wires=2)

UserWarning: Couldn't import `kahypar` - skipping from default hyper optimizer and using basic `labels` method instead.
  warnings.warn(
```

Furthermore, this also speeds up the pennylane import process.

**Benefits:** Warnings are no longer raised when importing pennylane if
`cotengra` is installed along with other packages.

**Possible Drawbacks:** The documentation of the `DefaultTensor` device,
as listed in the 'next generation devices', is slightly different:


![DT_attempt](https://github.com/user-attachments/assets/a26142c0-e46d-4deb-9d89-9d15f0173636)

**Related GitHub Issues:** #6893 

[sc-83272]
@isaacdevlugt isaacdevlugt changed the base branch from master to v0.41.0-rc0 April 7, 2025 13:38
@isaacdevlugt isaacdevlugt requested a review from andrijapau April 7, 2025 14:21
Copy link
Contributor

@PietropaoloFrisoni PietropaoloFrisoni left a comment

Choose a reason for hiding this comment

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

Thank @isaacdevlugt !

@PietropaoloFrisoni PietropaoloFrisoni added this to the v0.41 milestone Apr 7, 2025
isaacdevlugt and others added 3 commits April 7, 2025 10:51
**Context:**
The recent paper [Rise of conditionally clean ancillae for optimizing
quantum circuits](https://arxiv.org/abs/2407.17966) presents an improved
decomposition of MCX gates using conditionally clean ancilla qubits. The
proposed method achieves the following trade-offs in terms of Toffoli
gate count and circuit depth:

- 2n − 3 Toffoli and O(n) depth using 1 clean ancilla
- 2n − 3 Toffoli and O(log(n)) depth using 2 clean ancilla
- 4n − 8 Toffoli and O(n) depth using 1 dirty ancilla
- 4n - 8 Toffoli and O(log(n)) depth using 2 dirty ancilla

This approach is currently optimal regarding Toffoli count (for 1 and 2
ancillae) and significantly improves circuit depth.

**Description of the Change:**
Added `_decompose_mcx_with_two_workers` and
`_decompose_mcx_with_one_worker_kg24` decompositions.

**Benefits:**
Extend support to:
- `len(work_wires) == 2`, enabling a more efficient decomposition
- Improved decomposition for `len(work_wires) == 1`, reducing circuit
depth.

**Related GitHub Issues:**
Implements #6997

---------

Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca>
Co-authored-by: Jay Soni <jay@xanadu.ai>
Co-authored-by: Astral Cai <astralcai@gmail.com>
Copy link
Contributor

@andrijapau andrijapau left a comment

Choose a reason for hiding this comment

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

Amazing! Great work @isaacdevlugt. If anything comes up during QA we can always modify this document. 😄

@isaacdevlugt isaacdevlugt changed the base branch from v0.41.0-rc0 to v0.41.0-docs April 7, 2025 17:36
@isaacdevlugt isaacdevlugt enabled auto-merge (squash) April 7, 2025 22:03
@isaacdevlugt isaacdevlugt merged commit 6c31ef7 into v0.41.0-docs Apr 7, 2025
14 checks passed
@isaacdevlugt isaacdevlugt deleted the sc-84388-program-capture-sharp-bits branch April 7, 2025 22:19
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.

6 participants