Skip to content

Commit

Permalink
Automatic Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jesus-talavera-ibm committed Dec 4, 2024
1 parent e0abccb commit 93d29d8
Show file tree
Hide file tree
Showing 31 changed files with 100 additions and 100 deletions.
6 changes: 3 additions & 3 deletions ai-clifford-synthesis-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"import numpy as np\n",
"from qiskit import QuantumCircuit\n",
"from qiskit.quantum_info import random_clifford\n",
"\n",
"from qiskit.transpiler import PassManager\n",
"from qiskit_ibm_transpiler.ai.synthesis import AICliffordSynthesis\n",
"from qiskit_ibm_transpiler.ai.collection import CollectCliffords"
"\n",
"from qiskit_ibm_transpiler.ai.collection import CollectCliffords\n",
"from qiskit_ibm_transpiler.ai.synthesis import AICliffordSynthesis"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions ai-linear-function-synthesis-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"import numpy as np\n",
"from qiskit import QuantumCircuit\n",
"from qiskit.quantum_info import random_clifford\n",
"\n",
"from qiskit.transpiler import PassManager\n",
"from qiskit_ibm_transpiler.ai.synthesis import AILinearFunctionSynthesis\n",
"from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions"
"\n",
"from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions\n",
"from qiskit_ibm_transpiler.ai.synthesis import AILinearFunctionSynthesis"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions ai-permutation-synthesis-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"outputs": [],
"source": [
"from qiskit import QuantumCircuit\n",
"from qiskit.circuit.library import Permutation\n",
"from qiskit.transpiler import PassManager\n",
"\n",
"from qiskit_ibm_transpiler.ai.collection import CollectPermutations\n",
"from qiskit_ibm_transpiler.ai.synthesis import AIPermutationSynthesis\n",
"from qiskit.circuit.library import Permutation"
"from qiskit_ibm_transpiler.ai.synthesis import AIPermutationSynthesis"
]
},
{
Expand Down
11 changes: 8 additions & 3 deletions documentation-examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
"\n",
"circuit = EfficientSU2(101, entanglement=\"circular\", reps=1).decompose()\n",
Expand Down Expand Up @@ -44,6 +45,7 @@
],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
"\n",
"circuit = EfficientSU2(101, entanglement=\"circular\", reps=1).decompose()\n",
Expand Down Expand Up @@ -72,6 +74,7 @@
],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
"\n",
"circuit = EfficientSU2(101, entanglement=\"circular\", reps=1).decompose()\n",
Expand Down Expand Up @@ -100,6 +103,7 @@
],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
"\n",
"circuit = EfficientSU2(101, entanglement=\"circular\", reps=1).decompose()\n",
Expand All @@ -118,9 +122,10 @@
"metadata": {},
"outputs": [],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"from qiskit.transpiler import PassManager\n",
"\n",
"from qiskit_ibm_transpiler.ai.routing import AIRouting\n",
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"ai_passmanager = PassManager(\n",
" [\n",
Expand Down Expand Up @@ -149,12 +154,12 @@
}
],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"from qiskit.transpiler import PassManager\n",
"\n",
"from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions\n",
"from qiskit_ibm_transpiler.ai.routing import AIRouting\n",
"from qiskit_ibm_transpiler.ai.synthesis import AILinearFunctionSynthesis\n",
"from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions\n",
"from qiskit.circuit.library import EfficientSU2\n",
"\n",
"ai_passmanager = PassManager(\n",
" [\n",
Expand Down
4 changes: 2 additions & 2 deletions local-mode-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from qiskit import QuantumCircuit\n",
"from qiskit.quantum_info import random_clifford\n",
"from qiskit.transpiler import PassManager, generate_preset_pass_manager\n",
"import numpy as np\n",
"\n",
"from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions\n",
"from qiskit.quantum_info import random_clifford\n",
"from qiskit_ibm_transpiler.ai.synthesis import AILinearFunctionSynthesis"
]
},
Expand Down
5 changes: 3 additions & 2 deletions local-mode-routing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"metadata": {},
"outputs": [],
"source": [
"from qiskit.circuit.library import EfficientSU2\n",
"from qiskit.transpiler import PassManager\n",
"from qiskit_ibm_transpiler.ai.routing import AIRouting\n",
"from qiskit.circuit.library import EfficientSU2"
"\n",
"from qiskit_ibm_transpiler.ai.routing import AIRouting"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions qiskit_ibm_transpiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

import logging

from .ai import AIRouting
from .ai_passmanager import generate_ai_pass_manager
from .transpiler_service import TranspilerService
from .utils import create_random_linear_function, get_metrics
from .ai_passmanager import generate_ai_pass_manager

import logging

logging.basicConfig()
logging.getLogger(__name__).addHandler(logging.NullHandler())
10 changes: 5 additions & 5 deletions qiskit_ibm_transpiler/ai/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
# torch.set_num_threads(1)

import importlib
import numpy as np
import logging
from typing import List, Literal, Union

import numpy as np
from qiskit import ClassicalRegister, QuantumCircuit
from qiskit.converters import circuit_to_dag, dag_to_circuit
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.transpiler import CouplingMap, TranspilerError
from qiskit.transpiler.basepasses import TransformationPass
from qiskit.transpiler.layout import Layout
from qiskit.providers.backend import BackendV2 as Backend
from qiskit_ibm_runtime import QiskitRuntimeService

from qiskit_ibm_transpiler.wrappers import AIRoutingAPI, AILocalRouting

from typing import List, Union, Literal
from qiskit_ibm_transpiler.wrappers import AILocalRouting, AIRoutingAPI

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
10 changes: 4 additions & 6 deletions qiskit_ibm_transpiler/ai/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,30 @@
import os
from concurrent.futures import ThreadPoolExecutor, as_completed
from multiprocessing import cpu_count
from typing import Dict, Union, List
from typing import Dict, List, Union

from qiskit.circuit.exceptions import CircuitError
from qiskit.converters import circuit_to_dag
from qiskit.dagcircuit.dagcircuit import DAGCircuit
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.quantum_info import Clifford
from qiskit.transpiler import CouplingMap
from qiskit.transpiler.basepasses import TransformationPass
from qiskit.transpiler.exceptions import TranspilerError
from qiskit.providers.backend import BackendV2 as Backend
from qiskit_ibm_runtime import QiskitRuntimeService

from qiskit_ibm_transpiler.wrappers import (
AICliffordAPI,
AILinearFunctionAPI,
AIPermutationAPI,
AIPauliNetworkAPI,
AIPermutationAPI,
)

from qiskit_ibm_transpiler.wrappers.ai_local_synthesis import (
AILocalCliffordSynthesis,
AILocalLinearFunctionSynthesis,
AILocalPermutationSynthesis,
AILocalCliffordSynthesis,
)


logger = logging.getLogger(__name__)

MAX_THREADS = os.environ.get("AI_TRANSPILER_MAX_THREADS", int(cpu_count() / 2))
Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_transpiler/ai_passmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from qiskit.transpiler import CouplingMap, PassManager
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

from .ai.collection import CollectLinearFunctions
from .ai.routing import AIRouting
from .ai.synthesis import AILinearFunctionSynthesis
from .ai.collection import CollectLinearFunctions


def generate_ai_pass_manager(
Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_transpiler/transpiler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""

import logging
from typing import Dict, List, Union, Literal
from typing import Dict, List, Literal, Union

from qiskit import QuantumCircuit

Expand Down
11 changes: 5 additions & 6 deletions qiskit_ibm_transpiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@
"""

from typing import Dict, Union, List, Tuple
from enum import Enum

import numpy as np
import logging
import base64
import io
import logging
import struct
from enum import Enum
from typing import Dict, List, Tuple, Union

import numpy as np
from qiskit import QuantumCircuit, qasm2, qasm3, qpy
from qiskit.circuit import QuantumCircuit, library
from qiskit.circuit.library import LinearFunction
from qiskit.quantum_info import Clifford
from qiskit.synthesis.linear.linear_matrix_utils import random_invertible_binary_matrix
from qiskit.circuit import QuantumCircuit, library
from qiskit.transpiler.basepasses import TransformationPass

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions qiskit_ibm_transpiler/wrappers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"""

from .ai_api_routing import AIRoutingAPI
from .ai_local_routing import AILocalRouting
from .ai_api_synthesis import (
AICliffordAPI,
AILinearFunctionAPI,
AIPermutationAPI,
AIPauliNetworkAPI,
AIPermutationAPI,
)
from .ai_local_routing import AILocalRouting
from .base import BackendTaskError, QiskitTranspilerService
from .transpile import TranspileAPI, _get_circuit_from_result
8 changes: 5 additions & 3 deletions qiskit_ibm_transpiler/wrappers/ai_api_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

from typing import List, Literal, Union

from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap

from qiskit_ibm_transpiler.utils import (
deserialize_circuit_from_qpy_or_qasm,
get_circuit_from_qpy,
get_qpy_from_circuit,
serialize_circuit_to_qpy_or_qasm,
)
from .base import QiskitTranspilerService
from typing import List, Union, Literal
from qiskit.transpiler import CouplingMap

from .base import QiskitTranspilerService

# TODO: Reuse this code, it's repeated several times
OptimizationOptions = Literal["n_cnots", "n_gates", "cnot_layers", "layers", "noise"]
Expand Down
8 changes: 4 additions & 4 deletions qiskit_ibm_transpiler/wrappers/ai_api_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
# that they have been altered from the originals.

import logging
from typing import Union, List
from typing import List, Union

from qiskit import QuantumCircuit
from qiskit.circuit.library import LinearFunction
from qiskit.quantum_info import Clifford
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.quantum_info import Clifford

from .base import QiskitTranspilerService
from ..utils import (
serialize_circuits_to_qpy_or_qasm,
deserialize_circuit_from_qpy_or_qasm,
serialize_circuits_to_qpy_or_qasm,
)
from .base import QiskitTranspilerService

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
6 changes: 4 additions & 2 deletions qiskit_ibm_transpiler/wrappers/ai_local_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
# that they have been altered from the originals.

import importlib
from typing import List, Literal, Union

from qiskit import QuantumCircuit
from qiskit_ibm_transpiler.utils import get_circuit_from_qasm, input_to_qasm
from typing import List, Union, Literal
from qiskit.transpiler import CouplingMap

from qiskit_ibm_transpiler.utils import get_circuit_from_qasm, input_to_qasm

ai_local_package = "qiskit_ibm_ai_local_transpiler"
qiskit_ibm_ai_local_transpiler = (
importlib.import_module(ai_local_package)
Expand Down
7 changes: 4 additions & 3 deletions qiskit_ibm_transpiler/wrappers/ai_local_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import importlib
import logging

import networkx as nx
from networkx.exception import NetworkXError

Expand Down Expand Up @@ -70,14 +71,14 @@
"CLIFFORD_COUPLING_MAPS_BY_HASHES_DICT not found",
)

from typing import Union, List
from typing import List, Union

import numpy as np
from qiskit import QuantumCircuit
from qiskit.transpiler import CouplingMap
from qiskit.circuit.library import LinearFunction
from qiskit.quantum_info import Clifford
from qiskit.providers.backend import BackendV2 as Backend
from qiskit.quantum_info import Clifford
from qiskit.transpiler import CouplingMap

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
3 changes: 2 additions & 1 deletion qiskit_ibm_transpiler/wrappers/transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# that they have been altered from the originals.

import logging
from typing import Dict, List, Union, Literal
from typing import Dict, List, Literal, Union

import numpy as np
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit import QuantumCircuit, QuantumRegister, Qubit
from qiskit.transpiler import TranspileLayout
from qiskit.transpiler.layout import Layout

from qiskit_ibm_transpiler.utils import (
deserialize_circuit_from_qpy_or_qasm,
get_circuit_from_qpy,
Expand Down
5 changes: 3 additions & 2 deletions qiskit_transpiler_service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

import logging

from qiskit_ibm_transpiler.ai import AIRouting
from .transpiler_service import TranspilerService
from qiskit_ibm_transpiler.utils import create_random_linear_function, get_metrics

import logging
from .transpiler_service import TranspilerService

logging.basicConfig()
logging.getLogger(__name__).addHandler(logging.NullHandler())
2 changes: 1 addition & 1 deletion qiskit_transpiler_service/transpiler_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"""

import logging
from typing import Dict, List, Union, Literal
from typing import Dict, List, Literal, Union

from qiskit_ibm_transpiler import TranspilerService as NewTranspilerService

Expand Down
Loading

0 comments on commit 93d29d8

Please sign in to comment.