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

Demo on " Constant-depth preparation of matrix product states with dynamic circuits" #1185

Merged
merged 46 commits into from
Oct 9, 2024

Conversation

dwierichs
Copy link
Contributor

@dwierichs dwierichs commented Aug 9, 2024

Title:
Constant-depth preparation of matrix product states with dynamic circuits

Summary:
Matrix product states (MPS) form an important class of quantum many-body states. Preparing them is an important subroutine for any algorithm that want to use MPS as an initial state, for example. A recent paper, on which this demo is based, and which it is following closely, generalized a method that reduces the depth of such a preparation circuit to constant scaling, by using auxiliary qubits and dynamic quantum circuits (mid-circuit measurements together with classical feedforward).
We here focus on the simplest scenario in the main text of the paper, and implement a simple example in code.
The implemented MPS has a parameter controlling the correlation length of the prepared state, which we verify explicitly.

Relevant references:
https://arxiv.org/pdf/2404.16083
https://arxiv.org/pdf/quant-ph/0501096
https://journals.aps.org/prxquantum/pdf/10.1103/PRXQuantum.4.020315

Possible Drawbacks:

Related GitHub Issues:


If you are writing a demonstration, please answer these questions to facilitate the marketing process.

  • GOALS — Why are we working on this now?

    Mid-circuit measurements recently are/were a focus point in PennyLane. MPS states are used in some quantum chemistry algorithms as initial state.

  • AUDIENCE — Who is this for?

    Researchers in quantum algorithms

  • KEYWORDS — What words should be included in the marketing post?

TBD

  • Which of the following types of documentation is most similar to your file?
    (more details here)
  • Tutorial
  • Demo
  • How-to

[sc-64275]

Copy link

github-actions bot commented Aug 9, 2024

👋 Hey, looks like you've updated some demos!

🐘 Don't forget to update the dateOfLastModification in the associated metadata files so your changes are reflected in Glass Onion (search and recommendations).

Please hide this comment once the field(s) are updated. Thanks!

@dwierichs dwierichs marked this pull request as ready for review August 13, 2024 12:14
@dwierichs dwierichs changed the title [WIP] Demo on "Constant-depth preparation of matrix product states with adaptive quantum circuits" [WIP] Demo on " Constant-depth preparation of matrix product states with dynamic circuits" Aug 13, 2024
Comment on lines 8 to 9
"dateOfPublication": "2024-09-10T00:00:00+00:00",
"dateOfLastModification": "2024-09-10T00:00:00+00:00",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To do

Copy link

github-actions bot commented Aug 20, 2024

Thank you for opening this pull request.

You can find the built site at this link.

Deployment Info:

  • Pull Request ID: 1185
  • Deployment SHA: 57988a5acaed01429ec1592990b98fca42b8ee83
    (The Deployment SHA refers to the latest commit hash the docs were built from)

Note: It may take several minutes for updates to this pull request to be reflected on the deployed site.

@dwierichs dwierichs changed the title [WIP] Demo on " Constant-depth preparation of matrix product states with dynamic circuits" Demo on " Constant-depth preparation of matrix product states with dynamic circuits" Aug 21, 2024
@dwierichs dwierichs requested a review from Qottmann August 21, 2024 10:57
Copy link
Collaborator

@Qottmann Qottmann left a comment

Choose a reason for hiding this comment

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

This has turned out super nice, really well done @dwierichs

Just have some further, rather nitpicky but I think important points about the (very nice) illustrations and their positioning 🙃

demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@Qottmann Qottmann left a comment

Choose a reason for hiding this comment

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

👨‍🍳 👌
image

Copy link
Contributor

@ikurecic ikurecic left a comment

Choose a reason for hiding this comment

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

Thank you, @dwierichs . I've left some comments and suggestions. Please let me know if there's something I can clarify or help with. Thanks.

demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
demonstrations/tutorial_constant_depth_mps_prep.py Outdated Show resolved Hide resolved
@ikurecic ikurecic merged commit acd1f70 into master Oct 9, 2024
10 checks passed
@ikurecic ikurecic deleted the mps-mcm-demo branch October 9, 2024 09:36
albi3ro added a commit to PennyLaneAI/pennylane that referenced this pull request Nov 8, 2024
**Context:**
On the level of mid-scale algorithms, it might be nice to differentiate
between different "types" of wires, for example by coloring them
differently, or giving them distinct line styles. As an example, in
PennyLaneAI/qml#1185 on preparing matrix product
states, there are auxiliary bond qubits and physical qubits, and
coloring them differently would be a neat thing to do.

**Description of the Change:**
Update the output wire_options that could change the line style and
color for circuit output.
```python
        @qml.qnode(qml.device("default.qubit"))
        def node(x):
            for w in range(5):
                qml.Hadamard(w) 
            return qml.expval(qml.PauliZ(0) @ qml.PauliY(1))

        # Make all wires cyan and bold, 
        # except for wires 2 and 6, which are dashed and another color
        wire_options = {"color": "cyan", 
                        "linewidth": 5, 
                        2: {"linestyle": "--", "color": "red"}, 
                        6: {"linestyle": "--", "color": "orange"}
                    }
        _,ax  = qml.draw_mpl(node, wire_options=wire_options)(0.52)
```

**Benefits:**
When complicated sates and quantum circuits diagram are created, wires
could be marked with different selections.

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
#6165

---------

Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: ringo-but-quantum <>
Co-authored-by: Astral Cai <[email protected]>
Co-authored-by: Christina Lee <[email protected]>
mudit2812 pushed a commit to PennyLaneAI/pennylane that referenced this pull request Nov 11, 2024
**Context:**
On the level of mid-scale algorithms, it might be nice to differentiate
between different "types" of wires, for example by coloring them
differently, or giving them distinct line styles. As an example, in
PennyLaneAI/qml#1185 on preparing matrix product
states, there are auxiliary bond qubits and physical qubits, and
coloring them differently would be a neat thing to do.

**Description of the Change:**
Update the output wire_options that could change the line style and
color for circuit output.
```python
        @qml.qnode(qml.device("default.qubit"))
        def node(x):
            for w in range(5):
                qml.Hadamard(w) 
            return qml.expval(qml.PauliZ(0) @ qml.PauliY(1))

        # Make all wires cyan and bold, 
        # except for wires 2 and 6, which are dashed and another color
        wire_options = {"color": "cyan", 
                        "linewidth": 5, 
                        2: {"linestyle": "--", "color": "red"}, 
                        6: {"linestyle": "--", "color": "orange"}
                    }
        _,ax  = qml.draw_mpl(node, wire_options=wire_options)(0.52)
```

**Benefits:**
When complicated sates and quantum circuits diagram are created, wires
could be marked with different selections.

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
#6165

---------

Co-authored-by: David Wierichs <[email protected]>
Co-authored-by: ringo-but-quantum <>
Co-authored-by: Astral Cai <[email protected]>
Co-authored-by: Christina Lee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants