{"data":{"kind":"file","path":"README.md","version_id":"aee35ytn8mafr4a9rmxjgo1h","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":6003,"modified_at":"2026-11-27T16:57:22.658000","content_hash":"8608060ac1132f545555a6fec9ae962ba55c578d1bf549861b92d69a07f17d76"},"entries":[],"content":"# qiskit-quantumkatas\n\nA [verifiers](https://github.com/PrimeIntellect-ai/verifiers) (v1) environment for\n[Qiskit QuantumKatas](https://huggingface.co/datasets/Qiskit/Qiskit-QuantumKatas)\n([arXiv:2605.27210](https://arxiv.org/abs/2605.27210)): 350 quantum programming tasks in\n26 categories, adapted from Microsoft's [QuantumKatas](https://github.com/microsoft/QuantumKatas)\nfrom Q# to Qiskit. Each task is a function stub with a docstring. A hidden test checks the\nimplementation by classical circuit simulation (statevectors, unitaries, measurement\nstatistics).\n\n## Taskset\n\n- **Source:** `Qiskit/Qiskit-QuantumKatas` on the Hugging Face Hub, `test` split, pinned revision.\n- **Size:** 350 tasks. Categories range from basic gates and superposition to Grover,\n  Simon, Deutsch–Jozsa, QFT, error correction, key distribution and quantum games.\n- **Prompting:** zero-shot. The benchmark's `default` system prompt goes ahead of the stub.\n  Use `prompt_style = \"minimal\"` or `\"none\"` to change it.\n- **Reward:** `passed`, which is 1.0 if and only if the implementation passes the task's test.\n\n## Baselines\n\nSingle turn, no tools (`null` harness), the `default` prompt, 1 rollout per task, all 350\ntasks. Run with [configs/baseline.toml](configs/baseline.toml) on Prime Inference, graded\nin local Docker with the pre-built grader image (2026-11-27). The 95% intervals are Wilson\nintervals.\n\n| Model | Pass rate | 95% CI | Mean output tokens | Inference cost |\n|---|---|---|---|---|\n| `openai/gpt-oss-120b` | 225/350 (64.3%) | 59.1–69.1% | 969 | $0.29 |\n| `deepseek/deepseek-v4-flash` | 185/350 (52.9%) | 47.6–58.0% | 305 | $0.18 |\n| `qwen/qwen3.6-35b-a3b` | 170/350 (48.6%) | 43.4–53.8% | 1217 | $0.40 |\n\n131 tasks are solved by all three models, and 91 by none. That leaves a lot of room for RL.\n\n**Where models fail:**\n- Most failures are wrong answers: the code runs, but the test's state, unitary or\n  measurement check fails (60–97 tasks per model).\n- **Outdated or invented Qiskit APIs** are the main cause of code that doesn't even load.\n  gpt-oss-120b imports `Aer` from `qiskit` in 16 tasks; `Aer` and `execute` left the\n  top-level package in Qiskit 1.0. Models also invent names such as `TruthTable`,\n  `CuccaroAdder` or `qiskit.quantum_info.fidelity`.\n- Qwen3.6-35B-A3B also returns code that doesn't parse: syntax errors, or a function body\n  without its `def`.\n- The hardest categories across models are Teleportation, DistinguishUnitaries,\n  Measurements, RippleCarryAdder and SolveSATWithGrover. These tasks need you to encode a\n  problem or protocol, not apply a known algorithm, which matches the paper's finding.\n\n`scripts/summarize.py outputs/baseline/*/` reproduces the table, the failure types and a\nper-category breakdown from the run traces.\n\n## Isolated grader\n\nThe original benchmark harness execs the candidate and the test in one namespace and\nprocess. This environment grades with `verify.py`, which splits them:\n\n- The candidate runs in a spawned worker that never receives the test source.\n- The test runs in the trusted process against a proxy of the entry point. Arguments go\n  to the worker with cloudpickle. In-place changes to the circuit the candidate receives\n  (most tasks rely on these) are rebuilt onto the caller's `QuantumCircuit` through\n  Qiskit's public API. Returned callables (oracle-building tasks) stay in the worker and\n  are called remotely.\n- Helpers the solution defines and the test calls (for example `bob_classical`) stay\n  remote. Library names only the solution imported (for example `Pauli`) are re-imported\n  on the trusted side, and only from an allowlist of packages.\n\n`scripts/check_grader.py` checks the grader with no model in the loop:\n\n| Probe | Isolated grader | Original harness (before upstream PR #7) |\n|---|---|---|\n| Gold: canonical solutions | 350 / 350 pass | 350 / 350 pass |\n| Null: unmodified prompt stubs | 1 / 350 pass | 1 / 350 pass |\n| Patch: stub plus monkeypatched `numpy.allclose`, `Statevector.equiv`, … | 1 / 350 pass | 3 / 350 pass |\n| Forge: stub that reports \"passed\" through the grader's result channel | **0 / 350 pass** | **350 / 350 pass** |\n\nThe single null pass is `Teleportation/1.7`, whose stub ends in `return True` and already\nsatisfies its test (see the dataset's `MAINTAINERS_NOTES.md`).\n\nThe forge probe is the reason this grader exists. With RL, a policy that finds the\noriginal harness's result queue gets full reward on every task without solving any.\nThe benchmark harness now has the same fix upstream\n([issue #6](https://github.com/qiskit-community/Qiskit-QuantumKatas/issues/6),\n[PR #7](https://github.com/qiskit-community/Qiskit-QuantumKatas/pull/7)).\n\n```bash\nuv run scripts/check_grader.py path/to/qiskit_quantumkatas.jsonl [--legacy path/to/Qiskit-QuantumKatas]\n```\n\n**Remaining trust boundary.** Classes the solution defines (for example an enum the test\nindexes) are sent to the trusted side by value, so their methods run there. No task needs\nmore than plain data types. If you train against this environment, watch for solutions\nthat define classes with custom `__eq__` or `__bool__`.\n\n## Usage\n\n```bash\nuv pip install -e .\nuv run vf-validate qiskit-quantumkatas --runtime.type docker   # gold + no-op check per task\nuv run vf-run @ configs/baseline.toml -m <model>                 # single-turn baseline, local Docker\n```\n\nEach rollout otherwise installs Qiskit in a fresh sandbox, which gets slow when many\nsandboxes start at once. Build the optional grader image once and pass its tag:\n\n```bash\ndocker build -f docker/Dockerfile -t qiskit-quantumkatas-grader:0.1.1 .\nuv run vf-run @ configs/baseline.toml --env.taskset.image qiskit-quantumkatas-grader:0.1.1 -m <model>\n```\n\nModel-generated code executes inside the selected runtime. Use a Docker or Prime runtime\nfor models you don't trust.\n\n## License\n\nThe dataset is CC BY-NC-SA 4.0, because it is derived from Microsoft's QuantumKatas\n(Copyright Microsoft Corporation). This environment package uses the same license.\n","encoding":"utf-8","truncated":false,"total_bytes":6003},"status":null}