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

🚨 update pre-commit, lockfile, and adjust for Qiskit 1.3 #341

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# whether the workflow is triggered from a PR, a push to main, or a release, respectively.
python-packaging:
name: 🐍 Packaging
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.5
with:
# Do not include local version information on pushes to main to facilitate TestPyPI uploads.
no-local-version: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }}
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
path: dist
merge-multiple: true
- name: Generate artifact attestation for sdist and wheel(s)
uses: actions/attest-build-provenance@v1.4.4
uses: actions/attest-build-provenance@v2
with:
subject-path: "dist/*"
- uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ concurrency:
jobs:
change-detection:
name: 🔍 Change
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-change-detection.yml@v1.5

cpp-tests:
name: 🇨‌ Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-tests)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-ci.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-ci.yml@v1.5

cpp-linter:
name: 🇨‌ Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-linter)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-cpp-linter.yml@v1.5

python-tests:
name: 🐍 Test
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-ci.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-ci.yml@v1.5

code-ql:
name: 📝 CodeQL
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-code-ql)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-code-ql.yml@v1.5

cd:
name: 🚀 CD
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cd)
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-python-packaging.yml@v1.5

required-checks-pass: # This job does nothing and is only used for branch protection
name: 🚦 Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-mqt-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ concurrency:
jobs:
update-mqt-core:
name: ⬆️ Update MQT Core
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.4
uses: cda-tum/mqt-workflows/.github/workflows/reusable-mqt-core-update.yml@v1.5
with:
update-to-head: ${{ github.event.inputs.update-to-head == 'true' }}
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:

# Python linting and formatting using ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.8.2
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -87,13 +87,13 @@ repos:

# Check for spelling
- repo: https://github.com/crate-ci/typos
rev: v1.28.2
rev: typos-dict-v0.11.37
hooks:
- id: typos

# Clang-format the C++ part of the code base automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.4
rev: v19.1.5
hooks:
- id: clang-format
types_or: [c++, c, cuda]
Expand Down Expand Up @@ -140,6 +140,6 @@ repos:

# Check the pyproject.toml file
- repo: https://github.com/henryiii/validate-pyproject-schema-store
rev: 2024.11.11
rev: 2024.11.25
hooks:
- id: validate-pyproject
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def _run_tests(
if shutil.which("ninja") is None:
session.install("ninja")

_extras = ["test", *extras]
extras_ = ["test", *extras]
if "--cov" in posargs:
_extras.append("coverage")
extras_.append("coverage")
posargs.append("--cov-config=pyproject.toml")

session.install(*BUILD_REQUIREMENTS, *install_args, env=env)
install_arg = f"-ve.[{','.join(_extras)}]"
install_arg = f"-ve.[{','.join(extras_)}]"
session.install("--no-build-isolation", install_arg, *install_args, env=env)
session.run("pytest", *run_args, *posargs, env=env)

Expand Down
31 changes: 17 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies = [
"numba>=0.57; python_version <= '3.11'",
"pymatching>=2.2.1",
"qsample>=0.0.2",
"urllib3>=1.26.20,<2.0", # Required by qsample
"urllib3>=1.26.20", # Required by qsample (to be removed)
"fastcore>=1.7.10" # Required by qsample (to be removed)
]
dynamic = ["version"]
Expand Down Expand Up @@ -157,14 +157,20 @@ addopts = ["-ra", "--strict-markers", "--strict-config", "--showlocals"]
log_cli_level = "INFO"
xfail_strict = true
filterwarnings = [
"error",
"ignore:.*pkg_resources.*:DeprecationWarning:",
"ignore:.*The retworkx package is deprecated*:DeprecationWarning:pymatching",
'ignore:.*qiskit.providers.provider.Provider.*:DeprecationWarning:',
'ignore::DeprecationWarning:.*(simpleeval).*',
'ignore::RuntimeWarning:.*(qsample).*',
'ignore:.*invalid escape sequence.*::.*qsample.*',
'ignore:.*invalid escape sequence.*::.*latextools.*',
"error",
"ignore:.*pkg_resources.*:DeprecationWarning:",
"ignore:.*The retworkx package is deprecated*:DeprecationWarning:pymatching",
'ignore:.*qiskit.providers.provider.Provider.*:DeprecationWarning:',
'ignore::DeprecationWarning:.*(simpleeval).*',
'ignore::RuntimeWarning:.*(qsample).*',
'ignore:.*invalid escape sequence.*::.*qsample.*',
'ignore:.*invalid escape sequence.*::.*latextools.*',
# Qiskit 1.3 deprecations
'ignore:.*``qiskit.dagcircuit.dagcircuit.DAGCircuit.*`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:',
'ignore:.*``qiskit.circuit.instruction.Instruction.condition`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:',
'ignore:.*Conditioned gates in qasm2 will be loaded as an IfElseOp starting in Qiskit 2.0.*:FutureWarning:',
'ignore:.*``qiskit.circuit.singleton.*`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:',
'ignore:.*``qiskit.circuit.instruction.Instruction.c_if.*`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:',
]

[tool.coverage]
Expand Down Expand Up @@ -243,20 +249,17 @@ extend-select = [
"SLOT", # flake8-slots
"SIM", # flake8-simplify
"T20", # flake8-print
"TCH", # flake8-type-checking
"TC", # flake8-type-checking
"TID251", # flake8-tidy-imports.banned-api
"TRY", # tryceratops
"UP", # pyupgrade
"YTT", # flake8-2020
]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"ISC001", # Conflicts with formatter
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"PLC0415", # Import should be at top of file
"PT004", # Incorrect, just usefixtures instead.
"S101", # Use of assert detected
]
isort.required-imports = ["from __future__ import annotations"]
Expand Down Expand Up @@ -304,7 +307,7 @@ archs = "auto64"
test-command = "python -c \"from mqt import qecc\""
test-skip = ["cp313*"] # skip testing on Python 3.13 until our dependencies are ready
build-frontend = "build[uv]"
free-threaded-support = true
enable = ["cpython-freethreading"]
manylinux-x86_64-image = "manylinux_2_28"
manylinux-aarch64-image = "manylinux_2_28"
manylinux-ppc64le-image = "manylinux_2_28"
Expand Down
12 changes: 6 additions & 6 deletions src/mqt/qecc/analog_information_decoding/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,19 @@ def merge_datasets(datasets: list[dict[str, Any]]) -> dict[str, Any]:
return merged_data


def _merge_datasets_x(_datasets: list[dict[str, Any]]) -> dict[str, Any]:
def _merge_datasets_x(datasets_: list[dict[str, Any]]) -> dict[str, Any]:
"""Merges a list of dictionaries into a single dictionary.

The values for the fields "nr_runs", "x_success_cnt" and "z_success_cnt" are extracted from each dictionary and added together.

Args:
datasets (List[Dict[str, Any]]): A list of dictionaries to be merged.
datasets_ (List[Dict[str, Any]]): A list of dictionaries to be merged.

Returns:
Dict[str, Any]: A dictionary containing the merged data.
"""
# remove datasets that do not contain x_success_cnt
datasets = [data for data in _datasets if "x_success_cnt" in data]
datasets = [data for data in datasets_ if "x_success_cnt" in data]

if not datasets:
return {}
Expand Down Expand Up @@ -305,19 +305,19 @@ def _merge_datasets_x(_datasets: list[dict[str, Any]]) -> dict[str, Any]:
return merged_data


def _merge_datasets_z(_datasets: list[dict[str, Any]]) -> dict[str, Any]:
def _merge_datasets_z(datasets_: list[dict[str, Any]]) -> dict[str, Any]:
"""Merges a list of dictionaries into a single dictionary. The values for the fields "nr_runs".

"x_success_cnt" and "z_success_cnt" are extracted from each dictionary and added together.

Args:
datasets (List[Dict[str, Any]]): A list of dictionaries to be merged.
datasets_ (List[Dict[str, Any]]): A list of dictionaries to be merged.

Returns:
Dict[str, Any]: A dictionary containing the merged data.
"""
# remove datasets that do not contain z_success_cnt
datasets = [data for data in _datasets if "z_success_cnt" in data]
datasets = [data for data in datasets_ if "z_success_cnt" in data]

if not datasets:
return {}
Expand Down
2 changes: 1 addition & 1 deletion src/mqt/qecc/cc_decoder/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def threshold_fit(
"""Compute standard fit function for the threshold."""
p, ell = variables
expr = (p - pth) * (ell ** (1 / mu))
return cast(float, b0 + b1 * expr + b2 * (expr**2))
return cast("float", b0 + b1 * expr + b2 * (expr**2))


def calculate_threshold(
Expand Down
6 changes: 3 additions & 3 deletions src/mqt/qecc/circuit_synthesis/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def heuristic_encoding_circuit(
Returns:
The synthesized encoding circuit and the qubits that are used to encode the logical qubits.
"""
logging.info("Starting encoding circuit synthesis.")
logger.info("Starting encoding circuit synthesis.")

checks, logicals, use_x_checks = _get_matrix_with_fewest_checks(code)
n_checks = checks.shape[0]
Expand Down Expand Up @@ -93,7 +93,7 @@ def gate_optimal_encoding_circuit(
Returns:
The synthesized encoding circuit and the qubits that are used to encode the logical qubits.
"""
logging.info("Starting optimal encoding circuit synthesis.")
logger.info("Starting optimal encoding circuit synthesis.")
checks, logicals, use_x_checks = _get_matrix_with_fewest_checks(code)
assert checks is not None
n_checks = checks.shape[0]
Expand Down Expand Up @@ -141,7 +141,7 @@ def depth_optimal_encoding_circuit(
Returns:
The synthesized encoding circuit and the qubits that are used to encode the logical qubits.
"""
logging.info("Starting optimal encoding circuit synthesis.")
logger.info("Starting optimal encoding circuit synthesis.")
checks, logicals, use_x_checks = _get_matrix_with_fewest_checks(code)
assert checks is not None
n_checks = checks.shape[0]
Expand Down
5 changes: 3 additions & 2 deletions src/mqt/qecc/circuit_synthesis/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from ..codes import CSSCode

logger = logging.getLogger(__name__)


class NoisyNDFTStatePrepSimulator:
"""Class for simulating noisy state preparation circuit using a depolarizing noise model."""
Expand Down Expand Up @@ -245,8 +247,7 @@ def logical_error_rate(
while i <= int(np.ceil(shots / batch)) or at_least_min_errors:
num_logical_errors_batch, discarded_batch = self._simulate_batch(batch)

logging.log(
logging.INFO,
logger.info(
f"Batch {i}: {num_logical_errors_batch} logical errors and {discarded_batch} discarded shots. {batch - discarded_batch} shots used.",
)
p_l_batch = num_logical_errors_batch / (batch - discarded_batch) if discarded_batch != batch else 0.0
Expand Down
Loading
Loading