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

Allow constructing a SparsePauliOp from a SparseObservable #13500

Open
Cryoris opened this issue Nov 27, 2024 · 2 comments
Open

Allow constructing a SparsePauliOp from a SparseObservable #13500

Cryoris opened this issue Nov 27, 2024 · 2 comments
Assignees
Labels
mod: quantum info Related to the Quantum Info module (States & Operators) type: feature request New feature or request

Comments

@Cryoris
Copy link
Contributor

Cryoris commented Nov 27, 2024

What should we add?

quantum_info objects can typically be constructed from one another, e.g. we can do SparseObservable(sparse_pauli_op_type), Operator(sparse_pauli_op_type) or SparsePauliOp.from_operator(operator_type). It would be nice to extend these operations for SparseObservable. In particular constructing a SparsePauliOp from a SparseObservable would ease the transition to this new type -- doing the construction for an Operator is more of an optional convenience (albeit possibly leading users onto inefficient paths).

@Cryoris Cryoris added the type: feature request New feature or request label Nov 27, 2024
@Cryoris Cryoris self-assigned this Nov 27, 2024
@jakelishman
Copy link
Member

Constructing SparsePauliOp from SparseObservable can exponentially explode the memory usage - that's one of the reasons SparseObservable needed to exist. We should still allow it, but it possibly shouldn't be an allowed default conversion in the default constructor because it's dangerous.

All the work for Operator is tracked by #13389.

@Cryoris
Copy link
Contributor Author

Cryoris commented Nov 28, 2024

Oh right, the Operator case will already be done with the to_matrix method 👍🏻

Regarding the exponential overhead: yes that's right, maybe we'll just add a method instead, SparsePauliOp.from_sparse_observable instead and include a runtime warning in case we'd need to construct too many Paulis for the projectors.

@Cryoris Cryoris changed the title Allow constructing a SparsePauliOp and Operator from a SparseObservable Allow constructing a SparsePauliOp from a SparseObservable Nov 28, 2024
@ShellyGarion ShellyGarion added the mod: quantum info Related to the Quantum Info module (States & Operators) label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: quantum info Related to the Quantum Info module (States & Operators) type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants