Interface #45
Replies: 8 comments 39 replies
|
Copying the message you posted elsewhere: # ═══════════════ MAJORANA ═══════════════ ║ ═══════════════ PAULI (qubit) ═══════════════
from monoprop import (MajoranaPropagator, # from monoprop import (PauliPropagator,
MajoranaGate, MajoranaCircuit) # PauliGate, PauliCircuit)
from monoprop.majorana_data import MajoranaOperator # from monoprop.pauli_data import PauliOperator
# 1. Observable ║
obs = MajoranaOperator.from_dict( # obs = PauliOperator(["ZZ"], [1.0])
{(0, 1): 1.0j}, num_modes=2) # # num_qubits inferred from string length
# 2. Gates — pure generators (no angle on them) ║
g0 = MajoranaGate( # g0 = PauliGate((0,),
MajoranaOperator.from_dict({(0,): 1.0})) # PauliOperator(["X"], [1.0]))
g1 = MajoranaGate( # g1 = PauliGate((0, 1),
MajoranaOperator.from_dict({(2, 3): 1.0j})) # PauliOperator(["ZZ"], [1.0]))
# 3. Circuit — gates + angle values + mapping ║
circ = MajoranaCircuit( # circ = PauliCircuit(
(g0, g1), parameters=(0.3, 0.7), # (g0, g1), parameters=(0.3, 0.7),
initial_state=(0, 1)) # initial_state=(), num_qubits=2)
# 4. Propagator ║
mp = MajoranaPropagator.from_circuit( # pp = PauliPropagator.from_circuit(
circ, obs, cutoff=4) # circ, obs, cutoff=2)Ways to propgate: # A. from_circuit — construct + build the reusable graph in one step (most common)
mp = MajoranaPropagator.from_circuit(circ, obs, cutoff=4)
val = mp.expectation_value(circ) # replay at the circuit's angles
# B. construct, then build_graph — when you build the graph incrementally / reuse it
mp = MajoranaPropagator(obs, initial_state=[0, 1], cutoff=4)
mp.build_graph(circ) # graph now owns the gates + mapping
val = mp.expectation_value([0.3, 0.7]) # re-evaluate at any angles, cheaply
# C. propagate — one-shot, no graph stored (memory-lean, single contraction)
mp = MajoranaPropagator(obs, initial_state=[0, 1], cutoff=4)
mp.propagate(circ)
op = mp.evolved_operator() # {majorana-index-tuple: complex} |
|
Tagging people with relevant opinions: |
In my opinion the cleanest and most intuitive way for a user would be: from monoprop.majorana import ...
from monoprop.pauli import ... |
|
Regarding ways to propagate, I think the most important distinction is Heisenberg vs Schrodinger, not Majorana vs Pauli. Do you have examples for the two pictures? |
I would go for |
I totally agree. Also, what if I need to create e.g. the |
|
@diagonal-hamiltonian @robertodr Question: do we really need to have a |
I don't like A. because we are passing I like the idea of supporting both B. and C. but |
Uh oh!
There was an error while loading. Please reload this page.
#40 lets spitball
All reactions