tlquantum.tt_circuit.TTCircuit

class tlquantum.tt_circuit.TTCircuit(unitaries, ncontraq, ncontral, equations=None, contractions=None, max_partial_trace_size=4, device='cpu')[source]

A simulator for variational quantum circuits using tensor ring tensors with PyTorch Autograd support. Can be used to compute: 1) the expectation value of an operator, 2) the single-qubit measurements of circuit’s qubits; specifically for Multi-Basis Encoding [1], and 3) the partial trace of the circuit - all with Autograd support. [1] T. L. Patti, J. Kossaifi, A. Anandkumar, and S. F. Yelin, “Variational Quantum Optimization with Multi-Basis Encodings,” (2021), arXiv:2106.13304.

Parameters:
unitarieslist of TT Unitaries, circuit operations
ncontraqint, number of qubits to do pre-contraction over

(simplifying contraciton path/using fewer indices)

ncontralint, number of unitaries to do pre-contraction over

(simplifying contraciton path/using fewer indices)

equationsdictionary, accepts pre-computed/recycled equations for

operator expectation values, single-qubit measurements, and partial traces.

contractionsdictionary, accepts pre-computed/recycled paths for

operator expectation values, single-qubit measurements, and partial traces.

max_partial_trace_sizeint, the maximum number of cores to keep in

a single partial trace for single-qubit measurements.

devicestring, device on which to run the computation.
Returns:
TTCircuit

Methods

forward_expectation_value(state, operator[, ...])

Full expectation value of self.measurement of the unitary evolved state.

forward_partial_trace(state, kept_inds)

Partial trace for specified qubits in the output state of TTCircuit.

forward_single_qubit(state, op1, op2)

Expectation values of op for each qubit of state.

state_inner_product(state, compare_state)

Inner product of input state evolved in unitary with a comparison state.

to_ket(state)

State vector output of the quantum circuit.

to_operator()

Matrix/operator representation of the quantum circuit

forward_expectation_value(state, operator, precontract_operator=True)[source]

Full expectation value of self.measurement of the unitary evolved state.

Parameters:
statett-tensor, input state to be evolved by unitary
operator: tt-tensor, operator of which to get expectation value
precontract_operator: bool, if true, the operator must be precontracted before main contraction pass
Returns:
float, expectation value of self.measurement with unitary evolved state
forward_single_qubit(state, op1, op2)[source]

Expectation values of op for each qubit of state. Takes partial trace of subset of qubits and then takes single-operator measurements of these qubits. Specifically useful for Multi-Basis Encoding [1] (MBE). [1] T. L. Patti, J. Kossaifi, A. Anandkumar, and S. F. Yelin, “Variational Quantum Optimization with Multi-Basis Encodings,” (2021), arXiv:2106.13304.

Parameters:
statett-tensor, input state to be evolved by unitary
op1tt-tensor, first single-measurement operator
op2tt-tensor, second single-measurement operator
Returns:
float, expectation value of self.measurement with unitary evolved state
forward_partial_trace(state, kept_inds)[source]

Partial trace for specified qubits in the output state of TTCircuit.

Parameters:
statett-tensor, input state to be evolved by unitary
kept_indslist of ints, indices of the qubits to be kept in the partial trace
Returns:
tensor in matrix form, partial trace of the circuit’s output state
state_inner_product(state, compare_state)[source]

Inner product of input state evolved in unitary with a comparison state.

Parameters:
statett-tensor, input state to be evolved by unitary
compare_statett-tensor, input state to be compared with evolved state
Returns:
float, inner product of evolved state with compared state
to_ket(state)[source]

State vector output of the quantum circuit.

Parameters:
statett-tensor, input state to be evolved by unitary
Returns:
vector of floats, ket state vector output from quantum circuit
to_operator()[source]

Matrix/operator representation of the quantum circuit

Returns:
matrix of floats, quantum operator resulting from the circuit