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 TN with LightningTensor #1288

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

multiphaseCFD
Copy link
Member

Before submitting

Please complete the following checklist when submitting a PR:

  • Ensure that your tutorial executes correctly, and conforms to the
    guidelines specified in the README.

  • Remember to do a grammar check of the content you include.

  • All tutorials conform to
    PEP8 standards.
    To auto format files, simply pip install black, and then
    run black -l 100 path/to/file.py.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Title:

Summary:

Relevant references:

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?

    Eg. Promote a new PL feature or show a PL implementation of a recent paper.

  • AUDIENCE — Who is this for?

    Eg. Chemistry researchers, PL educators, beginners in quantum computing.

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

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

  • Tutorial
  • Demo
  • How-to

Copy link

github-actions bot commented Jan 2, 2025

👋 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!

@DSGuala
Copy link
Contributor

DSGuala commented Jan 3, 2025

Linking to shortcut:
[SC-77037]

@multiphaseCFD multiphaseCFD requested a review from josh146 January 8, 2025 16:21
@multiphaseCFD
Copy link
Member Author

Hey @LuisAlfredoNu , could you please help to double check if the scripts shown in this demo work? Thank you.

Comment on lines +105 to +142
import pennylane as qml
import numpy as np
import time

# Parameters of the quantum circuit
theta = 0.5
phi = 0.1
depth = 10
n = 1011
num_qubits = 100

# Instantiate the device with the TN method and the specified kwargs
dev = qml.device("lightning.tensor", wires=num_qubits, method="tn")


@qml.qnode(dev)
def circuit(theta, depth, n, num_qubits):
for i in range(num_qubits):
qml.X(wires=i)
for _ in range(1, depth - 1):
for i in range(0, num_qubits, 2):
qml.CNOT(wires=[i, i + 1])
for i in range(num_qubits % 5):
qml.RZ(theta, wires=i)
for i in range(1, num_qubits - 1, 2):
qml.CZ(wires=[i, i + 1])
for i in range(num_qubits - 1):
qml.CNOT(wires=[i, (i + 1)])
return qml.expval(qml.X(num_qubits - 1))


# Simulate the circuit for different numbers of qubits
print(f"Number of qubits: {num_qubits}")
start_time = time.time()
result = circuit(theta, depth, n, num_qubits)
end_time = time.time()
print(f"Result: {result}")
print(f"Execution time: {end_time - start_time:.4f} seconds")

Choose a reason for hiding this comment

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

The output of this code is the following:

Number of qubits: 100
Result: 0.0
Execution time: 22.2965 seconds

@multiphaseCFD multiphaseCFD marked this pull request as ready for review January 10, 2025 19:36
"tags": [
"how to"
],
"previewImages": [],
Copy link
Member Author

Choose a reason for hiding this comment

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

Wondering if we want to add new images for LT? @DSGuala @tomlqc

@multiphaseCFD multiphaseCFD changed the title [WIP] Demo TN with LightningTensor Demo TN with LightningTensor Jan 20, 2025
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.

4 participants