Skip to content

ZNE is incompatible with AdaptVQE() #793

@MarcoBarroca

Description

@MarcoBarroca

Describe the bug
I have been trying to use AdaptVQE() with ZNE by setting the resilience_level but have been running into the following error:

2023-03-30T15:28:36.439337986Z Traceback (most recent call last):
2023-03-30T15:28:36.439366661Z   File "/provider/programruntime/program_starter_wrapper.py", line 91, in execute
2023-03-30T15:28:36.439416418Z     final_result = self.main(backend, self.messenger, **self.user_params)
2023-03-30T15:28:36.439427471Z   File "/code/program.py", line 1507, in main
2023-03-30T15:28:36.439438964Z     result = job.result()
2023-03-30T15:28:36.439450175Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/meta/job.py", line 62, in result
2023-03-30T15:28:36.439460209Z     result = self.zne_strategy.mitigate_noisy_result(result)
2023-03-30T15:28:36.439469620Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/zne_strategy.py", line 257, in mitigate_noisy_result
2023-03-30T15:28:36.439481389Z     val, meta = self.extrapolator.extrapolate_zero(data)
2023-03-30T15:28:36.439493970Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/extrapolation/extrapolator.py", line 78, in extrapolate_zero
2023-03-30T15:28:36.439532518Z     return self.infer(0, data)
2023-03-30T15:28:36.439543991Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/extrapolation/extrapolator.py", line 70, in infer
2023-03-30T15:28:36.439554151Z     model, metadata = self.fit_regression_model(data)
2023-03-30T15:28:36.439562787Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/extrapolation/extrapolator.py", line 56, in fit_regression_model
2023-03-30T15:28:36.439572911Z     data = self._validate_data(data)
2023-03-30T15:28:36.439587111Z   File "/opt/app-root/lib64/python3.9/site-packages/zne/extrapolation/extrapolator.py", line 102, in _validate_data
2023-03-30T15:28:36.439597188Z     raise TypeError(
2023-03-30T15:28:36.439637867Z TypeError: Invalid data provided, expeceted Sequence[Sequence[float, float, float]].

This seems related to the way that the results from the job are formatted as the error happens during the extrapolation procedure while it tries to read the results.

Steps to reproduce
I'll attach a python script in the next comment to reproduce the issue. Note that it requires PySCF and qiskit-nature.

The retry_primitves.py is so that it can implement a max_retries option on the estimator and was taken from #598. The problem persists even if you use the standard Runtime Estimator().

Expected behavior
Ideally, it would work like it does when you use standard VQE. You can modify the attached script to use Standard VQE and it runs without issues.

Suggested solutions
I'm unsure if the modification would need to be in AdaptVQE() or in the ZNE files. I've taken a look at the files in the zne-prototype repo hoping they would be similar but it didn't help to come up with a solution.

Additional Information

  • qiskit-ibm-runtime version: 0.9.1
  • Python version: 3.9
  • Operating system: Mac OS 12.6 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions