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

Deprecate CutQC #527

Merged
merged 24 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
67386f1
deprecate cutqc
ibrahim-shehzad Apr 2, 2024
ce89dbe
Deprecate conversion and metrics.
ibrahim-shehzad Apr 2, 2024
6550136
Remove low coverage line from tox.ini
ibrahim-shehzad Apr 2, 2024
659cd83
Update test_cutqc.py
ibrahim-shehzad Apr 2, 2024
588aaf2
Update deprecation message
ibrahim-shehzad Apr 2, 2024
1d17be6
change package name in deprecation messages
ibrahim-shehzad Apr 2, 2024
4a388d3
snapshot
ibrahim-shehzad Apr 2, 2024
08319c3
Edit deprecation messages
ibrahim-shehzad Apr 2, 2024
659b8b4
Remove extraneous backticks
ibrahim-shehzad Apr 3, 2024
b66926a
add release note
ibrahim-shehzad Apr 3, 2024
c8b810f
Edit release note
ibrahim-shehzad Apr 3, 2024
e90fd4d
Update deprecation message in init file
ibrahim-shehzad Apr 4, 2024
2b9aff8
Move the deprecated imports inside the test functions
garrison Apr 4, 2024
66b2425
Skip the doctests in `metrics.py`
garrison Apr 4, 2024
c6bee07
Also avoid importing cutqc during test discovery
garrison Apr 4, 2024
6c57712
Remove warnings from private methods, edit release note and removal t…
ibrahim-shehzad Apr 4, 2024
601628d
Merge branch 'deprecate-cutqc' of https://github.com/Qiskit-Extension…
ibrahim-shehzad Apr 4, 2024
dc31577
Add ignore flags
ibrahim-shehzad Apr 4, 2024
1497412
Correct typo in deprecation message
ibrahim-shehzad Apr 4, 2024
fd5e44e
Edit removal timeline field
ibrahim-shehzad Apr 4, 2024
a9e1bb4
Remove trailing space
ibrahim-shehzad Apr 4, 2024
3f7142b
Double backticks
ibrahim-shehzad Apr 4, 2024
735d9f1
Add backticks around module name
ibrahim-shehzad Apr 4, 2024
2d2c553
restore notebook
ibrahim-shehzad Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions circuit_knitting/cutting/cutqc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

"""Code to initialize the cutqc imports."""

from warnings import warn

from .wire_cutting_evaluation import run_subcircuit_instances
from .wire_cutting_post_processing import generate_summation_terms, build
from .wire_cutting_verification import verify
Expand All @@ -33,3 +35,11 @@
"create_dd_bin",
"reconstruct_dd_full_distribution",
]

warn(
f"The package {__name__} is deprecated and will be removed no sooner than Circuit Knitting Toolbox 0.8.0. "
"There is a new circuit cutting implementation in circuit_knitting.cutting that implements similar and improved functionality, which will be maintained going forward."
" See https://qiskit-extensions.github.io/circuit-knitting-toolbox/circuit_cutting/tutorials/04_automatic_cut_finding.ipynb for a tutorial on automated cut-finding.",
DeprecationWarning,
stacklevel=2,
)
55 changes: 55 additions & 0 deletions circuit_knitting/cutting/cutqc/dynamic_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@
from typing import Sequence, Any
from qiskit import QuantumCircuit
from qiskit.circuit import Qubit
from qiskit.utils.deprecation import deprecate_func

from .wire_cutting_post_processing import build, find_process_jobs


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def dd_build(
summation_terms: Sequence[dict[int, int]],
subcircuit_entry_probs: dict[int, dict[int, np.ndarray]],
Expand Down Expand Up @@ -150,6 +157,12 @@ def dd_build(
return dd_bins


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _initialize_dynamic_definition_schedule(
counter: dict[int, dict[str, int]], mem_limit: int
) -> dict[str, dict[int, str]]:
Expand Down Expand Up @@ -185,6 +198,12 @@ def _initialize_dynamic_definition_schedule(
return schedule


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _next_dynamic_definition_schedule(
recursion_layer: int,
bin_id: int,
Expand Down Expand Up @@ -250,6 +269,12 @@ def _next_dynamic_definition_schedule(
return next_dd_schedule


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _distribute_load(capacities: dict[int, int], mem_limit: int) -> dict[int, int]:
"""
Determine the size to merge bit depending on memory size.
Expand Down Expand Up @@ -277,6 +302,12 @@ def _distribute_load(capacities: dict[int, int], mem_limit: int) -> dict[int, in
return loads


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _merge_prob_vector(
unmerged_prob_vector: np.ndarray, qubit_states: str
) -> np.ndarray:
Expand Down Expand Up @@ -317,6 +348,12 @@ def _merge_prob_vector(
return merged_prob_vector


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _merge_state_into_bins_parallel(
subcircuit_instances: dict[int, dict[tuple[tuple[str, ...], tuple[Any, ...]], int]],
subcircuit_entry_probs: dict[int, dict[int, np.ndarray]],
Expand Down Expand Up @@ -359,6 +396,12 @@ def _merge_state_into_bins_parallel(
return merged_subcircuit_entry_probs


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def _merge_states_into_bins(
subcircuit_instances: dict[int, dict[tuple[tuple[str, ...], tuple[Any, ...]], int]],
subcircuit_entry_probs: dict[int, dict[int, np.ndarray]],
Expand Down Expand Up @@ -414,6 +457,12 @@ def _merge_states_into_bins(
return merged_subcircuit_entry_probs


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def read_dd_bins(
subcircuit_out_qubits: dict[int, list[int]], dd_bins: dict[int, dict[str, Any]]
) -> np.ndarray:
Expand Down Expand Up @@ -483,6 +532,12 @@ def read_dd_bins(
return reconstructed_prob


@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
garrison marked this conversation as resolved.
Show resolved Hide resolved
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def get_reconstruction_qubit_order(
full_circuit: QuantumCircuit,
complete_path_map: dict[Qubit, list[dict[str, int | Qubit]]],
Expand Down
10 changes: 9 additions & 1 deletion circuit_knitting/cutting/cutqc/mip_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import numpy as np

from qiskit.utils.deprecation import deprecate_func


class MIPModel(object):
"""
Expand All @@ -30,6 +32,12 @@ class MIPModel(object):
can find the optimal wire cuts in the circuit.
"""

@deprecate_func(
removal_timeline="Circuit knitting toolbox 0.8.0 release",
since="0.7.0",
package_name="circuit-knitting-toolbox",
additional_msg="Use the wire cutting or automated cut-finding functionality in the circuit_knitting.cutting package. ",
)
def __init__(
self,
n_vertices: int,
Expand Down Expand Up @@ -95,7 +103,7 @@ def __init__(
from docplex.mp.model import Model
except ModuleNotFoundError as ex: # pragma: no cover
raise ModuleNotFoundError(
"DOcplex is not installed. For automatic cut finding to work, both "
"DOcplex is not installed. For automatic cut-finding to work, both "
"DOcplex and cplex must be available."
) from ex

Expand Down
Loading