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

ZZMax randomisation #99

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Comment out seed
  • Loading branch information
daniel-mills-cqc committed Apr 9, 2024
commit 0039850101ae59f6cd0d6eb45614b8384de3b3a3
57 changes: 38 additions & 19 deletions qermit/frame_randomisation/h_series_randomisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,35 @@ def gen_randomised_circuit(circuit):
for c_register in circuit.c_registers:
randomised_circuit.add_c_register(c_register)

seed_size = 16
seed_c_reg = BitRegister(name='seed_c', size=seed_size)
randomised_circuit.add_c_register(seed_c_reg)

if circuit.n_qubits < seed_size:
seed_q_reg = QubitRegister(
name='seed_q',
size=seed_size-sum(q_register.size for q_register in randomised_circuit.q_registers)
)
randomised_circuit.add_q_register(seed_q_reg)

all_qubits = list(itertools.chain.from_iterable([q_register.to_list() for q_register in randomised_circuit.q_registers]))
for qubit, cbit in zip(all_qubits[:seed_size], seed_c_reg.to_list()):
randomised_circuit.H(qubit)
randomised_circuit.Measure(qubit, cbit)
randomised_circuit.Reset(qubit)
randomised_circuit.add_wasm_to_reg("seed_randomisation", wfh, [seed_c_reg], [])
# seed_size = 16
# seed_c_reg = BitRegister(name='seed_c', size=seed_size)
# randomised_circuit.add_c_register(seed_c_reg)

# if circuit.n_qubits < seed_size:
# seed_q_reg = QubitRegister(
# name='seed_q',
# size=seed_size-sum(q_register.size for q_register in randomised_circuit.q_registers)
# )
# randomised_circuit.add_q_register(seed_q_reg)

# all_qubits = list(itertools.chain.from_iterable([q_register.to_list() for q_register in randomised_circuit.q_registers]))
# for qubit, cbit in zip(all_qubits[:seed_size], seed_c_reg.to_list()):
# randomised_circuit.H(qubit)
# randomised_circuit.Measure(qubit, cbit)
# randomised_circuit.Reset(qubit)
# randomised_circuit.add_wasm_to_reg("seed_randomisation", wfh, [seed_c_reg], [])

randomisation_reg = randomised_circuit.add_c_register("randomisation", 8)

for command in circuit:
rand_vals = [116, 154]

for command_count, command in enumerate(circuit):

# randomisation_reg = randomised_circuit.add_c_register(f"randomisation_{command_count}", 8)

if command.op.type == OpType.ZZMax:
randomised_circuit.add_wasm_to_reg("write_randomisation", wfh, [], [randomisation_reg])
# randomised_circuit.add_wasm_to_reg("write_randomisation", wfh, [], [randomisation_reg])
randomised_circuit.add_c_setreg(rand_vals[command_count], randomisation_reg)
randomised_circuit.Z(command.qubits[0], condition=randomisation_reg[0])
randomised_circuit.Z(command.qubits[1], condition=randomisation_reg[1])
randomised_circuit.X(command.qubits[0], condition=randomisation_reg[2])
Expand All @@ -57,5 +62,19 @@ def gen_randomised_circuit(circuit):
randomised_circuit.Z(command.qubits[1], condition=randomisation_reg[5])
randomised_circuit.X(command.qubits[0], condition=randomisation_reg[6])
randomised_circuit.X(command.qubits[1], condition=randomisation_reg[7])

# randomised_circuit.Z(command.qubits[0], condition=randomisation_reg[0])
# randomised_circuit.Z(command.qubits[0], condition=randomisation_reg[2])
# randomised_circuit.Z(command.qubits[0], condition=randomisation_reg[3])
# randomised_circuit.X(command.qubits[0], condition=randomisation_reg[2])

# randomised_circuit.Z(command.qubits[1], condition=randomisation_reg[1])
# randomised_circuit.Z(command.qubits[1], condition=randomisation_reg[2])
# randomised_circuit.Z(command.qubits[1], condition=randomisation_reg[3])
# randomised_circuit.X(command.qubits[1], condition=randomisation_reg[3])

# randomised_circuit.Phase(0.5, condition=randomisation_reg[2])
# randomised_circuit.Phase(0.5, condition=randomisation_reg[3])
# randomised_circuit.Phase(-1, condition_bits=[randomisation_reg[2], randomisation_reg[3]])

return randomised_circuit, wfh