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

Error to_matrix not defined for this #3

Open
cbjuan opened this issue Jun 18, 2024 · 0 comments
Open

Error to_matrix not defined for this #3

cbjuan opened this issue Jun 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cbjuan
Copy link
Member

cbjuan commented Jun 18, 2024

Sometimes we get this to_matrix not defined for this error. To reproduce this we can use the following code:

from qiskit_transpiler_service.ai.synthesis import AILinearFunctionSynthesis
from qiskit_transpiler_service.ai.collection import CollectLinearFunctions
from qiskit_transpiler_service.ai.routing import AIRouting
from qiskit.transpiler import PassManager
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.circuit.library import EfficientSU2
import numpy as np

circuit = QuantumCircuit(4)
for i in range(4):
    circuit.h(i)
for i in range(3):
    circuit.rxx(np.pi/4, i, i+1)
    circuit.rzz(np.pi/3, i, i+1)
    circuit.cx(i, i+1)

runtime_service = QiskitRuntimeService()

backend_name = "ibm_sherbrooke"
backend = runtime_service.get_backend(backend_name)

# Base Qiskit lvl3 transpiler
lvl3_plus_ai = generate_preset_pass_manager(optimization_level=3, backend=backend) # Here you include your backend object (ibm_sherbrooke)

# We replace the base routing with the AI-routing
lvl3_plus_ai.layout = None
lvl3_plus_ai.routing = PassManager([
    AIRouting(backend_name=backend_name, optimization_level=3, layout_mode="optimize") # AI Routing
])

# We include synthesis as a post-routing process
lvl3_plus_ai.post_routing = PassManager([
    CollectLinearFunctions(),  # Collect linear functions
    AILinearFunctionSynthesis(backend_name=backend_name)  # Optimize linear functions
])

ai_transpiled_circ = lvl3_plus_ai.run(circuit)
@cbjuan cbjuan added the bug Something isn't working label Jun 18, 2024
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

No branches or pull requests

1 participant