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

Add pauli_rep property to Adjoint when possible #6876

Open
albi3ro opened this issue Jan 23, 2025 · 3 comments
Open

Add pauli_rep property to Adjoint when possible #6876

albi3ro opened this issue Jan 23, 2025 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@albi3ro
Copy link
Contributor

albi3ro commented Jan 23, 2025

Context:

The Operator.pauli_rep property is a provides an efficient representation of an operator as a linear combination of pauli's, if the operator is an obvious linear combination of pauli's.

>>> (qml.X(0) + 2 * qml.Y(0)).pauli_rep
1.0 * X(0)
+ 2.0 * Y(0)
>>> (qml.X(0) ** 3).pauli_rep
1.0 * X(0)
>>> qml.RX(0.5, 0).pauli_rep is None
True

The returned object is a special dictionary mapping pauli words to coefficients, the PauliSentence

Currently, the pauli_rep for any Adjoint class is None.

>>> qml.adjoint(qml.X(0)).pauli_rep  is None
True

But if the target has a pauli rep, we should be able to provide one on the Adjoint class. We only need to take the conjugate of all the coefficients. You can see similar "modify pauli rep of target" behavior in our SProd (scalar product) class:

pr = {pw: qnp.dot(coeff, scalar) for pw, coeff in base_pauli_rep.items()}

The task

This issue would require initializing the _pauli_rep during initialization of all Adjoint operators to be the adjoint of the target's pauli rep.

The PR should also:

@albi3ro albi3ro added the good first issue Good for newcomers label Jan 23, 2025
@vivek-kumar9696
Copy link

Hi! I would like to take up this issue. Is there anyone else working on it ?
This is my first time trying to contribute to open source codebase and I wanted to know if issues are only assigned after a PR has been raised.

Thanks!!

@albi3ro
Copy link
Contributor Author

albi3ro commented Jan 24, 2025

Thanks for reaching out @vivek-kumar9696 . I've assigned you the issue.

If you have any questions, feel free to either reach out here, or open up a draft PR to start a discussion there.

@vivek-kumar9696
Copy link

@albi3ro Thanks for the reply. I will provide biweekly updates regularly.
Excited to work on this and close my first issue!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants