Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 def zero_state(cls, nqubits):
     state = cls(nqubits)
     is_matrix = isinstance(state, MatrixState)
     state.tensor = K.initial_state(nqubits, is_matrix)
     return state