GEMMA DEVELOPER AGENTSAVED EVIDENCE
← Dataset Exploration
ARCHIVED TRAINING / Qiskit/qiskit-terra

qiskit__qiskit-terra-5833

This is a preserved training example. Membership in the current training wave has not been verified.
Qiskit/qiskit-terra · Task 27 of 169

Problem statement

OptimizeSwapBeforeMeasure needs multiple invocations
The `OptimizeSwapBeforeMeasure` pass is supposed to commute quantum SWAP gates that immediately precede measurements, past the measurements, and instead convert them to classical swap (i.e.just retarget the measurement clbit).

However this should be generalized to work with any permutation that happens before the measurements, not just one swap layer. I made this work by invoking it many times for the example below, but really one invocation should be smart enough to remove all the swaps (that whole swap network should be modeled as a permutation).

```py
from qiskit import QuantumCircuit
from qiskit.transpiler.passes import OptimizeSwapBeforeMeasure, Depth, FixedPoint
from qiskit.transpiler import PassManager

circ = QuantumCircuit(8, 8)
circ.swap(3, 4)
circ.swap(6, 7)
circ.swap(0, 1)
circ.swap(6, 7)
circ.swap(4, 5)
circ.swap(0, 1)
circ.swap(5, 6)
circ.swap(3, 4)
circ.swap(1, 2)
circ.swap(6, 7)
circ.swap(4, 5)
circ.swap(2, 3)
circ.swap(0, 1)
circ.swap(5, 6)
circ.swap(1, 2)
circ.swap(6, 7)
circ.swap(4, 5)
circ.swap(2, 3)
circ.swap(3, 4)
circ.swap(3, 4)
circ.swap(5, 6)
circ.swap(1, 2)
circ.swap(4, 5)
circ.swap(2, 3)
circ.swap(5, 6)
circ.measure(range(8), range(8))
print(circ)

_depth_check = [Depth(), FixedPoint('depth')]
_opt = [OptimizeSwapBeforeMeasure()]
def _opt_control(property_set):
    return not property_set['depth_fixed_point']

pm = PassManager()
pm.append(_depth_check + _opt, do_while=_opt_control)  # should not need this do_while
print(pm.run(circ))
```

```
                    ┌─┐                                 
q_0: ─X──X─────X────┤M├─────────────────────────────────
      │  │     │    └╥┘         ┌─┐                     
q_1: ─X──X──X──X──X──╫─────X────┤M├─────────────────────
            │     │  ║     │    └╥┘      ┌─┐            
q_2: ───────X──X──X──╫──X──X─────╫──X────┤M├────────────
               │     ║  │        ║  │    └╥┘┌─┐         
q_3: ─X─────X──X─────╫──X──X──X──╫──X─────╫─┤M├─────────
      │     │        ║     │  │  ║        ║ └╥┘┌─┐      
q_4: ─X──X──X──X─────╫──X──X──X──╫──X─────╫──╫─┤M├──────
         │     │     ║  │        ║  │     ║  ║ └╥┘┌─┐   
q_5: ────X──X──X──X──╫──X──X─────╫──X──X──╫──╫──╫─┤M├───
            │     │  ║     │     ║     │  ║  ║  ║ └╥┘┌─┐
q_6: ─X──X──X──X──X──╫──X──X─────╫─────X──╫──╫──╫──╫─┤M├
      │  │     │     ║  │ ┌─┐    ║        ║  ║  ║  ║ └╥┘
q_7: ─X──X─────X─────╫──X─┤M├────╫────────╫──╫──╫──╫──╫─
                     ║    └╥┘    ║        ║  ║  ║  ║  ║ 
c: 8/════════════════╩═════╩═════╩════════╩══╩══╩══╩══╩═
                     0     7     1        2  3  4  5  6 
           ┌─┐               
q_0: ──────┤M├───────────────
        ┌─┐└╥┘               
q_1: ───┤M├─╫────────────────
     ┌─┐└╥┘ ║                
q_2: ┤M├─╫──╫────────────────
     └╥┘ ║  ║    ┌─┐         
q_3: ─╫──╫──╫────┤M├─────────
      ║  ║  ║    └╥┘      ┌─┐
q_4: ─╫──╫──╫─────╫───────┤M├
      ║  ║  ║ ┌─┐ ║       └╥┘
q_5: ─╫──╫──╫─┤M├─╫────────╫─
      ║  ║  ║ └╥┘ ║ ┌─┐    ║ 
q_6: ─╫──╫──╫──╫──╫─┤M├────╫─
      ║  ║  ║  ║  ║ └╥┘┌─┐ ║ 
q_7: ─╫──╫──╫──╫──╫──╫─┤M├─╫─
      ║  ║  ║  ║  ║  ║ └╥┘ ║ 
c: 8/═╩══╩══╩══╩══╩══╩══╩══╩═
      0  1  2  3  4  5  6  7 
```

Training membership

opd_e4b_cispo_v5 opd_e4b_pure_v6a opd_e4b_pure_v6b opd_e4b_pure_v7 opd_e4b_pure_v7b opd_e4b_self_audit_v4

Task issues extracted from preserved verified_rft_messages training examples. This is not a verified current RL wave manifest.

Task and snapshot provenance

Snapshot captured 2026-11-12T17:06:59.476467+00:00 · Autoresearch-Arena/gemma-4-developer-agent

{
  "datasets": [
    "opd_e4b_cispo_v5",
    "opd_e4b_pure_v6a",
    "opd_e4b_pure_v6b",
    "opd_e4b_pure_v7",
    "opd_e4b_pure_v7b",
    "opd_e4b_self_audit_v4"
  ],
  "examples": 14,
  "instance_id": "qiskit__qiskit-terra-5833",
  "problem_statement": "OptimizeSwapBeforeMeasure needs multiple invocations\nThe `OptimizeSwapBeforeMeasure` pass is supposed to commute quantum SWAP gates that immediately precede measurements, past the measurements, and instead convert them to classical swap (i.e.just retarget the measurement clbit).\r\n\r\nHowever this should be generalized to work with any permutation that happens before the measurements, not just one swap layer. I made this work by invoking it many times for the example below, but really one invocation should be smart enough to remove all the swaps (that whole swap network should be modeled as a permutation).\r\n\r\n```py\r\nfrom qiskit import QuantumCircuit\r\nfrom qiskit.transpiler.passes import OptimizeSwapBeforeMeasure, Depth, FixedPoint\r\nfrom qiskit.transpiler import PassManager\r\n\r\ncirc = QuantumCircuit(8, 8)\r\ncirc.swap(3, 4)\r\ncirc.swap(6, 7)\r\ncirc.swap(0, 1)\r\ncirc.swap(6, 7)\r\ncirc.swap(4, 5)\r\ncirc.swap(0, 1)\r\ncirc.swap(5, 6)\r\ncirc.swap(3, 4)\r\ncirc.swap(1, 2)\r\ncirc.swap(6, 7)\r\ncirc.swap(4, 5)\r\ncirc.swap(2, 3)\r\ncirc.swap(0, 1)\r\ncirc.swap(5, 6)\r\ncirc.swap(1, 2)\r\ncirc.swap(6, 7)\r\ncirc.swap(4, 5)\r\ncirc.swap(2, 3)\r\ncirc.swap(3, 4)\r\ncirc.swap(3, 4)\r\ncirc.swap(5, 6)\r\ncirc.swap(1, 2)\r\ncirc.swap(4, 5)\r\ncirc.swap(2, 3)\r\ncirc.swap(5, 6)\r\ncirc.measure(range(8), range(8))\r\nprint(circ)\r\n\r\n_depth_check = [Depth(), FixedPoint('depth')]\r\n_opt = [OptimizeSwapBeforeMeasure()]\r\ndef _opt_control(property_set):\r\n    return not property_set['depth_fixed_point']\r\n\r\npm = PassManager()\r\npm.append(_depth_check + _opt, do_while=_opt_control)  # should not need this do_while\r\nprint(pm.run(circ))\r\n```\r\n\r\n```\r\n                    ┌─┐                                 \r\nq_0: ─X──X─────X────┤M├─────────────────────────────────\r\n      │  │     │    └╥┘         ┌─┐                     \r\nq_1: ─X──X──X──X──X──╫─────X────┤M├─────────────────────\r\n            │     │  ║     │    └╥┘      ┌─┐            \r\nq_2: ───────X──X──X──╫──X──X─────╫──X────┤M├────────────\r\n               │     ║  │        ║  │    └╥┘┌─┐         \r\nq_3: ─X─────X──X─────╫──X──X──X──╫──X─────╫─┤M├─────────\r\n      │     │        ║     │  │  ║        ║ └╥┘┌─┐      \r\nq_4: ─X──X──X──X─────╫──X──X──X──╫──X─────╫──╫─┤M├──────\r\n         │     │     ║  │        ║  │     ║  ║ └╥┘┌─┐   \r\nq_5: ────X──X──X──X──╫──X──X─────╫──X──X──╫──╫──╫─┤M├───\r\n            │     │  ║     │     ║     │  ║  ║  ║ └╥┘┌─┐\r\nq_6: ─X──X──X──X──X──╫──X──X─────╫─────X──╫──╫──╫──╫─┤M├\r\n      │  │     │     ║  │ ┌─┐    ║        ║  ║  ║  ║ └╥┘\r\nq_7: ─X──X─────X─────╫──X─┤M├────╫────────╫──╫──╫──╫──╫─\r\n                     ║    └╥┘    ║        ║  ║  ║  ║  ║ \r\nc: 8/════════════════╩═════╩═════╩════════╩══╩══╩══╩══╩═\r\n                     0     7     1        2  3  4  5  6 \r\n           ┌─┐               \r\nq_0: ──────┤M├───────────────\r\n        ┌─┐└╥┘               \r\nq_1: ───┤M├─╫────────────────\r\n     ┌─┐└╥┘ ║                \r\nq_2: ┤M├─╫──╫────────────────\r\n     └╥┘ ║  ║    ┌─┐         \r\nq_3: ─╫──╫──╫────┤M├─────────\r\n      ║  ║  ║    └╥┘      ┌─┐\r\nq_4: ─╫──╫──╫─────╫───────┤M├\r\n      ║  ║  ║ ┌─┐ ║       └╥┘\r\nq_5: ─╫──╫──╫─┤M├─╫────────╫─\r\n      ║  ║  ║ └╥┘ ║ ┌─┐    ║ \r\nq_6: ─╫──╫──╫──╫──╫─┤M├────╫─\r\n      ║  ║  ║  ║  ║ └╥┘┌─┐ ║ \r\nq_7: ─╫──╫──╫──╫──╫──╫─┤M├─╫─\r\n      ║  ║  ║  ║  ║  ║ └╥┘ ║ \r\nc: 8/═╩══╩══╩══╩══╩══╩══╩══╩═\r\n      0  1  2  3  4  5  6  7 \r\n```",
  "repo": "Qiskit/qiskit-terra",
  "source": "v2/experiments/train_data/opd_e4b_cispo_v5/verified_rft_messages.jsonl",
  "source_sha256": "a43610ad0dfb6ace95375cfae09000f41afc0338cc925af870a4ade7a9b20c4c"
}
{
  "captured_at": "2026-11-12T17:06:59.476467+00:00",
  "membership": "archived training",
  "membership_evidence": "Task issues extracted from preserved verified_rft_messages training examples. This is not a verified current RL wave manifest.",
  "name": "Preserved post-training task archive",
  "source": "Autoresearch-Arena/gemma-4-developer-agent",
  "source_revision": "016496de222aaafca0d4ee4c18efc63ba616f76e",
  "sources": [
    {
      "path": "v2/experiments/train_data/opd_e4b_cispo_v5/verified_rft_messages.jsonl",
      "sha256": "a43610ad0dfb6ace95375cfae09000f41afc0338cc925af870a4ade7a9b20c4c"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_hybrid_v3/verified_rft_messages.jsonl",
      "sha256": "bd326303eb127e8e5e08f03daf97bb88d79d19709d59f3f93f348bc56686a8df"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_onpolicy_v3/verified_rft_messages.jsonl",
      "sha256": "960c680e797e823a0d3a22f4b1d5ef60a72971373d703b877340b0c9126aaf68"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_pure_v6a/verified_rft_messages.jsonl",
      "sha256": "f045b7ca5b3883a1e2eaee81e1c02a4a1b53dd7b7b36e98bacb2ba5823a15148"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_pure_v6b/verified_rft_messages.jsonl",
      "sha256": "0f62460a9706eea5e1605255896f191ab00cb5706c5f1f2e1c293e9a718218dc"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_pure_v7/verified_rft_messages.jsonl",
      "sha256": "e37f7bd675322f3f81500b73559d60d5f602ca0537bf19f5cb06332c728c7b72"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_pure_v7b/verified_rft_messages.jsonl",
      "sha256": "b864bdc8695183433eef6e31cb8d33fad44ba3aded2170c1ade4ad5b2944ce23"
    },
    {
      "path": "v2/experiments/train_data/opd_e4b_self_audit_v4/verified_rft_messages.jsonl",
      "sha256": "0026023745afb8f3dc1c176dc7f7171157b4ad5a66656b524af218e8e19ceee6"
    },
    {
      "path": "v2/experiments/train_data/rft_e4b_aligned_v2/verified_rft_messages.jsonl",
      "sha256": "92a4515fee9d152b0d4c510ee3ce4caaaffe2003ba7584469f8027f174aab18c"
    },
    {
      "path": "v2/experiments/train_data/rft_v1/verified_rft_messages.jsonl",
      "sha256": "a42453ccd7ac7680b0a03865e8e7080bc8bf74c8d9d193b440c441ed46f8512b"
    },
    {
      "path": "v2/experiments/train_data/rft_v2/verified_rft_messages.jsonl",
      "sha256": "18f4b3bd7e651f83c6acab479c9475e3fa50dc652a384f309e97146983ac85ba"
    }
  ]
}