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

qiskit blocks_to_matrix no longer imports #111

Closed
jordandsullivan opened this issue Dec 3, 2024 · 0 comments · Fixed by #119
Closed

qiskit blocks_to_matrix no longer imports #111

jordandsullivan opened this issue Dec 3, 2024 · 0 comments · Fixed by #119
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jordandsullivan
Copy link
Collaborator

jordandsullivan commented Dec 3, 2024

Describe the bug
There is a function being imported in one of our modified Qiskit transpiler passes which has been deprecated in Qiskit 1.3:

from qiskit._accelerate.convert_2q_block_matrix import blocks_to_matrix

which is used in on line 131 in the following code snippet to convert blocks of the DAGCircuit into matrix form:

if len(block_qargs) > 2:
q = QuantumRegister(len(block_qargs))
qc = QuantumCircuit(q)
if block_cargs:
c = ClassicalRegister(len(block_cargs))
qc.add_register(c)
for nd in block:
qc.append(nd.op, [q[block_index_map[i]] for i in nd.qargs])
unitary = UnitaryGate(Operator(qc), check_input=False)
else:
try:
matrix = blocks_to_matrix(block, block_index_map)
except QiskitError:
# If building a matrix for the block fails we should not consolidate it
# because there is nothing we can do with it.
continue
unitary = UnitaryGate(matrix, check_input=False)

This blocks_to_matrix function has been deprecated in Qiskit 1.3 (although it is not listed in the Release notes since qiskit._accelerate is not a module part of the official API (it is a Rust wrapper).

We need to find a replacement for this function.

To Reproduce
Steps to reproduce the behavior:

pip install --upgrade qiskit
Installing collected packages: qiskit
  Attempting uninstall: qiskit
    Found existing installation: qiskit 1.2.4
    Uninstalling qiskit-1.2.4:
      Successfully uninstalled qiskit-1.2.4
Successfully installed qiskit-1.3.0
(bench) pytest ucc/tests/test_compile.py
ucc/transpiler_passes/__init__.py:5: in <module>
    from .consolidate_blocks import ConsolidateBlocks
ucc/transpiler_passes/consolidate_blocks.py:32: in <module>
    from qiskit._accelerate.convert_2q_block_matrix import blocks_to_matrix
E   ModuleNotFoundError: No module named 'qiskit._accelerate.convert_2q_block_matrix'; 'qiskit._accelerate' is not a package

Expected behavior
It should convert the blocks to matrix form using the appropriate API.

Additional context
Arguably should consider eliminating or replacing other references to qiskit._accelerate in UCC, given that this is intended as an internal function and likely to be a more fragile part of the API.

@jordandsullivan jordandsullivan added the bug Something isn't working label Dec 3, 2024
@jordandsullivan jordandsullivan added this to the 0.3.0 milestone Dec 3, 2024
@jordandsullivan jordandsullivan changed the title qiskit._accelerate no longer imports qiskit blocks_to_matrix no longer imports Dec 4, 2024
@Misty-W Misty-W self-assigned this Dec 4, 2024
@Misty-W Misty-W linked a pull request Dec 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants