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

Neat gif with simple Tangelo code snippets to show people how easy it is to use the software #389

Open
ValentinS4t1qbit opened this issue May 28, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@ValentinS4t1qbit
Copy link
Collaborator

ValentinS4t1qbit commented May 28, 2024

A picture (or a gif !) is worth a thousand words. Wouldn't it be nice if people could just see in practice how Tangelo works on simple tasks without having to dig into documentation, tutorials, etc ? They'd just "get it" and be able to decide if that's relevant to them or not.

Well, a gif in our README would be pretty neat. To win this:

  • upload a gif in the docs folder on the repo
  • alongside a simple text or rst file describing how you did it (don't worry about the README file, leave it alone). Mention the tools / website / techniques and the text used.

Here is what we want to see in that gif:

  • a sequence of code snippets (provided below) gradually typed on screen, accompanied with the output
  • try to keep the size of the text consistent across snippets.

Snippets and their results:




Snippet 1

# Run circuits on your favorite simulators

from tangelo.linq import Gate, Circuit, get_backend

c = Circuit([Gate('H', 0), Gate('X', 1)])
sim = get_backend("qiskit")  # or "qulacs", "cirq" ...
bitstring_frequencies, statevector = sim.simulate(c, return_statevector=True)

print(f'{bitstring_frequencies=} \n{statevector=}')
Screenshot 2024-05-28 at 4 27 00 PM




Snippet 2

# Use all the projects in the quantum ecosystem !

from tangelo.linq import translate_circuit

c_qiskit = translate_circuit(c, target="qiskit")  # to or from "qiskit", "pennylane", "cirq", ...
c_qiskit.draw(output='mpl', style={'backgroundcolor': '#EEEEEE'}) # it's a qiskit object !

(this is not the actual output, just run the above code with qiskit and pylatexenc in your environment)

Screenshot 2024-05-28 at 4 30 09 PM




Snippet 3

# Compute ground state of a molecule with VQE
# Check out the computational resources needed

from tangelo import SecondQuantizedMolecule
from tangelo.algorithms import VQESolver

xyz_H2 = [("H", (0., 0., 0.)), ("H", (0., 0., 0.7414))]
mol = SecondQuantizedMolecule(xyz_H2, q=0, spin=0, basis="sto-3g")

vqe_options = {"molecule": mol}  # Plenty options for qubit mappings etc
vqe_solver = VQESolver(vqe_options)
vqe_solver.build()
opt_energy = vqe_solver.simulate()

print(opt_energy)
print(vqe_solver.get_resources())
Screenshot 2024-05-28 at 4 42 35 PM




Snippet 4

from tangelo.linq.qpu_connection import IBMConnection

conn = IBMConnection(ibm_quantum_token='your_ibm_token')
job_id = conn.job_submit('sampler', 'ibmq_qasm_simulator', n_shots=100, circuit)
job_res = conn.job_results(job_id)  # Your job on IBM Quantum eventually completes

(no output needed)

@ValentinS4t1qbit ValentinS4t1qbit added the documentation Improvements or additions to documentation label May 28, 2024
@ValentinS4t1qbit ValentinS4t1qbit self-assigned this May 28, 2024
@ValentinS4t1qbit ValentinS4t1qbit added the good first issue Good for newcomers label May 28, 2024
@ValentinS4t1qbit ValentinS4t1qbit changed the title Insert a neat gif with simple Tangelo code snippets to show people how easy it is to use the software Neat gif with simple Tangelo code snippets to show people how easy it is to use the software May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant