<jupyter_start><jupyter_text>Random Clifford Circuit  RandomCliffordGate `RandomClifordGate(*qubits)` represents a random Clifford gate acting on a set of qubits. There is no further parameter to specify, as it is not any particular gate, but a placeholder for a generic random Clifford gate.**Parameters**- `*qubits`: indices of the set of qubits on which the gate acts on.Example:<jupyter_code>gate = vaeqst.RandomCliffordGate(0,1)
gate<jupyter_output><empty_output><jupyter_text>`RandomCliffordGate.random_clifford_map()` evokes a random sampling of the Clifford unitary, return in the form of operator mapping table $M$ and the corresponding sign indicator $h$. Such that under the mapping, any Pauli operator $\sigma_g$  specified by the binary representation $g$ (and localized within the gate support) gets mapped to$$\sigma_g \to \prod_{i=1}^{2n} (-)^{h_i}\sigma_{M_i}^{g_i}.$$The binary representation is in the $g=(x_0,z_0,x_1,z_1,\cdots)$ basis.<jupyter_code>gate.random_clifford_map()<jupyter_output><empty_output><jupyter_text>RandomCliffordLayer `RandomCliffordLayer(*gates)` represents a layer of random Clifford gates. **Parameters:*** `*gates`: quantum gates contained in the layer.The gates in the same layer should not overlap with each other (all gates need to commute). To ensure this, we do not manually add gates to the layer, but using the higher level function `.gate()` provided by `RandomCliffordCircuit` (see discussion later).Example:<jupyter_code>layer = vaeqst.RandomCliffordLayer(vaeqst.RandomCliffordGate(0,1),vaeqst.RandomCliffordGate(3,5))
layer<jupyter_output><empty_output><jupyter_text>It hosts a list of gates:<jupyter_code>layer.gates<jupyter_output><empty_output><jupyter_text>Given the total number of qubits $N$, the layer can sample the Clifford unitary (as product of each gate) $U=\prod_{a}U_a$, and represent it as a single operator mapping (because gates do not overlap, so they maps operators in different supports independently).<jupyter_code>layer.random_clifford_map(6)<jupyter_output><empty_output><jupyter_text>RandomCliffordCircuit `RandomCliffordCircuit()` represents a quantum circuit of random Clifford gates.  Methods  Construct the  CircuitExample: create a random Clifford circuit.<jupyter_code>circ = vaeqst.RandomCliffordCircuit()<jupyter_output><empty_output><jupyter_text>Use `.gate(*qubits)` to add random Clifford gates to the circuit.<jupyter_code>circ.gate(0,1)
circ.gate(2,4)
circ.gate(1,4)
circ.gate(0,2)
circ.gate(3,5)
circ.gate(3,4)
circ<jupyter_output><empty_output><jupyter_text>Gates will automatically arranged into layers. Each new gate added to the circuit will commute through the layers if it is not blocked by the existing gates. If the number of qubits `.N` is not explicitly defined, it will be dynamically infered from the circuit width, as the largest qubit index of all gates + 1.<jupyter_code>circ.N<jupyter_output><empty_output><jupyter_text>Navigate in the Circuit `.layers_forward()` and `.layers_backward()` provides two generators to iterate over layers in forward and backward order resepctively.<jupyter_code>list(circ.layers_forward())
list(circ.layers_backward())<jupyter_output><empty_output><jupyter_text>`.first_layer` and `.last_layer` points to the first and the last layers.<jupyter_code>circ.first_layer
circ.last_layer<jupyter_output><empty_output><jupyter_text>Use `.next_layer` and `.prev_layer` to move forward and backward.<jupyter_code>circ.first_layer.next_layer, circ.last_layer.prev_layer<jupyter_output><empty_output><jupyter_text>Locate a gate in the circuit.<jupyter_code>circ.first_layer.next_layer.next_layer.gates[0]<jupyter_output><empty_output><jupyter_text>Apply Circuit to State `.forward(state)` and `.backward(state)` applies the circuit to transform the state forward / backward. * Each call will sample a new random realization of the random Clifford circuit.* The transformation will create a new state, the original state remains untouched.<jupyter_code>rho = vaeqst.StabilizerState(6, r=0)
rho
circ.forward(rho)
circ.backward(rho)<jupyter_output><empty_output><jupyter_text>POVM `.povm(nsample)` provides a generator to sample $n_\text{sample}$ from the prior POVM based on the circuit by back evolution.<jupyter_code>list(circ.povm(3))<jupyter_output><empty_output><jupyter_text>BrickWallRCC `BrickWallRCC(N, depth)` is a subclass of `RandomCliffordCircuit`. It represents the circuit with 2-qubit gates arranged following a brick wall pattern.<jupyter_code>circ = vaeqst.BrickWallRCC(16,2)
circ<jupyter_output><empty_output><jupyter_text>Create an inital state as a computational basis state.<jupyter_code>rho = vaeqst.StabilizerState(16, r=0)
rho<jupyter_output><empty_output><jupyter_text>Backward evolve the state to obtain the measurement operator.<jupyter_code>circ.backward(rho)<jupyter_output><empty_output><jupyter_text>OnSiteRCC `OnSiteRCC(N)` is a subclass of `RandomCliffordCircuit`. It represents the circuit of a single layer of on-site Clifford gates. It can be used to generate random Pauli states.<jupyter_code>circ = vaeqst.OnSiteRCC(16)
circ
rho = vaeqst.StabilizerState(16, r=0)
circ.backward(rho)<jupyter_output><empty_output><jupyter_text>GlobalRCC `GlobalRCC(N)` is a subclass of `RandomCliffordCircuit`. It represents the circuit consists of a global Clifford gate. It can be used to generate Clifford states.<jupyter_code>circ = vaeqst.GlobalRCC(16)
circ
rho = vaeqst.StabilizerState(16, r=0)
circ.backward(rho)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09496088775695834, 'fraction_numerical': 0.008550118246316173, 'mean_word_length': 7.6719242902208205, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '19', 'dir': 'jupyter-structured-clean-dedup', 'id': '1584', 'license': 'MIT', 'n_tokens_mistral': 1827, 'n_tokens_neox': 1736, 'n_words': 515, 'path': 'circuit.ipynb', 'repo_name': 'hongyehu/Sim-Clifford', 'size': '5497'}