Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State preparation compilation error when optimization level is set to more than 1 #288

Open
peachnuts opened this issue Oct 3, 2024 · 0 comments

Comments

@peachnuts
Copy link
Contributor

from bqskit import MachineModel
from bqskit.qis.state.state import StateVector
from bqskit import compile

n = 2
coupling_graph = [(i, i + 1) for i in range(n - 1)]
model = MachineModel(n, coupling_graph=coupling_graph)
out_circuit = compile(StateVector([0, 1, 0, 0]), model=model, optimization_level=2)

It should get the circuit that prepares the state but I got the following error:

Traceback (most recent call last):
File "/.venv/lib/python3.10/site-packages/bqskit/compiler/compiler.py", line 439, in _send_recv
return self._recv_handle_log_error()
File "/.venv/lib/python3.10/site-packages/bqskit/compiler/compiler.py", line 467, in _recv_handle_log_error
raise RuntimeError(payload)
RuntimeError: Traceback (most recent call last):
File "/.venv/lib/python3.10/site-packages/bqskit/runtime/worker.py", line 462, in _try_step_next_ready_task
future = task.step(self._get_desired_result(task))
File "/.venv/lib/python3.10/site-packages/bqskit/runtime/task.py", line 115, in step
to_return = self.coro.send(send_val)
File "/.venv/lib/python3.10/site-packages/bqskit/runtime/task.py", line 149, in run
return await self.fnargs[0](*self.fnargs[1], **self.fnargs[2])
File "/.venv/lib/python3.10/site-packages/bqskit/compiler/task.py", line 54, in run
await self.workflow.run(self.circuit, self.data)
File "/.venv/lib/python3.10/site-packages/bqskit/compiler/workflow.py", line 75, in run
await pass_obj.run(circuit, data)
File "/.venv/lib/python3.10/site-packages/bqskit/passes/processing/scan.py", line 129, in run
working_copy.instantiate(target, **instantiate_options)
File "/.venv/lib/python3.10/site-packages/bqskit/ir/circuit.py", line 2901, in instantiate
instantiater.multi_start_instantiate_inplace(self, target, multistarts)
File "/.venv/lib/python3.10/site-packages/bqskit/ir/opt/instantiaters/minimization.py", line 110, in multi_start_instantiate_inplace
params_list = [self.instantiate(circuit, target, x0) for x0 in starts]
File "/.venv/lib/python3.10/site-packages/bqskit/ir/opt/instantiaters/minimization.py", line 110, in
params_list = [self.instantiate(circuit, target, x0) for x0 in starts]
File "/.venv/lib/python3.10/site-packages/bqskit/ir/opt/instantiaters/minimization.py", line 68, in instantiate
return self.minimizer.minimize(cost, x0)
TypeError: AttributeError: 'HilbertSchmidtCost' object has no attribute 'get_residuals'

I didn't get the error when setting the optimization level to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant