Skip to content

quantum: modernize QFT to Qiskit 2.x and re-enable its test (DRAFT) - #15119

Closed
priya-sundaram-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
priya-sundaram-dev:modernize-quantum-qft
Closed

quantum: modernize QFT to Qiskit 2.x and re-enable its test (DRAFT)#15119
priya-sundaram-dev wants to merge 1 commit into
TheAlgorithms:masterfrom
priya-sundaram-dev:modernize-quantum-qft

Conversation

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor

Follow-up to #15118 and the ask in #15081: try to get the remaining ignored tests working, starting with the quantum one.

What this does

quantum/q_fourier_transform.py imported Aer and execute from qiskit — both removed in the Qiskit 1.0 API break — so the file could never import, which is why it sat on the --ignore list and its doctest was never validated. This ports it to the current API:

  • Simulate with the pure-Python BasicSimulator (transpile() + backend.run()) instead of Aer.get_backend("qasm_simulator") + execute(). BasicSimulator ships inside qiskit core, so no compiled qiskit-aer backend is required — relevant because qiskit-aer doesn't publish Python 3.14 wheels yet (Need binary distribution on PyPI for Python 3.14 Qiskit/qiskit-aer#2378), while this repo requires Python ≥ 3.14.
  • Seed the run (seed_simulator=42) and rewrite the doctest to check the reproducible, shot-noise-independent facts (all four outcomes appear; counts sum to the shot total) rather than exact per-state counts, which random sampling can never hit — the old {'00': 2500, ...} doctest was statistically impossible and only "passed" because it was ignored.
  • Add qiskit>=2 to dependencies; drop --ignore=quantum/q_fourier_transform.py and the stale # TODO: #8818 Re-enable quantum tests comment from build.yml.

Why draft

I can't install Qiskit on Python 3.14 locally to fully verify, so I'm opening this as a draft to let CI confirm qiskit core installs and imports on the repo's interpreter (the same document-the-failures approach as #15104/#15105). If it's green, happy to mark ready. Closes the quantum half of #8818 once it lands.

The other ignored files (TensorFlow) — separate story

The remaining --ignore entries are TensorFlow-based and are hard-blocked by the Python floor, not by stale code:

File Blocker
dynamic_programming/k_means_clustering_tensorflow.py, neural_network/input_data.py, computer_vision/cnn_classification.py import tensorflow — TensorFlow's latest release tops out at Python 3.13; there are no 3.14 wheels, so adding it would break uv sync for the whole repo. k_means_clustering_tensorflow.py also still uses the TF1.x graph API (tf.placeholder, sessions).
machine_learning/lstm/lstm_prediction.py Keras-only, but Keras 3 needs a backend and the only backend that fits the Python floor would be JAX; it also trains an LSTM per run (slow/heavy for build).
web_programming/current_stock_price.py, web_programming/fetch_anime_and_play.py, scripts/validate_solutions.py live network / third-party HTML → flaky, should stay out of build.

So TF re-enablement realistically waits on TensorFlow shipping 3.14 wheels (or a JAX-backend rewrite of the Keras files). Happy to take on the JAX-backend lstm_prediction path as a separate PR if you'd like.

quantum/q_fourier_transform.py used the Aer and execute symbols that were
removed from qiskit in the 1.0 API break, so it could never run and was on
the pytest --ignore list. Port it to the current API:

- Drop 'from qiskit import Aer, execute'. Build the circuit unchanged, then
  simulate with the pure-Python BasicSimulator via transpile() + backend.run(),
  so no compiled qiskit-aer backend is needed (qiskit-aer has no Python 3.14
  wheels yet; BasicSimulator ships inside qiskit core).
- Seed the run (seed_simulator=42) and rewrite the doctest to assert the
  reproducible, shot-noise-independent facts (the four outcomes appear and the
  counts sum to the shot total) instead of exact per-state counts, which random
  sampling can never hit.
- Add 'qiskit>=2' to project dependencies and drop the quantum ignore + the
  stale '# TODO: TheAlgorithms#8818 Re-enable quantum tests' comment in build.yml.

Draft until CI confirms qiskit installs and imports on the repo's Python 3.14.
@algorithms-keeper

Copy link
Copy Markdown

Closing this pull request as invalid

@priya-sundaram-dev, this pull request is being closed as none of the checkboxes have been marked. It is important that you go through the checklist and mark the ones relevant to this pull request. Please read the Contributing guidelines.

If you're facing any problem on how to mark a checkbox, please read the following instructions:

  • Read a point one at a time and think if it is relevant to the pull request or not.
  • If it is, then mark it by putting a x between the square bracket like so: [x]

NOTE: Only [x] is supported so if you have put any other letter or symbol between the brackets, that will be marked as invalid. If that is the case then please open a new pull request with the appropriate changes.

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor Author

Re-opened as #15120 — the keeper closed this one for the draft's unchecked template, but CI already went fully green (build + build_docs pass on 3.14), so I've reopened it as a ready-for-review PR with the checklist completed. Same diff.

@cclauss

cclauss commented Aug 30, 2026

Copy link
Copy Markdown
Member

Can you please add one of those Markdown AI rules files to this repo so that you always remember that there needs to be at least one checked checkbox in the commit message of every new PR to placate the keeper.

@priya-sundaram-dev

Copy link
Copy Markdown
Contributor Author

Done — opened #15121, which adds a vendor-neutral AGENTS.md at the repo root. The headline rule is exactly the one you flagged: algorithms-keeper closes any PR whose "Describe your change" section has no checked box, so the file tells agents to tick the template before submitting. I also folded in the ruff / type-hint / doctest / naming conventions and pointed at CONTRIBUTING.md as the source of truth. Used AGENTS.md (the emerging cross-tool filename) rather than a tool-specific one so every agent picks it up.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants