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

Support static parameters for GlobalPhase and multiRZ gates. #1396

Open
wants to merge 33 commits into
base: v0.10.0-rc
Choose a base branch
from

Conversation

mehrdad2m
Copy link
Contributor

Context:
PR #1387, adds support for static parameters in customOp. However support for GlobalPhase and MultiRZ gates are missing.

Description of the Change:
This PR adds support for the missing two gates. We unified the way GlobalPhase and MultiRZ are treated in the frontend. right now, GlobalPase has its own primitive (qphase_p) however MultiRZ is binded through the qinst_p primitive. qphase_p is now removed from frontend and binded through qints_p similar to MultiRZ.
If a MultiRZ or GlobalPhase gate has static parameters parameters, a staticCustomOp is created which will be lowered to the respective gate in static_custom_lowering pass.

Benefits:
removed inconsistency in the definition of odd custom gates (MultiRZ and GlobalPhase)
static circuit IR now supports more parameterized gates.

Possible Drawbacks:

Related GitHub Issues:

@@ -201,7 +200,7 @@ def _eval_jaxpr(*args, **kwargs):
# Take care when adding primitives to this set in order to avoid introducing a quadratic number of
# edges to the jaxpr equation graph in ``sort_eqns()``. Each equation with a primitive in this set
# is constrained to occur before all subsequent equations in the quantum operations trace.
FORCED_ORDER_PRIMITIVES = {qdevice_p, gphase_p}
FORCED_ORDER_PRIMITIVES = {qdevice_p}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: This needs to be handled in another way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I wonder if this is the reason the primitive exists. Without qubits, it could be reordered before the device is instantiated, which would result in a crash I think

Copy link
Contributor

@erick-xanadu erick-xanadu left a comment

Choose a reason for hiding this comment

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

Thanks @mehrdad2m! I do see why this would be nice, but given the current constraints with the topological sorting, I believe the best, temporary, course of action is to leave the gphase_p primitive as is. Whenever we have time we should determine why the instructions get reordered. (I believe this has to do with how we trace.) However, depending on some future changes, this investigation may no longer be needed.

Regarding MultiRZ, I think it is ok to merge in a single primitive but it is not incredibly important. I'll leave it up to you if you want to merge it or close this PR without merging.

@dime10
Copy link
Contributor

dime10 commented Jan 2, 2025

Agreed, let's just keep the gphase_p primitive and we can still map both gphase and multirz to the StaticCustomOp when the params are static.

ringo-but-quantum and others added 24 commits January 6, 2025 16:55
…states, and use it to disentangle CNOTs and SWAPs (#1154)

**Context:**
In circuits that mostly involve the six Pauli eigenstates, the effect of
gates can be described by a simple six-state finite state machine. This
allows us to deduce their midcircuit state at compile time.

The knowledge of the snapshot midcircuit states can be useful when:
- Deducing CNOT/Toffoli/SWAP/... effect and decouple them. We decouple
CNOT and SWAP in this PR.
- Replace complicated circuits whose results are |01+-LR> with standard
preparation routines
  - Potentially more

**Description of the Change:**
Added an analysis for propagating simple states (and tests).
Also added CNOT and SWAP decomposition pass `disentangle-CNOT`,
`disentangle-SWAP` (and tests).
Credit to [Ritu Thombre](https://github.com/ritu-thombre99) for the work
on the SWAP gates!

**Benefits:**
More compile time circuit information for potential compile time
transformation/optimization.

**Possible Drawbacks:**
This algorithm is from an external paper. We need to properly cite it. 
https://arxiv.org/abs/2012.07711 (fig.5)

**Related GitHub Issues:** closes #1268 

[sc-74649]
[sc-74650]

---------

Co-authored-by: Ritu Thombre <[email protected]>
Co-authored-by: Ritu Thombre <[email protected]>
**Context:**
Forgotten changelog entry for PR #1387

**Description of the Change:**

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**
**Context:**
Braket tests were removed temporarily because the dev version of
PennyLane needed for Catalyst tests was incompatible with the Braket
plugin in the interim between removing legacy operator arithmetic from
PennyLane and releasing a version of the Braket plugin with no
references to legacy opmath.

Braket has released, so we expect things to work again now. 

**Description of the Change:**
This PR reverses the changes disabling Braket tests in #1308 and #1321.

[sc-78774]
**Context:**
The [wheels are
failing](https://github.com/PennyLaneAI/catalyst/actions/runs/12563739994/job/35026196938)
after we put the Braket tests stuff back

Looking at the wheels, it's ending up installing version 1.28 (we set
the minimum to 1.27). We need a more recent version because
`QubitDevice` isn't accessible at top level and legacy opmath has been
removed.

**Description of the Change:**

Install with `>=0.31.0` instead. We also remove the `boto3` pin, because
it was creating version conflicts and seems to no longer be needed.
**Context:** A number of OQD packages, modules and data files had been
added recently (e.g. #1348 and #1355). However, as support for OQD
devices is still under development, these files should not be included
in the wheels.

**Description of the Change:** Excludes _all_ OQD packages, modules and
data files (such as toml config files) from the wheels. Furthermore, the
OQD device entry in the [Supported devices
documentation](https://docs.pennylane.ai/projects/catalyst/en/stable/dev/devices.html)
has also been removed.
…ent from the wheels (#1406)

**Context:** Switching to a different branch after setting up the dev
wheel environment would break the latter.

**Description of the Change:** Accept a branch to switch to as an
optional argument, and switch to it before hard-linking the frontend
source code files.

**Benefits:** Start working directly on an existing branch.

**Possible Drawbacks:** Switching to another branch using git would keep
breaking the installation.
**Context:** Changelog

---------

Co-authored-by: Joey Carter <[email protected]>
**Context:** In preparation for the Catalyst 0.10.0 release candidate
(RC), the GitHub action must point to the corresponding RC branch,
`v0.10.0-rc`.

**Description of the Change:** Update the Catalyst RC branch `v0.9.0-rc`
-> `v0.10.0-rc`, as well as the corresponding RC branches for Lightning
and PennyLane from `v0.39.0` to `v0.40.0`.
**Context:** Preparing for the Catalyst v0.10.0 release candidate (RC).

**Description of the Change:** Update versions in release notes and
_version.py.
**Context:** Preparing the main branch for Catalyst v0.11.0-dev
(development release).

**Description of the Change:** Bump version to "0.11.0-dev" and add new
changelog.

---------

Co-authored-by: erick-xanadu <[email protected]>
**Context:** The new development release is v0.11.0, not v0.10.0.
:confounded:

**Description of the Change:** Fix typo in title of changelog for
development release.
@mehrdad2m mehrdad2m changed the base branch from main to v0.10.0-rc January 6, 2025 21:58
erick-xanadu and others added 5 commits January 6, 2025 17:13
**Context:**

![Before](https://github.com/user-attachments/assets/3ec337c1-a898-4abd-a9c6-990d8767679c)

**Description of the Change:**


![After](https://github.com/user-attachments/assets/a07c6a1c-f98d-4b00-b9aa-9afd0a893673)

**Benefits:** No floating `}` and well formatted contents.

**Possible Drawbacks:** Do we also want to show the libraries we use?

**Related GitHub Issues:**
**Context:** Fix some typos and phrasing in the docs
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.

9 participants