def zero_state(cls, circuit): state = cls(circuit) state.create_pieces() with K.device(state.device): piece = K.initial_state(nqubits=state.nlocal) state.pieces[0] = K.optimization.Variable(piece, dtype=piece.dtype) return state
def zero_state(cls, circuit): """Creates ``|00...0>`` as a distributed state.""" state = cls(circuit) state.create_pieces() with K.on_cpu(): piece = K.initial_state(nqubits=state.nlocal) state.pieces[0] = K.cpu_tensor(piece, dtype=state.dtype) return state
def zero_state(cls, nqubits): state = cls(nqubits) is_matrix = isinstance(state, MatrixState) state.tensor = K.initial_state(nqubits, is_matrix) return state