The question
Can a small QAOA circuit favor the schedule that satisfies the most illustrative requests?
Circuit & method
Fix Electronics in the first slot, leaving four binary choices and 16 schedules. Use two QAOA layers on Marrakesh. Exhaustive enumeration identifies a unique score-19 optimum out of 24 weighted requests.
Results
Hardware sampled the optimal schedule on 199/256 shots (77.7%); the ideal sampled run returned 228/256 (89.1%). Mean hardware score was 17.47/24.
What this supports
Percentages are rounded for reading. The original integer counts, physical layouts, settings and available uncertainty calculations remain in the records below. Sampling intervals do not account for drift or every systematic error.
Full experiment record
Every top-level field from the primary hardware JSON is reproduced below, including the complete saved measurement distributions where present. Field names and outcome strings retain their original order and spelling.
- Workshop-schedule-hardware.jsonQuantum Field Report.pdf / Experiment-results.zip · 2,238 bytes
stage
done
job_tag
workshop-schedule-qaoa-first-20261119
backend
ibm_marrakesh
queue_snapshot_utc
2026-11-20T02:31:38.743323+00:00
queues
{
"ibm_fez": {
"backend_name": "ibm_fez",
"backend_version": "",
"operational": true,
"pending_jobs": 2,
"status_msg": "active"
},
"ibm_kingston": {
"backend_name": "ibm_kingston",
"backend_version": "",
"operational": true,
"pending_jobs": 1,
"status_msg": "active"
},
"ibm_marrakesh": {
"backend_name": "ibm_marrakesh",
"backend_version": "",
"operational": true,
"pending_jobs": 0,
"status_msg": "active"
}
}qubits_by_classical_bit
{
"0": 52,
"1": 53,
"2": 54,
"3": 55
}gates
{
"rz": 39,
"sx": 36,
"cz": 12,
"measure": 4,
"x": 3,
"barrier": 1
}shots
256
angles
[ 1.3411628499099122, -1.5471965319316754, 1.80338546388486, -0.7870628982360862 ]
qiskit_ibm_runtime
0.52.1
job_id
dbvr22ts2omc7388ba0g
ibm_status
DONE
last_status_change_utc
2026-11-20T02:31:51.828583+00:00
counts
{
"1010": 199,
"1110": 22,
"0010": 7,
"1011": 11,
"0000": 3,
"1000": 8,
"1100": 2,
"0011": 1,
"0111": 1,
"1001": 1,
"1111": 1
}optimal_shots
199
mean_attendance
17.47265625
metrics
{
"caller": "qiskit",
"qiskit_version": "qiskit_ibm_runtime-0.52.1,qiskit-2.6.2*,qiskit_aer-0.17.2",
"timestamps": {
"created": "2026-11-20T02:31:39.292347Z",
"finished": "2026-11-20T02:31:44.954419Z",
"running": "2026-11-20T02:31:40.792044Z"
},
"usage": {
"qpu_charge_time_seconds": 2,
"value": 0.029494,
"unit": "resource_units",
"status": "complete",
"details": [
{
"value": 0.029494,
"unit": "resource_units",
"metric": {
"id": "caffe3ca-729c-5750-8777-df63bbf8bfd9",
"value": 2
}
}
]
},
"circuits_execution_time_ns": 67590400
}Simulation & checks
These are the supplied simulator records and their preserved variants. Their model, seed, settings and results appear exactly as saved. Shared simulator references on fresh-map pages describe the ideal graph protocol, rather than a new hardware-matched calibration.
- Workshop-schedule-simulator.jsonQuantum Field Report.pdf / Experiment-results.zip · 1,776 bytes
field-report/outputs/Workshop-schedule-simulator.json · full record
{
"counts": {
"1010": 228,
"1110": 19,
"0010": 2,
"1011": 2,
"1100": 1,
"1000": 4
},
"optimal_shots": 228,
"shots": 256,
"mean_attendance": 18.26953125,
"workshops": [
"Electronics",
"Radio",
"Robotics",
"Python",
"3D printing"
],
"illustrative_request_counts": [
[
0,
1,
3
],
[
0,
2,
4
],
[
0,
3,
2
],
[
0,
4,
3
],
[
1,
2,
4
],
[
2,
3,
3
],
[
3,
4,
5
]
],
"fixed_first_slot": "Electronics",
"bit_order": "Printed from left: 3D printing, Python, Robotics, Radio; 0=first slot",
"seed": 1941,
"versions": {
"qiskit": "2.6.2",
"numpy": "2.2.6",
"scipy": "1.15.3"
},
"scores": [
0,
7,
11,
10,
10,
17,
15,
14,
8,
15,
19,
18,
8,
15,
13,
12
],
"best": 19,
"total_people": 24,
"angles": [
1.3411628499099122,
-1.5471965319316754,
1.80338546388486,
-0.7870628982360862
],
"exact_probabilities": [
0.00013693735484442626,
9.559238301842365e-07,
0.007199029735285274,
5.533163076902071e-05,
2.2539935622300253e-05,
2.7688956811161627e-06,
0.0009409388684396568,
9.366986246649071e-06,
0.01639506881909755,
6.04170261334143e-05,
0.8676375954619173,
0.006388007155409842,
0.0011859126101266436,
0.00013828133671691276,
0.09894176044715759,
0.0008850878127220846
],
"ideal_mean": 18.134857735295558,
"ideal_optimal_probability": 0.8676375954619173
}Source code
Original experiment and verification programs are preserved byte for byte. These are historical listings; dependencies, authentication prompts and machine-specific input paths may need adjustment before a rerun.
- workshop_schedule.pyQuantum Field Report.pdf / Experiment-source.zip · 8,351 bytes
field-report/outputs/workshop_schedule.py · complete source
"""Two-slot workshop scheduling with four-qubit, two-layer weighted MaxCut QAOA."""
import getpass
import json
import logging
import sys
import time
from datetime import datetime, timezone
from importlib.metadata import version
from pathlib import Path
import numpy as np
from scipy.optimize import minimize
from qiskit import QuantumCircuit
from qiskit.primitives import StatevectorSampler
from qiskit.quantum_info import Statevector
from qiskit.transpiler import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService, SamplerV2
ROOT = Path(__file__).resolve().parent
LOCAL = ROOT / "Workshop-schedule-simulator.json"
RESULT = ROOT / "Workshop-schedule-hardware.json"
TAG = "workshop-schedule-qaoa-first-20261119"
SHOTS = 256
SEED = 1941
NAMES = ["Electronics", "Radio", "Robotics", "Python", "3D printing"]
# Each person requested exactly one pair. Workshop 0 is fixed in slot 0.
REQUESTS = [(0, 1, 3), (0, 2, 4), (0, 3, 2), (0, 4, 3),
(1, 2, 4), (2, 3, 3), (3, 4, 5)]
def now():
return datetime.now(timezone.utc).isoformat()
def save(path, data):
temporary = path.with_suffix(".tmp")
temporary.write_text(json.dumps(data, indent=2, default=str), encoding="utf-8")
temporary.replace(path)
def slots(index):
return [0] + [(index >> bit) & 1 for bit in range(4)]
def attendance(index):
assignment = slots(index)
return sum(n for a, b, n in REQUESTS if assignment[a] != assignment[b])
SCORES = np.array([attendance(i) for i in range(16)])
def circuit(angles):
qc = QuantumCircuit(4, name="workshop_schedule")
qc.h(range(4))
for gamma, beta in np.reshape(angles, (2, 2)):
for a, b, weight in REQUESTS:
if a == 0:
qc.rz(-gamma * weight, b - 1)
else:
qc.rzz(-gamma * weight, a - 1, b - 1)
qc.rx(2 * beta, range(4))
return qc
def probabilities(angles):
state = np.full(16, 0.25, dtype=complex)
for gamma, beta in np.reshape(angles, (2, 2)):
state *= np.exp(-1j * gamma * SCORES)
for q in range(4):
state = np.cos(beta) * state - 1j * np.sin(beta) * state[np.arange(16) ^ (1 << q)]
return abs(state)**2
def summarize(counts):
if sum(counts.values()) != SHOTS or any(len(k) != 4 or set(k) - {"0","1"} for k in counts):
raise ValueError("Invalid hardware or simulator counts")
best = int(SCORES.max())
hits = sum(n for bits, n in counts.items() if attendance(int(bits, 2)) == best)
mean = sum(attendance(int(bits, 2))*n for bits, n in counts.items()) / SHOTS
return {"counts": counts, "optimal_shots": hits, "shots": SHOTS, "mean_attendance": mean}
def simulate():
rng = np.random.default_rng(SEED)
starts = [np.array([0.15, -0.5, 0.3, -0.3]), *rng.uniform(-1, 1, (20, 4))]
optimum = min((minimize(lambda v: -float(probabilities(v) @ SCORES), initial,
method="BFGS") for initial in starts), key=lambda r:r.fun)
qc = circuit(optimum.x)
expected = Statevector.from_instruction(qc).probabilities()
if not np.allclose(probabilities(optimum.x), expected):
raise ValueError("Qiskit circuit disagrees with classical model")
qc.measure_all()
counts = StatevectorSampler(seed=SEED).run([qc], shots=SHOTS).result()[0].data.meas.get_counts()
result = summarize(counts)
result.update(workshops=NAMES, illustrative_request_counts=REQUESTS, fixed_first_slot=NAMES[0],
bit_order="Printed from left: 3D printing, Python, Robotics, Radio; 0=first slot",
seed=SEED, versions={p:version(p) for p in ("qiskit","numpy","scipy")},
scores=SCORES.tolist(), best=int(SCORES.max()), total_people=sum(w for _,_,w in REQUESTS),
angles=optimum.x.tolist(), exact_probabilities=expected.tolist(),
ideal_mean=float(expected @ SCORES),
ideal_optimal_probability=float(expected[SCORES == SCORES.max()].sum()))
save(LOCAL, result)
print(result["best"], result["ideal_mean"], result["ideal_optimal_probability"], result["optimal_shots"])
for i in np.flatnonzero(SCORES == SCORES.max()):
print(format(i,"04b"), slots(i))
def hardware():
local = json.loads(LOCAL.read_text())
if not sys.stdin.isatty():
raise RuntimeError("Use an interactive console for the hidden key prompt")
print("Workshop scheduling | 4 qubits | one 256-shot job on the shortest reported queue")
key = getpass.getpass("IBM Cloud API key (hidden): ").strip()
if not key:
return
service = QiskitRuntimeService(channel="ibm_quantum_platform", token=key,
plans_preference=["open"], region="us-east")
if RESULT.exists():
record = json.loads(RESULT.read_text())
if record["stage"] == "done":
return
if "job_id" in record:
job = service.job(record["job_id"])
else:
matches = service.jobs(job_tags=[TAG], limit=2)
if len(matches) != 1:
raise RuntimeError("Reconcile prior submission before retry")
job = matches[0]
else:
qc = circuit(local["angles"])
qc.measure_all()
backends = {b.name:b for b in service.backends(simulator=False, min_num_qubits=4)
if not b.is_mock}
compiled = {}
while True:
queue = {name:b.status().to_dict() for name,b in backends.items()}
stamp = now()
active = [name for name,status in queue.items()
if status["operational"] and status["status_msg"].lower()=="active"]
if not active:
raise RuntimeError("No active processor")
name = min(active, key=lambda n:(queue[n]["pending_jobs"],n))
backend = backends[name]
if name in compiled:
break
pm = generate_preset_pass_manager(backend=backend, optimization_level=3, seed_transpiler=SEED)
isa = pm.run(qc)
backend.check_faulty(isa)
compiled[name] = isa
isa = compiled[name]
measured = {isa.find_bit(inst.clbits[0]).index:isa.find_bit(inst.qubits[0]).index
for inst in isa.data if inst.operation.name == "measure"}
record = {"stage":"submitting", "job_tag":TAG, "backend":name, "queue_snapshot_utc":stamp,
"queues":queue, "qubits_by_classical_bit":measured, "gates":dict(isa.count_ops()),
"shots":SHOTS, "angles":local["angles"], "qiskit_ibm_runtime":version("qiskit-ibm-runtime")}
sampler = SamplerV2(mode=backend, options={"environment":{"job_tags":[TAG]},
"twirling":{"enable_gates":False,"enable_measure":False}})
with RESULT.open("x",encoding="utf-8") as out:
json.dump(record,out,indent=2)
job = sampler.run([isa],shots=SHOTS)
record.update(job_id=job.job_id(), stage="submitted")
save(RESULT,record)
print("Submitted",record["backend"],job.job_id(),flush=True)
while True:
status = str(job.status())
if status != record.get("ibm_status"):
record.update(ibm_status=status, last_status_change_utc=now())
save(RESULT, record)
if status in ("DONE","ERROR","CANCELLED"):
break
time.sleep(12)
record.update(summarize(job.result()[0].data.meas.get_counts()),stage="measured")
save(RESULT,record)
for _ in range(180):
metrics = job.metrics()
if metrics.get("usage",{}).get("status") == "complete":
break
time.sleep(5)
record.update(metrics=metrics,stage="done")
save(RESULT,record)
print("Optimal schedules:",record["optimal_shots"],"/",SHOTS)
if __name__ == "__main__":
if sys.argv[1:] == ["simulate"]:
simulate()
elif sys.argv[1:] == ["hardware"]:
logging.disable(logging.CRITICAL)
try:
hardware()
except Exception as exc:
import traceback
save(ROOT.parent/"work"/"workshop-error.json", {"type":type(exc).__name__,
"frames":[[Path(f.filename).name,f.lineno,f.name] for f in traceback.extract_tb(exc.__traceback__)]})
print(type(exc).__name__)
input("Press Enter to close.")
Personal comments
Personal comments will be added here.