Error when using rigetti qpu: User program used too many qubits

Hi, I am using Pennylane to connect to Rigetti device, when i connect to Ankaa-2 or Ankaa-9Q-3 device (currently online) I get the Error: User program used too many qubits: 9 used and 0 available in the largest connected component. although i just use 1 qubit on my circuit.

I already config the secret of Rigetti account at ~/.qcs

Did I misconfigure or use it incorrectly? I would greatly appreciate the team’s help. Thank you very much.

My code:

import pennylane as qml

dev_qpu = qml.device('rigetti.qpu',device='Ankaa-9Q-3')

@qml.qnode(dev_qpu)
def func(x):
    qml.RZ(x, wires=0)
    return qml.expval(qml.PauliZ(0))

func(0.4)



The error message is:

C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\Scripts\python.exe C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\main.py 
Traceback (most recent call last):
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\main.py", line 13, in <module>
    func(0.4)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\qnode.py", line 1020, in __call__
    return self._impl_call(*args, **kwargs)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\qnode.py", line 1008, in _impl_call
    res = self._execution_component(args, kwargs, override_shots=override_shots)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\qnode.py", line 957, in _execution_component
    res = qml.execute(
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\execution.py", line 771, in execute
    results = ml_boundary_execute(tapes, execute_fn, jpc, device=device)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\interfaces\autograd.py", line 147, in autograd_execute
    return _execute(parameters, tuple(tapes), execute_fn, jpc)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\autograd\tracer.py", line 48, in f_wrapped
    return f_raw(*args, **kwargs)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\interfaces\autograd.py", line 168, in _execute
    return execute_fn(tapes)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\workflow\execution.py", line 212, in inner_execute
    results = device.execute(transformed_tapes, execution_config=execution_config)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\devices\modifiers\single_tape_support.py", line 32, in execute
    results = batch_execute(self, circuits, execution_config)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\devices\legacy_facade.py", line 456, in execute
    results = _set_shots(dev, first_shot)(dev.batch_execute)(circuits, **kwargs)
  File "C:\Users\thienthang.letran\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\devices\_qubit_device.py", line 510, in batch_execute
    res = self.execute(circuit, **kwargs)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane_rigetti\qpu.py", line 201, in execute
    return super().execute(circuit, **kwargs)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane_rigetti\qc.py", line 260, in execute
    return super().execute(circuit, **kwargs)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane\devices\_qubit_device.py", line 316, in execute
    self._samples = self.generate_samples()
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane_rigetti\qpu.py", line 204, in generate_samples
    return None if self._skip_generate_samples else super().generate_samples()
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane_rigetti\qc.py", line 272, in generate_samples
    self._compiled_program = self.compile()
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pennylane_rigetti\qc.py", line 254, in compile
    return self.qc.compile(self.prog)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pyquil\api\_quantum_computer.py", line 399, in compile
    nq_program = self.compiler.quil_to_native_quil(program, protoquil=protoquil)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pyquil\api\_abstract_compiler.py", line 123, in quil_to_native_quil
    response = self._compiler_client.compile_to_native_quil(request)
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\pyquil\api\_compiler_client.py", line 188, in compile_to_native_quil
    response: rpcq.messages.NativeQuilResponse = rpcq_client.call(
  File "C:\Users\thienthang.letran\Desktop\Workspace\Test-python\pennylane-rigetti\.venv\lib\site-packages\rpcq\_client.py", line 205, in call
    raise utils.RPCError(reply.error)
rpcq._utils.RPCError: Unhandled error in host program:
User program used too many qubits: 9 used and 0 available in the largest connected component.

Process finished with exit code 1

The qml.about() output is:

Name: PennyLane
Version: 0.38.1
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: c:\users\thienthang.letran\desktop\workspace\test-python\pennylane-rigetti\.venv\lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, toml, typing-extensions
Required-by: PennyLane-Rigetti, PennyLane_Lightning

Platform info:           Windows-10-10.0.18362-SP0
Python version:          3.10.11
Numpy version:           1.26.4
Scipy version:           1.14.1
Installed devices:
- default.clifford (PennyLane-0.38.1)
- default.gaussian (PennyLane-0.38.1)
- default.mixed (PennyLane-0.38.1)
- default.qubit (PennyLane-0.38.1)
- default.qubit.autograd (PennyLane-0.38.1)
- default.qubit.jax (PennyLane-0.38.1)
- default.qubit.legacy (PennyLane-0.38.1)
- default.qubit.tf (PennyLane-0.38.1)
- default.qubit.torch (PennyLane-0.38.1)
- default.qutrit (PennyLane-0.38.1)
- default.qutrit.mixed (PennyLane-0.38.1)
- default.tensor (PennyLane-0.38.1)
- null.qubit (PennyLane-0.38.1)
- lightning.qubit (PennyLane_Lightning-0.38.0)
- rigetti.numpy_wavefunction (PennyLane-Rigetti-0.36.0.post0)
- rigetti.qpu (PennyLane-Rigetti-0.36.0.post0)
- rigetti.qvm (PennyLane-Rigetti-0.36.0.post0)
- rigetti.wavefunction (PennyLane-Rigetti-0.36.0.post0)

and I am using Forest SDK version 2.23.0 (Latest)

Hi @thienthang_citynow , welcome to the Forum!

Your code looks right so there might be an issue with the plugin or on Rigetti’s side. I’ll check with the team on this. Is this the first time you’re using the plugin or was it working before and then it suddenly stopped working?

hi @CatalinaAlbornoz
this the first time I’m using the plugin

Hi @thienthang_citynow

It looks like the plugin is using an outdated version of PyQuil at the moment. The team at Rigetti and mentioned they’re going to try to look at it this week.

Please let us know in case it’s still not working in one week and we’ll check with the team at Rigetti.

Thanks again for posting this!

1 Like