Skip to content

Minimal first version#1

Open
matulni wants to merge 17 commits into
TeamGraphix:mainfrom
matulni:minimal
Open

Minimal first version#1
matulni wants to merge 17 commits into
TeamGraphix:mainfrom
matulni:minimal

Conversation

@matulni

@matulni matulni commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This commit introduces a minimal functioning version of the graphix-mqtbench plugin, compatible with Graphix' master branch.

matulni added a commit to TeamGraphix/graphix that referenced this pull request Jul 7, 2026
This commit introduces a reverse dependency on the [`graphix-mqtbench` plugin](https://github.com/TeamGraphix/graphix-mqtbench) and lists it in the README.

Current reverse dependency points to the branch `minimal` in my fork to ensure that the CI passes, but upon merging TeamGraphix/graphix-mqtbench#1, we can edit the nox file to point to the `main` branch in the base TeamGraphix repository.

This new plugin offers an API to interface with the MQT Bench suite which is useful for benchmarking Graphix with relevant circuits (both the simulator backends and the optimization workflow). Since we still don't have a robust pipeline to benchmark execution times and the pattern optimization passes, the glue code to perform the benchmarks is presented in the plugin's README instead of being part of the plugin's codebase.
The contents of `_benchmark_names.py` depend on the exact version
of **`mqt‑bench`** that was used to generate it. When a different
version is installed, the module contains incorrect benchmark names,
causing test failures.

In the CI for Graphix (a reverse dependency), this problem manifested
because the file had been generated with `mqt-bench==2.1.0`, while
`pyproject.toml` only required `mqt‑bench>=2.1.0`. Consequently, CI
installed the newer release **2.2.2**, leading to a mismatch.

For instance, see https://github.com/TeamGraphix/graphix/actions/runs/28994040306/job/86039809250?pr=558

**Fixes introduced in this commit:**
- Pin the `mqt-bench` dependency to version **2.2.2**.
- Enable Dependabot to keep this pin up‑to‑date when necessary.
- Add a generator script that can recreate `_benchmark_names.py` for
  any future `mqt-bench` version.
- Run the generator with the new pinned version and commit the updated
  `_benchmark_names.py`.

These changes ensure that the benchmark names stay in sync with the
installed `mqt-bench` version, preventing CI failures.

@thierry-martinez thierry-martinez left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the reasons for using the src/graphix_mqtbench/ directory structure instead of the flatter layout graphix_mqtbench/ (i.e., only one level of subdirectory)? It feels a bit odd to have a dedicated src/ folder that contains just this single package. Are there plans to add other packages to the repository in the future?

Having benchmark names hard‑coded in _benchmark_names.py makes the code break every time the list of names is updated on the MQTBench side. I propose a fix that pins the MQTBench version: matulni#2

Comment thread tests/test_benchmark.py Outdated
qc_clean.remove_final_measurements()
qiskit_data = Statevector_qiskit(qc_clean).data # numpy array of complex amplitudes

qiskit_data_msb = qiskit_data.reshape((2,) * bench.nqubits).transpose(range(bench.nqubits - 1, -1, -1)).reshape(-1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
qiskit_data_msb = qiskit_data.reshape((2,) * bench.nqubits).transpose(range(bench.nqubits - 1, -1, -1)).reshape(-1)
qiskit_data_msb = qiskit_data.reshape((2,) * bench.nqubits).transpose(reverse(range(bench.nqubits))).reshape(-1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5e0f50c

@matulni

matulni commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Could you explain the reasons for using the src/graphix_mqtbench/ directory structure instead of the flatter layout graphix_mqtbench/ (i.e., only one level of subdirectory)? It feels a bit odd to have a dedicated src/ folder that contains just this single package. Are there plans to add other packages to the repository in the future?

It's the default structure when you initialize a project with uv init --lib project_name. If I flatten the layout, I get the following error when running uv run pytest tests/ from the parent directory:

Expected a Python module at: src/graphix_mqtbench/__init__.py

Here there's a related discussion: https://stackoverflow.com/questions/79794657/how-to-build-a-single-file-namespace-library-with-uv

Adding

[tool.uv.build-backend]
namespace = true

to the .toml fixes the issue, but still fails when running uv build.

I noticed that in Graphix we don't have this issue, maybe because we use the setuptools build backend ?

To answer your question, there are no plans to add additional packages to the repository. I hope that one day we can deploy some proper benchmarking of Graphix, but I expect it to be a different repo that has graphix-mqtbench as a dependency. Still, since it's uv's default, I'd say having the src layout is fine, but I can dig more into it if needed.

Having benchmark names hard‑coded in _benchmark_names.py makes the code break every time the list of names is updated on the MQTBench side. I propose a fix that pins the MQTBench version: matulni#2

Thanks a lot for this suggestion!
I merged your PR, but I'm not sure if I understand at which point are we calling _benchmark_names.py Could you please clarify ? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants