PennyLaneAI / pennylane-sf

The PennyLane-SF plugin integrates Xanadu's Strawberry Fields photonic quantum simulators and hardware with PennyLane's quantum machine learning capabilities.
https://docs.pennylane.ai/projects/strawberryfields
Apache License 2.0
38 stars 19 forks source link

Error trying to acess ‘simulon_gausian’ in pennylane #113

Open HeyPhiS opened 2 years ago

HeyPhiS commented 2 years ago

Issue description

I am trying to run a circuit on Xanadu’s " simulon_gaussian" backend via the PennyLane-Strawberry Fields Plugin. Unfortunately, when trying to initialise the device with

  import pennylane as qml

  dev = qml.device('strawberryfields.remote', backend='simulon_gaussian', wires=['0','1','2'], cutoff_dim=10)

I receive in return the error message ValueError: Device has a fixed number of {'pnr_max': 20, 'homodyne_max': 1000, 'heterodyne_max': 1000} modes and cannot be created with 3 wires.

When I leave out the wires keyword argument I instead receive the error message TypeError: ‘dict’ object cannot be interpreted as an integer.

System information

Source code and tracebacks

When I look at the source code


    self.backend = backend
    self.cutoff = cutoff_dim
    eng = sf.RemoteEngine(self.backend)

    self.num_wires = eng.device.modes

    if wires is None:
        # infer the number of modes from the device specs
        # and use consecutive integer wire labels
        wires = range(self.num_wires)

    if isinstance(wires, int):
        raise ValueError(
            f"Device has a fixed number of {self.num_wires} modes. The wires argument can "
            f"only be used to specify an iterable of wire labels."
        )

    if self.num_wires != len(wires):
        raise ValueError(
            f"Device has a fixed number of {self.num_wires} modes and "
            f"cannot be created with {len(wires)} wires."
        )

the problem seems to me that sf.RemoteEngine( 'simulon_gaussian').device.modes returns the dictionary {'pnr_max': 20, 'homodyne_max': 1000, 'heterodyne_max': 1000} while pennylane expects an integer.

To me, this looks very much like a bug. However, I don't know if the problem is on the side of PennyLane or Strafberryfields.

CatalinaAlbornoz commented 2 years ago

Linking the forum post where this issue was first reported.