Skip to content

Interface

Interface(register, embedding, circuit, vparams=None, observable=None)

Bases: AbstractInterface[Tensor, QuantumCircuit, Tensor, Tensor, list[Counter], Tensor]

A class holding register, embedding, circuit, native backends and optional observable.

Source code in qadence2_platforms/backends/pyqtorch/interface.py
def __init__(
    self,
    register: RegisterInterface,
    embedding: Embedding,
    circuit: pyq.QuantumCircuit,
    vparams: dict[str, torch.Tensor] = None,
    observable: list[InputType] | InputType | None = None,
) -> None:
    super().__init__()
    self.register = register
    self.init_state: torch.Tensor = (
        circuit.state_from_bitstring(register.init_state)
        if register.init_state is not None
        else circuit.init_state()
    ).to(dtype=torch.complex128)
    self.embedding = embedding
    self.circuit = circuit
    self.observable = observable
    self.vparams = ParameterDict(vparams)
    self._dtype = torch.float64