area/circuitsarea/cirqhelp wantedkind/feature-requestskill-level/expert
仓库指标
- Star
- (2,145 star)
- PR 合并指标
- (PR 指标待抓取)
描述
It would be a very useful feature to be able to reason about "Circuit structures". Supporting this feature would mean that we would roughly need to be able create an op to do the following:
my_circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1), cirq.Y(q1) ** beta)
circuit_tensor = tfq.convert_to_tensor([my_circuit])
structure_grid = tfq.circuit_structure(circuit_tensor)
print(structure_grid)
# [[...], ...] some kind of meaningful 2d description of the circuit.
# Should maybe be something like [batch_size, ragged on n_qubits, ragged on depth, n_channels]
# Maybe an additional output to track symbols as well ?
My current thinking is that we do something like this: have the following inputs:
(optional) gate_alphabet where gate_alphabet[gate] = a unique integer value
(optional) symbol_alphabet[symbol_name] = a unique integer value different from any in gate_alphabet
circuits[i] = a serialized cirq.Circuit`
symbol_names = a list of all symbols found in all the circuits in circuits
Outputs:
encoding[i][j][k] = gate_alphabet[operation from circuits[i] at moment j at qubit index k]
params[i][j][k][l] = symbol_alphabet[parameter l from operation from circuits[i] at moment j at qubit index k]
or the value of l if it isn't a symbol.
What do people think ?
Going to leave open for discussion with @vprusso and others.