SimulaQron.virtNode package

Submodules

SimulaQron.virtNode.basics module

class SimulaQron.virtNode.basics.quantumEngine(maxQubits=10)[source]

Bases: twisted.spread.flavors.Referenceable

Basic quantum engine. This by itself does nothing.

Attributes:
maxQubits: maximum number of qubits this engine will support.
exception SimulaQron.virtNode.basics.quantumError(value)[source]

Bases: Exception

SimulaQron.virtNode.crudeSimulator module

class SimulaQron.virtNode.crudeSimulator.quantumRegister(node, num, maxQubits=10)[source]

Bases: SimulaQron.virtNode.crudeSimulator.simpleEngine

A simulated quantum register. The qubits who are simulated in this register may be distributed over different quantum nodes.

class SimulaQron.virtNode.crudeSimulator.simpleEngine(maxQubits=10)[source]

Bases: SimulaQron.virtNode.basics.quantumEngine

Basic quantum engine which uses QuTip. Works with density matrices and in principle allows full quantum dynamics via QuTip. Subsequently, this is quite slow.

Attributes:
maxQubits: maximum number of qubits this engine will support.
absorb(other)[source]

Absorb the qubits from the other engine into this one. This is done by tensoring the state at the end.

absorb_parts(R, I, activeQ)[source]

Absorb the qubits, given in pieces

Arguments: R real part of the qubit state as a list I imaginary part as a list activeQ active number of qubits

add_fresh_qubit()[source]

Add a new qubit initialized in the |0> state

add_qubit(newQubit)[source]

Add new qubit in the state described by the density matrix newQubit

apply_CNOT(qubitNum1, qubitNum2)[source]

Applies the CNOT to the qubit with the numbers qubitNum1 and qubitNum2.

apply_CPHASE(qubitNum1, qubitNum2)[source]

Applies the CPHASE to the qubit with the numbers qubitNum1 and qubitNum2.

apply_H(qubitNum)[source]

Applies a Hadamard gate to the qubits with number qubitNum.

apply_K(qubitNum)[source]

Applies a K gate to the qubits with number qubitNum. Maps computational basis to Y eigenbasis.

apply_T(qubitNum)[source]

Applies a T gate to the qubits with number qubitNum.

apply_X(qubitNum)[source]

Applies a X gate to the qubits with number qubitNum.

apply_Y(qubitNum)[source]

Applies a Y gate to the qubits with number qubitNum.

apply_Z(qubitNum)[source]

Applies a Z gate to the qubits with number qubitNum.

apply_onequbit_gate(gateU, qubitNum)[source]

Applies a unitary gate to the specified qubit.

Arguments: gateU unitary to apply as Qobj qubitNum the number of the qubit this gate is applied to

apply_rotation(qubitNum, n, a)[source]

Applies a rotation around the axis n with the angle a to qubit with number qubitNum. If n is zero a ValueError is raised Arguments: qubitNum Qubit number n A tuple of three numbers specifying the rotation axis, e.g n=(1,0,0) a The rotation angle in radians.

apply_twoqubit_gate(gateU, qubit1, qubit2)[source]

Applies a unitary gate to the two specified qubits.

Arguments: gateU unitary to apply as Qobj qubit1 the first qubit qubit2 the second qubit

get_qubits(list)[source]

Returns the qubits with numbers in list.

get_qubits_RI(qList)[source]

Retrieves the qubits in the list and returns the result as a list divided into a real and imaginary part. Twisted only likes to send real values lists, not complex ones.

Arguments qList list of qubits to retrieve, e.g. [1, 4]

get_register_RI()[source]

Retrieves the entire register in real and imaginary parts and returns the result as a list. Twisted only likes to send real valued lists, not complex ones.

measure_qubit(qubitNum)[source]

Measures the desired qubit in the standard basis. This returns the classical outcome and deletes the qubit.

Arguments: qubitNum qubit to be measured

measure_qubit_inplace(qubitNum)[source]

Measures the desired qubit in the standard basis. This returns the classical outcome. The quantum register is in the post-measurment state corresponding to the obtained outcome.

Arguments: qubitNum qubit to be measured

remove_qubit(qubitNum)[source]

Removes the qubit with the desired number qubitNum

replace_qubit(qubitNum, state)[source]

Replaces the qubit at position qubitNum with the one given by state.

reset()[source]

Resets this register to 0 qubits.

SimulaQron.virtNode.quantum module

class SimulaQron.virtNode.quantum.simulatedQubit(node, register, simNum, num=0)[source]

Bases: twisted.spread.flavors.Referenceable

Simulated qubit object in the specified local simulation engine.

  • Arguments
    node:network node that this qubit lives at
    register:register on that node that the qubit is in

Note

Qubit objects are local to each node that is simulating a particular quantum register. A qubit object provides the backing for a virtual qubit, which may be at another node.

isLocked()[source]
lock()[source]
make_fresh()[source]

Make this a fresh qubit.

remote_apply_H()[source]

Apply H gate.

remote_apply_K()[source]

Apply K gate to itself by passing it onto the underlying register. Maps computational to Y eigenbasis.

remote_apply_T()[source]

Apply T gate.

remote_apply_X()[source]

Apply X gate to itself by passing it onto the underlying register.

remote_apply_Y()[source]

Apply Y gate.

remote_apply_Z()[source]

Apply Z gate.

remote_apply_rotation(*args)[source]

Apply rotation around axis n with angle a. Arguments: n A tuple of three numbers specifying the rotation axis, e.g n=(1,0,0) a The rotation angle in radians.

remote_cnot_onto(targetNum)[source]

Performs a CNOT operation with this qubit as control, and the other qubit as target.

Arguments targetNum the qubit to use as the target of the CNOT

remote_cphase_onto(targetNum)[source]

Performs a CPHASE operation with this qubit as control, and the other qubit as target.

Arguments targetNum the qubit to use as the target of the CPHASE

remote_get_details()[source]

Returns out simulation number as well as the details of this simulating node.

remote_get_number()[source]

Returns the local number of this qubit.

remote_get_numbers()[source]

Returns the number of the simulating register.

remote_get_qubit()[source]

Returns the state of the qubits in the list qList by tracing out the rest.

remote_get_register()[source]

Returns the register where this qubit is simulated.

remote_get_sim_number()[source]

Returns the simulation number of this qubit.

remote_isActive()[source]
remote_lock()[source]
remote_measure()[source]

Measure the qubit in the standard basis. This does delete the qubit.

Returns the measurement outcome.

remote_measure_inplace()[source]

Measure the qubit in the standard basis. This does NOT delete the qubit, but replace the relevant qubit with the measurement outcome.

Returns the measurement outcome.

remote_unlock()[source]
unlock()[source]

SimulaQron.virtNode.virtual module

class SimulaQron.virtNode.virtual.QubitCQC(fromName, toName, from_app_id, to_app_id, new_virt_num, rawEntInfo=None)[source]

Bases: object

class SimulaQron.virtNode.virtual.backEnd(name, configName)[source]

Bases: object

start(maxQubits=10)[source]

Start listening to requests from other nodes.

Arguments maxQubits maximum qubits in the default register

class SimulaQron.virtNode.virtual.virtualNode(ID, config, maxQubits=10, maxRegisters=1000)[source]

Bases: twisted.spread.flavors.Root

connectNet()[source]

Initialize the connections to the other virtual nodes in the network according to the available configuration.

get_sim_id()[source]

Similarly, this is a crude and horrible cludge to generate unique IDs for simulated qubits.

get_virtual_id()[source]

This is a crude and horrible cludge to generate unique IDs for virtual qubits.

local_merge_regs(qubit1, qubit2)[source]

Merges the two local quantum registers. Note that these register may simulate virtual qubits across different network nodes. This will ignore maxQubits and simply create one large register allowing twice maxQubits qubits.

Arguments qubit1 qubit1 in reg1, called from remote having access to only qubits qubit2 qubit2 in reg2

remote_add_qubit(name, simQubit)[source]

Add a qubit to the local virtual node.

Arguments name name of the node simulating this qubit simQubit simulated qubit reference in the backend we’re adding

remote_cqc_add_epr_list(fromName, from_app_id, to_app_id, new_virt_num, rawEntInfo)[source]

Add an item to the epr list for use in CQC.

remote_cqc_add_recv_list(fromName, from_app_id, to_app_id, new_virt_num)[source]

Add an item to the received list for use in CQC.

remote_cqc_get_epr_recv(to_app_id)[source]

Retrieve the next qubit (half of an EPR-pair) with the given app ID from the received list.

remote_cqc_get_recv(to_app_id)[source]

Retrieve the next qubit with the given app ID form the received list.

remote_cqc_send_epr_half(num, targetName, app_id, remote_app_id, rawEntInfo)[source]

Send interface for CQC to add the qubit to the remote nodes received list for an application.

Arguments: num number of virtual qubit to send targetName name of the node to send to app_id application asking to have this qubit delivered remote_app_id application ID to deliver the qubit to entInfo entanglement information

remote_cqc_send_qubit(num, targetName, app_id, remote_app_id)[source]

Send interface for CQC to add the qubit to the remote nodes received list for an application.

Arguments: num number of virtual qubit to send targetName name of the node to send to app_id application asking to have this qubit delivered remote_app_id application ID to deliver the qubit to

remote_get_global_lock()[source]
remote_get_multiple_qubits(qList)[source]

Return the state of multiple qubits virtually located at this node. This will fail if the qubits are not in the same register or thus also simulating node.

Arguments qList list of virtual qubits of which to retrieve the state

remote_get_register(qubit)[source]

Return the value of of a locally simulated register which contains this virtual qubit.

remote_get_register_del(qubitNum)[source]

Return the value of of a locally simulated register, and remove the simulated qubits from this node.

Caution: virtual qubits not updated.

remote_get_state(simNumList)[source]

Return the state of multiple qubits corresponding to the IDs in simNumList.

remote_get_virtual_ref(num)[source]

Return a virual qubit object for the given number.

Arguments num number of the virtual qubit

remote_lock_reg_qubits(qubitNum)[source]

Acquire the lock on all qubits in the same register as qubitNum.

remote_merge_from(simNodeName, simQubitNum, localReg)[source]

Bring a remote register to this node.

Arguments simNodeName name of the node who simulates right now simQubitNum simulation number of qubit whose register we will merge localReg local register to merge with

remote_merge_regs(num1, num2)[source]

Merges the two local quantum registers. Note that these register may simulate virtual qubits across different network nodes. This will ignore maxQubits and simply create one large register allowing twice maxQubits qubits.

Arguments num1 number of the first qubit num2 number of the second qubit

remote_new_qubit()[source]

Create a new qubit in the default local register.

remote_new_qubit_inreg(reg)[source]

Create a new qubit in the specified register reg.

remote_new_register(maxQubits=10)[source]

Initialize a local register. Right now, this simple creates a register according to the simple engine backend using qubit.

Arguments: maxQubits maximum number of qubits to use in the default engine (default 10)

remote_release_global_lock()[source]
remote_remove_sim_qubit_num(delNum)[source]

Removes the simulated qubit delQubit from the node and also from the underlying engine. Relies on this qubit having been locked.

Arguments delNum simID of the simulated qubit to delete

remote_reset_reg(reg)[source]

Reset the simulated register, including removing all simulated qubits. Caution: this does not update remote nodes XXX

remote_send_qubit(qubit, targetName)[source]

Sends the qubit to the specified target node. This creates a new virtual qubit object at the remote node with the right qubit and backend details.

Arguments qubit virtual qubit to be sent targetName target ndoe to place qubit at (host object)

remote_test()[source]
remote_test_arg(newSimNodeName, oldSimNodeName, oldRegNum, newD)[source]
remote_transfer_qubit(simQubitNum, targetName)[source]

Transfer the qubit to the destination node if we are the simulating node. The reason why we cannot do this directly is that Twisted PB does not allow objects to be passed between connecting nodes. Only between the creator of the object and its immediate connections.

Arguments simQubitNum simulated qubit number to be sent targetName target node to place qubit at (host object)

remote_unlock_reg_qubits(qubitNum)[source]

Release the lock on all qubits in the same register as qubitNum.

remote_update_virtual_merge(newSimNodeName, oldSimNodeName, oldRegNum, newD)[source]

Update the virtual qubits to the new simulating node, if applicable. This is extremely inefficient due to not keeping register information in virtualQubit.

Arguments newSimNodeName new node simulating this qubit oldSimNodeName old node simulating the qubit oldReg old register newD dictionary mapping qubit numbers to qubit objects at the new simulating node

class SimulaQron.virtNode.virtual.virtualQubit(virtNode, simNode, simQubit, num)[source]

Bases: twisted.spread.flavors.Referenceable

remote_apply_H()[source]

Apply H gate.

remote_apply_K()[source]

Apply K gate - taking computational basis to Y eigenbasis.

remote_apply_T()[source]

Apply T gate.

remote_apply_X()[source]

Apply X gate to itself by passing it onto the underlying register.

remote_apply_Y()[source]

Apply Y gate.

remote_apply_Z()[source]

Apply Z gate.

remote_apply_rotation(n, a)[source]

Apply rotation around axis n with angle a. Arguments: n A tuple of three numbers specifying the rotation axis, e.g n=(1,0,0) a The rotation angle in radians.

remote_cnot_onto(target)[source]

Performs a CNOT operation with this qubit as control, and the other qubit as target.

Arguments target the virtual qubit to use as the target of the CNOT

remote_cphase_onto(target)[source]

Performs a CPHASE operation with this qubit as control, and the other qubit as target.

Arguments target the virtual qubit to use as the target of the CPHASE

remote_get_number()[source]

Returns the number of this qubit in whatever local register it is in. Not useful for the client, but convenient for debugging.

remote_get_qubit()[source]

Returns the state of this qubit in real and imaginary parts separated. This is required single Twisted cannot natively transfer complex valued objects.

remote_get_virt_num()[source]

Returns the number of the virtual qubit.

remote_measure(inplace=False)[source]

Measure the qubit in the standard basis. If inplace=False, this does delete the qubit from the simulation.

Returns the measurement outcome.

remote_test()[source]

Module contents