From 0e3e9c72fa3bde626df70624114c585430bf0242 Mon Sep 17 00:00:00 2001 From: qingyunqian Date: Wed, 29 Jul 2026 10:57:09 +0800 Subject: [PATCH 1/5] Document Challenge 07 classical-ancilla reduction --- README.md | 8 + ...hallenge-07-classical-ancilla-reduction.md | 314 +++++++++++++++ optimized_sloutions/README.md | 6 + .../solution_7_classical_ancilla.py | 166 ++++++++ .../audit_challenge_07_classical_reduction.py | 381 ++++++++++++++++++ 5 files changed, 875 insertions(+) create mode 100644 docs/challenge-07-classical-ancilla-reduction.md create mode 100644 optimized_sloutions/challenge-07/solution_7_classical_ancilla.py create mode 100644 scripts/audit_challenge_07_classical_reduction.py diff --git a/README.md b/README.md index 34d671f..099397e 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,14 @@ Each task is framework-neutral; the required framework is selected only through The task-level map shows why a single pass rate is not enough: different frameworks and agents fail on different physical workflows, and valid artifacts can vary substantially in runtime relative to the expert TC reference. +### Challenge-design notes + +- [Challenge 07 exact classical-ancilla reduction](docs/challenge-07-classical-ancilla-reduction.md) + documents an unexpected reduction of the published measurement-feedback + circuit, provides an independently auditable proof of concept, and discusses + whether future revisions should accept the reduction or strengthen the + intended mid-circuit-measurement contract. + ## What ORBIT-Q Measures Surface-level functional tests are not enough for scientific programming. diff --git a/docs/challenge-07-classical-ancilla-reduction.md b/docs/challenge-07-classical-ancilla-reduction.md new file mode 100644 index 0000000..1b4c2ae --- /dev/null +++ b/docs/challenge-07-classical-ancilla-reduction.md @@ -0,0 +1,314 @@ +# Challenge 07: exact classical-ancilla reduction + +## Summary + +Challenge 07's reference solution is correct and faithfully implements the +stated 16-qubit measurement-feedback protocol. The public circuit itself, +however, has an unexpected exact reduction: + +```text +16 qubits x 64 measured trajectories + | + | analytic ancilla sampling + | reversible prefix-XOR inversion + v +8 data qubits x unique weighted branches +``` + +For the published seed and configuration, the 64 complete two-layer +trajectories contain only two unique branches, with multiplicities 63 and 1. +The proof-of-concept implementation therefore evaluates two eight-qubit +TensorCircuit circuits, weights them by `63/64` and `1/64`, and expands their +final energies back to the required 64 entries. + +This is best understood as a challenge-design loophole, not as a generic +acceleration of differentiable mid-circuit measurement. It satisfies the +public executable output contract while bypassing the intended 16-qubit +`cond_measure` workload. + +The repository additions associated with this report do not replace the +canonical task or human reference: + +- `optimized_sloutions/challenge-07/solution_7_classical_ancilla.py` is a + runnable proof of concept. +- `scripts/audit_challenge_07_classical_reduction.py` independently compares + the analytic reduction with a literal 16-qubit TensorCircuit circuit. + +## Exact derivation + +### Ancilla source probabilities are classical + +At the start of each layer, every ancilla is in a computational-basis state. +For the first layer this is `|0>`; for the next layer it is the previous +measurement result `b`. + +After `RY(theta)`, the pre-ladder source bit `x` has probability + +```text +P(x=1 | b=0) = sin(theta/2)^2, +P(x=1 | b=1) = cos(theta/2)^2 + = 1 - sin(theta/2)^2. +``` + +The following data-ancilla `RZZ` is diagonal in the ancilla computational +basis. Conditioned on `x`, it applies a norm-preserving unitary to the data +qubit. It can change a branch phase and the data state, but cannot change the +ancilla Z-basis probability. + +Consequently, the eight pre-ladder ancilla source bits are independent +Bernoulli variables even though the full state may be entangled with data. + +### The ancilla CNOT ladder is a prefix XOR + +Challenge 07 applies + +```text +CNOT(a[0], a[1]), CNOT(a[1], a[2]), ..., CNOT(a[6], a[7]) +``` + +in that order. On computational-basis source bits `x`, the measured bits `m` +are + +```text +m[0] = x[0], +m[i] = m[i-1] xor x[i] + = x[0] xor ... xor x[i]. +``` + +This map is bijective: + +```text +x[0] = m[0], +x[i] = m[i] xor m[i-1]. +``` + +Sequential measurement can therefore be sampled with the same fixed +uniforms used by TensorCircuit. If `q_i = P(x[i]=1)`, then + +```text +P(m[i]=1 | m[i-1]=0) = q_i, +P(m[i]=1 | m[i-1]=1) = 1 - q_i. +``` + +The proof of concept reproduces TensorCircuit's strict comparison rule +`status > 1-P(bit=1)`. + +### Conditioned quantum action stays on the data register + +Conditioning on one measured string selects one unique source string. The two +data-ancilla interactions become data-only Z rotations: + +```text +RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta), +RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). +``` + +They commute and can be emitted as one summed `RZ` angle. All remaining +quantum evolution is the original eight-data-qubit variational circuit and +the original open-boundary TFIM Hamiltonian. + +### Equal fixed trajectories can be merged + +For the public seed: + +| Complete two-layer pattern | Count | +| --- | ---: | +| all measured and source bits zero | 63 | +| one rare nonzero pattern | 1 | + +The rare measured-bit pattern, flattened by layer, is + +```text +00001111 00001010 +``` + +and its inverse pre-ladder source pattern is + +```text +00001000 00001111. +``` + +The objective is an arithmetic mean over fixed trajectories. Evaluating each +unique branch once with its exact multiplicity is therefore algebraically +identical to evaluating all duplicates. + +Changing only the seed does not close the fundamental loophole. It may +increase the number of unique branches, but every branch remains an +eight-qubit data-only circuit produced by an analytically sampled classical +ancilla controller. + +### The branch table stays fixed during optimization + +For a fixed sampled branch, the normalized conditioned data state does not +depend on the magnitude of its ancilla `RY` amplitude; that amplitude cancels +during projective normalization. The discrete comparison that selects the +branch has no pathwise derivative. Therefore the exact pathwise gradients of +all ancilla sampling angles are zero. + +Adam leaves those angles unchanged, so the fixed-uniform branch table can be +computed once before the 100 updates. The full complex64 graph produces tiny +nonzero numerical residue on nominally zero coordinates; this finite- +precision artifact is measured below rather than treated as physical signal. + +## Independent numerical audit + +The included audit constructs both: + +1. a literal 16-qubit TensorCircuit program with `cond_measure`; and +2. the independently derived analytic sampler and eight-qubit reduced + energy. + +The recorded audit on the public configuration found: + +| Check | Result | +| --- | ---: | +| Full versus analytic measurement bits | all 1,024 equal | +| Unique complete patterns | 2 | +| Pattern counts | 63, 1 | +| Initial-energy absolute error | `1.1921e-5` | +| Maximum per-trajectory energy error | `1.1444e-5` | +| Maximum non-ancilla gradient error | `1.9896e-6` | +| Full ancilla-gradient maximum magnitude | `4.6529e-7` | +| Reduced ancilla-gradient maximum magnitude | `0` | +| Post-one-Adam-update energy error | `3.3379e-6` | + +The ideal pathwise derivative of a fixed discrete branch with respect to its +sampling angle is exactly zero. The full complex64 contraction leaves only +sub-micro numerical residue on those coordinates. Adam can normalize tiny +residue into a visible parameter-coordinate change; parameters are not part +of the task output, and the physical energy comparisons remain close. + +These values come from the self-contained script in the repository using the +same six-CPU/7-GiB, no-network TensorCircuit image as the canonical proof-of- +concept run. The separate portable benchmark audit used a different full- +circuit contraction order and reported comparably small errors; both records +pass their predeclared complex64 tolerances. + +Run the audit from the repository root: + +```bash +python3 scripts/audit_challenge_07_classical_reduction.py +``` + +Run the proof of concept with the canonical evaluator by copying it to a +temporary module or making the variant directory importable: + +```bash +PYTHONPATH="$PWD/optimized_sloutions/challenge-07" \ + python3 tasks/challenge-07/tests/evaluate_7.py \ + --solution solution_7_classical_ancilla +``` + +## Paired performance evidence + +The reduction was benchmarked in the separate portable expert benchmark +repository using the unchanged public evaluator, one no-network container, +six CPUs, 7 GiB, fresh evaluator processes, and alternating pair order. + +| Metric | Human expert | Reduced candidate | +| --- | ---: | ---: | +| Passing runs | 6/6 | 6/6 | +| Mean runtime | 140.076441 s | 3.070839 s | +| Median runtime | 140.069298 s | 3.046739 s | +| Sample standard deviation | 15.386367 s | 0.124233 s | +| Standard error | 6.281458 s | 0.050718 s | + +The candidate won 6/6 pairs. Ratio-of-means speedup was 45.615x, while mean +paired speedup was 45.758x with a two-sided 95% Student-t interval of +[39.385x, 52.131x]. No successful value was filtered or rerun. + +Complete evidence, raw-output hashes, the conservative literal-measurement +variant, and the full derivation are available in +[OrbitBreakersExpertBenchmarks PR #11](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11). + +Relevant immutable hashes: + +| Artifact | SHA-256 | +| --- | --- | +| Human expert source | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | +| Reduced proof of concept | `0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e` | +| Evaluator | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | +| Six-pair report | `068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f` | + +These timings are same-machine workload evidence, not a cross-hardware or +global SOTA claim. + +## Why the current contract permits the workaround + +The task prose says that Challenge 07 is designed to exercise mid-circuit +measurement and branch-dependent feedback. The executable checks only: + +- history and trajectory array shapes; +- energy decrease and target thresholds; +- use of the selected quantum framework; +- absence of obvious hard-coded or raw-simulator bypasses. + +The reduced solution still uses TensorCircuit for all quantum gates and +Hamiltonian expectations, consumes the fixed status matrix, trains the +original parameter layout, performs 100 Adam updates, and returns the required +64 trajectory energies. It does not need to construct the ancilla register or +call `cond_measure` during optimization. + +This makes framework-fidelity review ambiguous: the solution is +mathematically faithful to the public instance but does not exercise the +framework feature that the task was intended to measure. + +## Additional specification inconsistencies + +The current problem statement contains two smaller issues: + +1. It fixes `n_trajectories = 64` but writes the objective as + `1/128 * sum(t=1..128) E_t`. The reference and evaluator use the mean over + 64 trajectories. +2. Two consecutive protocol sections are both titled + "Data Post-Processing Layer". + +These documentation issues do not cause the classicalization, but correcting +them would make a future revision less ambiguous. + +## Recommended benchmark response + +There are two reasonable policies. + +### Accept exact reductions + +Treat analytic elimination as scientific problem solving. Under this policy, +the proof of concept is a valid optimized artifact and Challenge 07 measures +whether an agent notices hidden circuit structure rather than only whether it +uses a mid-circuit API. + +The task description should then disclose that equivalent analytic +reductions are allowed, and performance comparisons should identify this +algorithmic change explicitly. + +### Require literal mid-circuit measurement + +If the intended axis is framework support for hybrid measurement-feedback +programs, the stronger fix is to redesign the circuit rather than rely only on +a source-policy rule. + +Useful changes include: + +- apply a non-diagonal ancilla operation after the data-ancilla interaction, + so measurement probabilities depend on the data state; +- replace the ancilla-only CNOT ladder with a transformation that is not a + classical basis permutation; +- include multiple hidden configurations with varied layer counts, topology, + and gates; +- define the desired sampling-gradient estimator explicitly; +- require framework-native mid-circuit measurement in the timed region as a + secondary policy check. + +Changing only the random seed, trajectory count, or OMECo budget does not +remove the exact classical controller. + +## Proposed disposition + +Keep the new proof of concept and audit as research artifacts, without +replacing the canonical reference in this pull request. Maintainers can then +choose whether a future Challenge 07 revision should: + +- embrace the reduction as a valid expert insight; +- strengthen policy to require literal `cond_measure`; or +- redesign the circuit so the intended hybrid quantum-classical workload is + intrinsic rather than merely described. diff --git a/optimized_sloutions/README.md b/optimized_sloutions/README.md index 84297ed..e510417 100644 --- a/optimized_sloutions/README.md +++ b/optimized_sloutions/README.md @@ -19,3 +19,9 @@ Host: MacBook Pro with Apple M4 Pro, 14-core CPU, 48 GB memory. Software: JAX 0. | --- | --- | --- | ---: | --- | | `challenge-01/solution_1_mpo.py` | 2026-07-07 | `evaluate_1.py --solution solution_1_mpo --max-steps 500` | 19.34s | PASS | | `challenge-05/solution_5_omeco.py` | 2026-07-07 | `evaluate_5.py --solution solution_5_omeco --max-steps 600` (reference baseline 48.27s) | 34.85s | PASS | +| `challenge-07/solution_7_classical_ancilla.py` | 2026-07-29 | six paired canonical Docker runs; see `docs/challenge-07-classical-ancilla-reduction.md` | 3.070839s mean | PASS | + +The Challenge 07 variant is intentionally labeled a challenge-design +reduction. It analytically removes the measured ancilla subsystem and should +not be interpreted as a generic speedup of framework-native mid-circuit +measurement. diff --git a/optimized_sloutions/challenge-07/solution_7_classical_ancilla.py b/optimized_sloutions/challenge-07/solution_7_classical_ancilla.py new file mode 100644 index 0000000..36f947b --- /dev/null +++ b/optimized_sloutions/challenge-07/solution_7_classical_ancilla.py @@ -0,0 +1,166 @@ +""" +Task Suite Problem 7: 16-qubit measurement-feedback VQE. + +The TensorCircuit-NG baseline uses cond_measure for ancilla measurements and +batches fixed trajectories with vmap for deterministic trajectory-averaged +energy optimization. +""" + +import numpy as np +import optax + +import tensorcircuit as tc + +K = tc.set_backend("jax") +tc.set_dtype("complex64") +tc.set_contractor("plain-experimental") + +PARAMS_PER_LAYER = 48 + + +def initial_parameters(config): + rng = np.random.default_rng(config["seed"]) + return K.convert_to_tensor( + rng.normal( + scale=config["initial_parameter_scale"], + size=(config["n_layers"] * PARAMS_PER_LAYER,), + ).astype(np.float32) + ) + + +def trajectory_status(config): + rng = np.random.default_rng(config["seed"] + 1) + return K.convert_to_tensor( + rng.random( + (config["n_trajectories"], config["n_layers"] * config["n_ancilla_qubits"]), + dtype=np.float32, + ) + ) + + +def trajectory_patterns(config, params, status): + # RZZ is diagonal, and the ancilla CNOT ladder is a computational-basis + # permutation. Therefore the measured bits can be sampled analytically + # from the independent pre-ladder ancilla bits with the exact same fixed + # uniforms. The objective is piecewise constant in the ancilla RY angles, + # so their pathwise gradients are zero and these patterns remain fixed. + p = np.asarray(K.numpy(params)) + uniforms = np.asarray(K.numpy(status)) + measured = np.zeros( + (config["n_trajectories"], config["n_layers"], config["n_ancilla_qubits"]), + dtype=np.int32, + ) + source = np.zeros_like(measured) + for trajectory in range(config["n_trajectories"]): + previous_layer = np.zeros(config["n_ancilla_qubits"], dtype=np.int32) + for layer in range(config["n_layers"]): + offset = layer * PARAMS_PER_LAYER + base = np.sin(p[offset + 8 : offset + 16] / 2.0) ** 2 + probability_one = base + previous_layer * (1.0 - 2.0 * base) + previous_output = 0 + for a in range(config["n_ancilla_qubits"]): + q = probability_one[a] + if previous_output: + q = 1.0 - q + bit = int( + uniforms[trajectory, layer * config["n_ancilla_qubits"] + a] + > 1.0 - q + ) + measured[trajectory, layer, a] = bit + source[trajectory, layer, a] = bit ^ previous_output + previous_output = bit + previous_layer = measured[trajectory, layer] + patterns = np.stack([measured, source], axis=1) + unique, inverse, counts = np.unique( + patterns.reshape(config["n_trajectories"], -1), + axis=0, + return_inverse=True, + return_counts=True, + ) + unique = unique.reshape( + -1, 2, config["n_layers"], config["n_ancilla_qubits"] + ) + return ( + K.convert_to_tensor(unique), + K.convert_to_tensor(inverse, dtype="int32"), + K.convert_to_tensor(counts.astype(np.float32) / config["n_trajectories"]), + ) + + +def make_one_pattern(config): + n_data = config["n_data_qubits"] + n_layers = config["n_layers"] + transverse_field = config["transverse_field"] + + pauli_strings = [] + weights = [] + for i in range(n_data - 1): + term = [0] * n_data + term[i] = 3 + term[i + 1] = 3 + pauli_strings.append(term) + weights.append(-1.0) + for i in range(n_data): + term = [0] * n_data + term[i] = 1 + pauli_strings.append(term) + weights.append(-transverse_field) + hamiltonian = tc.quantum.PauliStringSum2COO(pauli_strings, weights) + + def one_pattern(params, pattern): + measured, source = pattern + c = tc.Circuit(n_data) + for layer in range(n_layers): + offset = layer * PARAMS_PER_LAYER + for q in range(n_data): + c.ry(q, theta=params[offset + q]) + theta0 = params[offset + 24 : offset + 32] + theta1 = params[offset + 32 : offset + 40] + for q in range(n_data): + bitf = K.cast(measured[layer, q], "float32") + sourcef = K.cast(source[layer, q], "float32") + feedback_theta = theta0[q] + bitf * (theta1[q] - theta0[q]) + c.rz( + q, + theta=(1.0 - 2.0 * sourcef) * params[offset + 16 + q] + + (1.0 - 2.0 * bitf) * feedback_theta, + ) + for q in range(n_data - 1): + c.cnot(q, q + 1) + for q in range(n_data): + c.rz(q, theta=params[offset + 40 + q]) + return tc.templates.measurements.operator_expectation(c, hamiltonian) + + return one_pattern + + +def run_solution(config): + params = initial_parameters(config) + status = trajectory_status(config) + patterns, inverse, weights = trajectory_patterns(config, params, status) + one_pattern = make_one_pattern(config) + batched_patterns = K.jit(K.vmap(one_pattern, vectorized_argnums=1)) + optimizer = optax.adam(config["learning_rate"]) + + def loss_fn(p): + return K.sum(batched_patterns(p, patterns) * weights) + + def train_step(p, state): + value, grads = K.value_and_grad(loss_fn)(p) + updates, state = optimizer.update(grads, state, p) + p = optax.apply_updates(p, updates) + return p, state, value + + train_step = K.jit(train_step) + opt_state = optimizer.init(params) + energy_history = [] + for _ in range(config["max_steps"]): + params, opt_state, value = train_step(params, opt_state) + energy_history.append(value) + + final_pattern_energies = batched_patterns(params, patterns) + final_trajectory_energies = final_pattern_energies[inverse] + return { + "energy_history": K.numpy(K.stack(energy_history)), + "final_trajectory_energies": K.numpy(final_trajectory_energies), + } diff --git a/scripts/audit_challenge_07_classical_reduction.py b/scripts/audit_challenge_07_classical_reduction.py new file mode 100644 index 0000000..d76b126 --- /dev/null +++ b/scripts/audit_challenge_07_classical_reduction.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +"""Audit the exact classical-ancilla reduction proposed for Task 07.""" + +from __future__ import annotations + +import argparse +import json +from pathlib import Path +from typing import Any + +import jax +import numpy as np +import optax +import tensorcircuit as tc + + +CONFIG = { + "n_data_qubits": 8, + "n_ancilla_qubits": 8, + "n_qubits": 16, + "n_layers": 2, + "n_trajectories": 64, + "initial_parameter_scale": 0.1, + "max_steps": 100, + "learning_rate": 0.02, + "seed": 2047, + "transverse_field": 1.05, + "minimum_improvement": 0.3, + "target_final_energy": -8.3, +} + +K = tc.set_backend("jax") +tc.set_dtype("complex64") +tc.set_contractor("greedy") + + +def initial_parameters() -> Any: + rng = np.random.default_rng(CONFIG["seed"]) + return K.convert_to_tensor( + rng.normal( + scale=CONFIG["initial_parameter_scale"], + size=(CONFIG["n_layers"] * 48,), + ).astype(np.float32) + ) + + +def trajectory_status() -> Any: + rng = np.random.default_rng(CONFIG["seed"] + 1) + return K.convert_to_tensor( + rng.random( + ( + CONFIG["n_trajectories"], + CONFIG["n_layers"] * CONFIG["n_ancilla_qubits"], + ), + dtype=np.float32, + ) + ) + + +def ready(value: Any) -> Any: + return jax.tree.map( + lambda leaf: leaf.block_until_ready() + if hasattr(leaf, "block_until_ready") + else leaf, + value, + ) + + +def exact_full_bits(params: Any, status: Any) -> Any: + c = tc.Circuit(CONFIG["n_qubits"]) + pidx = 0 + sidx = 0 + layers = [] + for _ in range(CONFIG["n_layers"]): + for q in range(CONFIG["n_data_qubits"]): + c.ry(q, theta=params[pidx + q]) + pidx += CONFIG["n_data_qubits"] + for a in range(CONFIG["n_ancilla_qubits"]): + c.ry(CONFIG["n_data_qubits"] + a, theta=params[pidx + a]) + pidx += CONFIG["n_ancilla_qubits"] + for a in range(CONFIG["n_ancilla_qubits"]): + c.rzz( + CONFIG["n_data_qubits"] + a, + a, + theta=params[pidx + a], + ) + pidx += CONFIG["n_ancilla_qubits"] + for a in range(CONFIG["n_ancilla_qubits"] - 1): + c.cnot( + CONFIG["n_data_qubits"] + a, + CONFIG["n_data_qubits"] + a + 1, + ) + theta0 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] + pidx += CONFIG["n_ancilla_qubits"] + theta1 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] + pidx += CONFIG["n_ancilla_qubits"] + bits = [] + for a in range(CONFIG["n_ancilla_qubits"]): + bit = c.cond_measure( + CONFIG["n_data_qubits"] + a, status=status[sidx] + ) + bitf = K.cast(bit, "float32") + feedback = theta0[a] + bitf * (theta1[a] - theta0[a]) + c.rz(a, theta=(1.0 - 2.0 * bitf) * feedback) + bits.append(bit) + sidx += 1 + for q in range(CONFIG["n_data_qubits"] - 1): + c.cnot(q, q + 1) + for q in range(CONFIG["n_data_qubits"]): + c.rz(q, theta=params[pidx + q]) + pidx += CONFIG["n_data_qubits"] + layers.append(K.stack(bits)) + return K.stack(layers) + + +def analytic_bits(params: Any, status: Any) -> tuple[Any, Any]: + previous_measured = K.zeros([CONFIG["n_ancilla_qubits"]], dtype="int32") + measured_layers = [] + pre_ladder_layers = [] + sidx = 0 + for layer in range(CONFIG["n_layers"]): + offset = layer * 48 + ancilla_angles = params[offset + 8 : offset + 16] + base_probability_one = K.sin(ancilla_angles / 2.0) ** 2 + previous_float = K.cast(previous_measured, "float32") + probability_one = base_probability_one + previous_float * ( + 1.0 - 2.0 * base_probability_one + ) + measured = [] + pre_ladder = [] + previous_output = K.convert_to_tensor(0, dtype="int32") + for a in range(CONFIG["n_ancilla_qubits"]): + previous_output_float = K.cast(previous_output, "float32") + measured_probability_one = probability_one[a] + previous_output_float * ( + 1.0 - 2.0 * probability_one[a] + ) + bit = K.cast( + status[sidx] > (1.0 - measured_probability_one), "int32" + ) + source_bit = bit + previous_output - 2 * bit * previous_output + measured.append(bit) + pre_ladder.append(source_bit) + previous_output = bit + sidx += 1 + previous_measured = K.stack(measured) + measured_layers.append(previous_measured) + pre_ladder_layers.append(K.stack(pre_ladder)) + return K.stack(measured_layers), K.stack(pre_ladder_layers) + + +def make_full_energy() -> Any: + """Build the literal 16-qubit measurement circuit used for comparison.""" + + def full_energy(params: Any, status: Any) -> Any: + c = tc.Circuit(CONFIG["n_qubits"]) + status_index = 0 + for layer in range(CONFIG["n_layers"]): + offset = layer * 48 + for q in range(CONFIG["n_data_qubits"]): + c.ry(q, theta=params[offset + q]) + for a in range(CONFIG["n_ancilla_qubits"]): + c.ry( + CONFIG["n_data_qubits"] + a, + theta=params[offset + 8 + a], + ) + for a in range(CONFIG["n_ancilla_qubits"]): + c.rzz( + CONFIG["n_data_qubits"] + a, + a, + theta=params[offset + 16 + a], + ) + for a in range(CONFIG["n_ancilla_qubits"] - 1): + c.cnot( + CONFIG["n_data_qubits"] + a, + CONFIG["n_data_qubits"] + a + 1, + ) + theta0 = params[offset + 24 : offset + 32] + theta1 = params[offset + 32 : offset + 40] + for a in range(CONFIG["n_ancilla_qubits"]): + bit = c.cond_measure( + CONFIG["n_data_qubits"] + a, + status=status[status_index], + ) + bit_float = K.cast(bit, "float32") + feedback = theta0[a] + bit_float * (theta1[a] - theta0[a]) + c.rz(a, theta=(1.0 - 2.0 * bit_float) * feedback) + status_index += 1 + for q in range(CONFIG["n_data_qubits"] - 1): + c.cnot(q, q + 1) + for q in range(CONFIG["n_data_qubits"]): + c.rz(q, theta=params[offset + 40 + q]) + + energy = 0.0 + for q in range(CONFIG["n_data_qubits"] - 1): + energy -= K.real(c.expectation_ps(z=[q, q + 1])) + for q in range(CONFIG["n_data_qubits"]): + energy -= CONFIG["transverse_field"] * K.real( + c.expectation_ps(x=[q]) + ) + return energy + + return full_energy + + +def make_reduced_energy() -> Any: + strings = [] + weights = [] + for i in range(CONFIG["n_data_qubits"] - 1): + term = [0] * CONFIG["n_data_qubits"] + term[i] = 3 + term[i + 1] = 3 + strings.append(term) + weights.append(-1.0) + for i in range(CONFIG["n_data_qubits"]): + term = [0] * CONFIG["n_data_qubits"] + term[i] = 1 + strings.append(term) + weights.append(-CONFIG["transverse_field"]) + hamiltonian = tc.quantum.PauliStringSum2COO(strings, weights) + + def reduced_energy(params: Any, pattern: Any) -> Any: + measured, pre_ladder = pattern + c = tc.Circuit(CONFIG["n_data_qubits"]) + for layer in range(CONFIG["n_layers"]): + offset = layer * 48 + for q in range(CONFIG["n_data_qubits"]): + c.ry(q, theta=params[offset + q]) + theta0 = params[offset + 24 : offset + 32] + theta1 = params[offset + 32 : offset + 40] + for q in range(CONFIG["n_data_qubits"]): + measured_float = K.cast(measured[layer, q], "float32") + source_float = K.cast(pre_ladder[layer, q], "float32") + feedback = theta0[q] + measured_float * ( + theta1[q] - theta0[q] + ) + angle = ( + (1.0 - 2.0 * source_float) * params[offset + 16 + q] + + (1.0 - 2.0 * measured_float) * feedback + ) + c.rz(q, theta=angle) + for q in range(CONFIG["n_data_qubits"] - 1): + c.cnot(q, q + 1) + for q in range(CONFIG["n_data_qubits"]): + c.rz(q, theta=params[offset + 40 + q]) + return tc.templates.measurements.operator_expectation(c, hamiltonian) + + return reduced_energy + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--output", type=Path) + args = parser.parse_args() + + params = initial_parameters() + statuses = trajectory_status() + + full_bits = ready( + K.jit(K.vmap(exact_full_bits, vectorized_argnums=1))(params, statuses) + ) + analytic = K.jit(K.vmap(analytic_bits, vectorized_argnums=1)) + analytic_measured, analytic_pre_ladder = ready(analytic(params, statuses)) + patterns = K.stack([analytic_measured, analytic_pre_ladder], axis=1) + + pattern_array = np.asarray(patterns, dtype=np.int32) + flat_patterns = pattern_array.reshape(CONFIG["n_trajectories"], -1) + unique_flat, inverse, counts = np.unique( + flat_patterns, axis=0, return_inverse=True, return_counts=True + ) + unique_patterns = K.convert_to_tensor( + unique_flat.reshape(-1, 2, CONFIG["n_layers"], 8) + ) + inverse_tensor = K.convert_to_tensor(inverse, dtype="int32") + counts_tensor = K.convert_to_tensor(counts, dtype="float32") + + full_one = make_full_energy() + full_batch = K.jit(K.vmap(full_one, vectorized_argnums=1)) + reduced_one = make_reduced_energy() + reduced_batch = K.jit(K.vmap(reduced_one, vectorized_argnums=1)) + + def full_loss(p: Any) -> Any: + return K.mean(full_batch(p, statuses)) + + def reduced_loss(p: Any) -> Any: + values = reduced_batch(p, unique_patterns) + return K.sum(values * counts_tensor) / CONFIG["n_trajectories"] + + full_energy, full_grad = ready( + K.jit(K.value_and_grad(full_loss))(params) + ) + reduced_energy, reduced_grad = ready( + K.jit(K.value_and_grad(reduced_loss))(params) + ) + full_values = ready(full_batch(params, statuses)) + unique_values = ready(reduced_batch(params, unique_patterns)) + reduced_values = unique_values[inverse_tensor] + + ancilla_indices = np.array( + [*range(8, 16), *range(56, 64)], dtype=np.int32 + ) + non_ancilla_mask = np.ones(96, dtype=bool) + non_ancilla_mask[ancilla_indices] = False + full_grad_np = np.asarray(full_grad) + reduced_grad_np = np.asarray(reduced_grad) + + optimizer = optax.adam(CONFIG["learning_rate"]) + full_state = optimizer.init(params) + reduced_state = optimizer.init(params) + full_updates, full_state = optimizer.update(full_grad, full_state, params) + reduced_updates, reduced_state = optimizer.update( + reduced_grad, reduced_state, params + ) + full_post = optax.apply_updates(params, full_updates) + reduced_post = optax.apply_updates(params, reduced_updates) + full_post_energy = ready(K.jit(full_loss)(full_post)) + reduced_post_energy = ready(K.jit(reduced_loss)(reduced_post)) + + report = { + "schema_version": 1, + "task_id": "07", + "full_vs_analytic_bits_equal": bool( + np.array_equal(np.asarray(full_bits), np.asarray(analytic_measured)) + ), + "unique_pattern_count": int(len(unique_flat)), + "pattern_counts": [int(value) for value in counts], + "rare_trajectory_indices": [ + int(index) for index in np.where(inverse != inverse[0])[0] + ], + "initial_energy": { + "full": float(full_energy), + "reduced": float(reduced_energy), + "abs_error": abs(float(full_energy) - float(reduced_energy)), + }, + "trajectory_energy_max_abs_error": float( + np.max(np.abs(np.asarray(full_values) - np.asarray(reduced_values))) + ), + "gradient_max_abs_error": float( + np.max(np.abs(full_grad_np - reduced_grad_np)) + ), + "non_ancilla_gradient_max_abs_error": float( + np.max( + np.abs( + full_grad_np[non_ancilla_mask] + - reduced_grad_np[non_ancilla_mask] + ) + ) + ), + "full_ancilla_gradient_max_abs": float( + np.max(np.abs(full_grad_np[ancilla_indices])) + ), + "reduced_ancilla_gradient_max_abs": float( + np.max(np.abs(reduced_grad_np[ancilla_indices])) + ), + "post_update_parameter_max_abs_error": float( + np.max(np.abs(np.asarray(full_post) - np.asarray(reduced_post))) + ), + "post_update_energy": { + "full": float(full_post_energy), + "reduced": float(reduced_post_energy), + "abs_error": abs( + float(full_post_energy) - float(reduced_post_energy) + ), + }, + } + report["passed"] = bool( + report["full_vs_analytic_bits_equal"] + and report["unique_pattern_count"] == 2 + and report["initial_energy"]["abs_error"] <= 5e-5 + and report["non_ancilla_gradient_max_abs_error"] <= 5e-4 + and report["post_update_energy"]["abs_error"] <= 2e-3 + ) + rendered = json.dumps(report, indent=2, sort_keys=True) + "\n" + if args.output is not None: + args.output.write_text(rendered, encoding="utf-8") + print(rendered, end="") + if not report["passed"]: + raise SystemExit(1) + + +if __name__ == "__main__": + main() From 506fdf08ea28f6be887119e4e5854d1bdbffac43 Mon Sep 17 00:00:00 2001 From: qingyunqian Date: Wed, 29 Jul 2026 11:38:25 +0800 Subject: [PATCH 2/5] Address Challenge 07 review feedback --- README.md | 2 +- ...hallenge-07-classical-ancilla-reduction.md | 314 ------------------ .../README.md | 2 +- .../challenge-01/solution_1_mpo.py | 0 .../challenge-05/solution_5_omeco.py | 0 .../CLASSICAL_ANCILLA_REDUCTION.md | 155 +++++++++ .../audit_classical_ancilla_reduction.py | 0 .../solution_7_classical_ancilla.py | 0 8 files changed, 157 insertions(+), 316 deletions(-) delete mode 100644 docs/challenge-07-classical-ancilla-reduction.md rename {optimized_sloutions => optimized_solutions}/README.md (93%) rename {optimized_sloutions => optimized_solutions}/challenge-01/solution_1_mpo.py (100%) rename {optimized_sloutions => optimized_solutions}/challenge-05/solution_5_omeco.py (100%) create mode 100644 optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md rename scripts/audit_challenge_07_classical_reduction.py => optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py (100%) rename {optimized_sloutions => optimized_solutions}/challenge-07/solution_7_classical_ancilla.py (100%) diff --git a/README.md b/README.md index 099397e..666ca43 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ The task-level map shows why a single pass rate is not enough: different framewo ### Challenge-design notes -- [Challenge 07 exact classical-ancilla reduction](docs/challenge-07-classical-ancilla-reduction.md) +- [Challenge 07 exact classical-ancilla reduction](optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md) documents an unexpected reduction of the published measurement-feedback circuit, provides an independently auditable proof of concept, and discusses whether future revisions should accept the reduction or strengthen the diff --git a/docs/challenge-07-classical-ancilla-reduction.md b/docs/challenge-07-classical-ancilla-reduction.md deleted file mode 100644 index 1b4c2ae..0000000 --- a/docs/challenge-07-classical-ancilla-reduction.md +++ /dev/null @@ -1,314 +0,0 @@ -# Challenge 07: exact classical-ancilla reduction - -## Summary - -Challenge 07's reference solution is correct and faithfully implements the -stated 16-qubit measurement-feedback protocol. The public circuit itself, -however, has an unexpected exact reduction: - -```text -16 qubits x 64 measured trajectories - | - | analytic ancilla sampling - | reversible prefix-XOR inversion - v -8 data qubits x unique weighted branches -``` - -For the published seed and configuration, the 64 complete two-layer -trajectories contain only two unique branches, with multiplicities 63 and 1. -The proof-of-concept implementation therefore evaluates two eight-qubit -TensorCircuit circuits, weights them by `63/64` and `1/64`, and expands their -final energies back to the required 64 entries. - -This is best understood as a challenge-design loophole, not as a generic -acceleration of differentiable mid-circuit measurement. It satisfies the -public executable output contract while bypassing the intended 16-qubit -`cond_measure` workload. - -The repository additions associated with this report do not replace the -canonical task or human reference: - -- `optimized_sloutions/challenge-07/solution_7_classical_ancilla.py` is a - runnable proof of concept. -- `scripts/audit_challenge_07_classical_reduction.py` independently compares - the analytic reduction with a literal 16-qubit TensorCircuit circuit. - -## Exact derivation - -### Ancilla source probabilities are classical - -At the start of each layer, every ancilla is in a computational-basis state. -For the first layer this is `|0>`; for the next layer it is the previous -measurement result `b`. - -After `RY(theta)`, the pre-ladder source bit `x` has probability - -```text -P(x=1 | b=0) = sin(theta/2)^2, -P(x=1 | b=1) = cos(theta/2)^2 - = 1 - sin(theta/2)^2. -``` - -The following data-ancilla `RZZ` is diagonal in the ancilla computational -basis. Conditioned on `x`, it applies a norm-preserving unitary to the data -qubit. It can change a branch phase and the data state, but cannot change the -ancilla Z-basis probability. - -Consequently, the eight pre-ladder ancilla source bits are independent -Bernoulli variables even though the full state may be entangled with data. - -### The ancilla CNOT ladder is a prefix XOR - -Challenge 07 applies - -```text -CNOT(a[0], a[1]), CNOT(a[1], a[2]), ..., CNOT(a[6], a[7]) -``` - -in that order. On computational-basis source bits `x`, the measured bits `m` -are - -```text -m[0] = x[0], -m[i] = m[i-1] xor x[i] - = x[0] xor ... xor x[i]. -``` - -This map is bijective: - -```text -x[0] = m[0], -x[i] = m[i] xor m[i-1]. -``` - -Sequential measurement can therefore be sampled with the same fixed -uniforms used by TensorCircuit. If `q_i = P(x[i]=1)`, then - -```text -P(m[i]=1 | m[i-1]=0) = q_i, -P(m[i]=1 | m[i-1]=1) = 1 - q_i. -``` - -The proof of concept reproduces TensorCircuit's strict comparison rule -`status > 1-P(bit=1)`. - -### Conditioned quantum action stays on the data register - -Conditioning on one measured string selects one unique source string. The two -data-ancilla interactions become data-only Z rotations: - -```text -RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta), -RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). -``` - -They commute and can be emitted as one summed `RZ` angle. All remaining -quantum evolution is the original eight-data-qubit variational circuit and -the original open-boundary TFIM Hamiltonian. - -### Equal fixed trajectories can be merged - -For the public seed: - -| Complete two-layer pattern | Count | -| --- | ---: | -| all measured and source bits zero | 63 | -| one rare nonzero pattern | 1 | - -The rare measured-bit pattern, flattened by layer, is - -```text -00001111 00001010 -``` - -and its inverse pre-ladder source pattern is - -```text -00001000 00001111. -``` - -The objective is an arithmetic mean over fixed trajectories. Evaluating each -unique branch once with its exact multiplicity is therefore algebraically -identical to evaluating all duplicates. - -Changing only the seed does not close the fundamental loophole. It may -increase the number of unique branches, but every branch remains an -eight-qubit data-only circuit produced by an analytically sampled classical -ancilla controller. - -### The branch table stays fixed during optimization - -For a fixed sampled branch, the normalized conditioned data state does not -depend on the magnitude of its ancilla `RY` amplitude; that amplitude cancels -during projective normalization. The discrete comparison that selects the -branch has no pathwise derivative. Therefore the exact pathwise gradients of -all ancilla sampling angles are zero. - -Adam leaves those angles unchanged, so the fixed-uniform branch table can be -computed once before the 100 updates. The full complex64 graph produces tiny -nonzero numerical residue on nominally zero coordinates; this finite- -precision artifact is measured below rather than treated as physical signal. - -## Independent numerical audit - -The included audit constructs both: - -1. a literal 16-qubit TensorCircuit program with `cond_measure`; and -2. the independently derived analytic sampler and eight-qubit reduced - energy. - -The recorded audit on the public configuration found: - -| Check | Result | -| --- | ---: | -| Full versus analytic measurement bits | all 1,024 equal | -| Unique complete patterns | 2 | -| Pattern counts | 63, 1 | -| Initial-energy absolute error | `1.1921e-5` | -| Maximum per-trajectory energy error | `1.1444e-5` | -| Maximum non-ancilla gradient error | `1.9896e-6` | -| Full ancilla-gradient maximum magnitude | `4.6529e-7` | -| Reduced ancilla-gradient maximum magnitude | `0` | -| Post-one-Adam-update energy error | `3.3379e-6` | - -The ideal pathwise derivative of a fixed discrete branch with respect to its -sampling angle is exactly zero. The full complex64 contraction leaves only -sub-micro numerical residue on those coordinates. Adam can normalize tiny -residue into a visible parameter-coordinate change; parameters are not part -of the task output, and the physical energy comparisons remain close. - -These values come from the self-contained script in the repository using the -same six-CPU/7-GiB, no-network TensorCircuit image as the canonical proof-of- -concept run. The separate portable benchmark audit used a different full- -circuit contraction order and reported comparably small errors; both records -pass their predeclared complex64 tolerances. - -Run the audit from the repository root: - -```bash -python3 scripts/audit_challenge_07_classical_reduction.py -``` - -Run the proof of concept with the canonical evaluator by copying it to a -temporary module or making the variant directory importable: - -```bash -PYTHONPATH="$PWD/optimized_sloutions/challenge-07" \ - python3 tasks/challenge-07/tests/evaluate_7.py \ - --solution solution_7_classical_ancilla -``` - -## Paired performance evidence - -The reduction was benchmarked in the separate portable expert benchmark -repository using the unchanged public evaluator, one no-network container, -six CPUs, 7 GiB, fresh evaluator processes, and alternating pair order. - -| Metric | Human expert | Reduced candidate | -| --- | ---: | ---: | -| Passing runs | 6/6 | 6/6 | -| Mean runtime | 140.076441 s | 3.070839 s | -| Median runtime | 140.069298 s | 3.046739 s | -| Sample standard deviation | 15.386367 s | 0.124233 s | -| Standard error | 6.281458 s | 0.050718 s | - -The candidate won 6/6 pairs. Ratio-of-means speedup was 45.615x, while mean -paired speedup was 45.758x with a two-sided 95% Student-t interval of -[39.385x, 52.131x]. No successful value was filtered or rerun. - -Complete evidence, raw-output hashes, the conservative literal-measurement -variant, and the full derivation are available in -[OrbitBreakersExpertBenchmarks PR #11](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11). - -Relevant immutable hashes: - -| Artifact | SHA-256 | -| --- | --- | -| Human expert source | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | -| Reduced proof of concept | `0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e` | -| Evaluator | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | -| Six-pair report | `068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f` | - -These timings are same-machine workload evidence, not a cross-hardware or -global SOTA claim. - -## Why the current contract permits the workaround - -The task prose says that Challenge 07 is designed to exercise mid-circuit -measurement and branch-dependent feedback. The executable checks only: - -- history and trajectory array shapes; -- energy decrease and target thresholds; -- use of the selected quantum framework; -- absence of obvious hard-coded or raw-simulator bypasses. - -The reduced solution still uses TensorCircuit for all quantum gates and -Hamiltonian expectations, consumes the fixed status matrix, trains the -original parameter layout, performs 100 Adam updates, and returns the required -64 trajectory energies. It does not need to construct the ancilla register or -call `cond_measure` during optimization. - -This makes framework-fidelity review ambiguous: the solution is -mathematically faithful to the public instance but does not exercise the -framework feature that the task was intended to measure. - -## Additional specification inconsistencies - -The current problem statement contains two smaller issues: - -1. It fixes `n_trajectories = 64` but writes the objective as - `1/128 * sum(t=1..128) E_t`. The reference and evaluator use the mean over - 64 trajectories. -2. Two consecutive protocol sections are both titled - "Data Post-Processing Layer". - -These documentation issues do not cause the classicalization, but correcting -them would make a future revision less ambiguous. - -## Recommended benchmark response - -There are two reasonable policies. - -### Accept exact reductions - -Treat analytic elimination as scientific problem solving. Under this policy, -the proof of concept is a valid optimized artifact and Challenge 07 measures -whether an agent notices hidden circuit structure rather than only whether it -uses a mid-circuit API. - -The task description should then disclose that equivalent analytic -reductions are allowed, and performance comparisons should identify this -algorithmic change explicitly. - -### Require literal mid-circuit measurement - -If the intended axis is framework support for hybrid measurement-feedback -programs, the stronger fix is to redesign the circuit rather than rely only on -a source-policy rule. - -Useful changes include: - -- apply a non-diagonal ancilla operation after the data-ancilla interaction, - so measurement probabilities depend on the data state; -- replace the ancilla-only CNOT ladder with a transformation that is not a - classical basis permutation; -- include multiple hidden configurations with varied layer counts, topology, - and gates; -- define the desired sampling-gradient estimator explicitly; -- require framework-native mid-circuit measurement in the timed region as a - secondary policy check. - -Changing only the random seed, trajectory count, or OMECo budget does not -remove the exact classical controller. - -## Proposed disposition - -Keep the new proof of concept and audit as research artifacts, without -replacing the canonical reference in this pull request. Maintainers can then -choose whether a future Challenge 07 revision should: - -- embrace the reduction as a valid expert insight; -- strengthen policy to require literal `cond_measure`; or -- redesign the circuit so the intended hybrid quantum-classical workload is - intrinsic rather than merely described. diff --git a/optimized_sloutions/README.md b/optimized_solutions/README.md similarity index 93% rename from optimized_sloutions/README.md rename to optimized_solutions/README.md index e510417..974c70b 100644 --- a/optimized_sloutions/README.md +++ b/optimized_solutions/README.md @@ -19,7 +19,7 @@ Host: MacBook Pro with Apple M4 Pro, 14-core CPU, 48 GB memory. Software: JAX 0. | --- | --- | --- | ---: | --- | | `challenge-01/solution_1_mpo.py` | 2026-07-07 | `evaluate_1.py --solution solution_1_mpo --max-steps 500` | 19.34s | PASS | | `challenge-05/solution_5_omeco.py` | 2026-07-07 | `evaluate_5.py --solution solution_5_omeco --max-steps 600` (reference baseline 48.27s) | 34.85s | PASS | -| `challenge-07/solution_7_classical_ancilla.py` | 2026-07-29 | six paired canonical Docker runs; see `docs/challenge-07-classical-ancilla-reduction.md` | 3.070839s mean | PASS | +| `challenge-07/solution_7_classical_ancilla.py` | 2026-07-29 | six paired canonical Docker runs; see `challenge-07/CLASSICAL_ANCILLA_REDUCTION.md` | 3.070839s mean | PASS | The Challenge 07 variant is intentionally labeled a challenge-design reduction. It analytically removes the measured ancilla subsystem and should diff --git a/optimized_sloutions/challenge-01/solution_1_mpo.py b/optimized_solutions/challenge-01/solution_1_mpo.py similarity index 100% rename from optimized_sloutions/challenge-01/solution_1_mpo.py rename to optimized_solutions/challenge-01/solution_1_mpo.py diff --git a/optimized_sloutions/challenge-05/solution_5_omeco.py b/optimized_solutions/challenge-05/solution_5_omeco.py similarity index 100% rename from optimized_sloutions/challenge-05/solution_5_omeco.py rename to optimized_solutions/challenge-05/solution_5_omeco.py diff --git a/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md b/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md new file mode 100644 index 0000000..fda9ba1 --- /dev/null +++ b/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md @@ -0,0 +1,155 @@ +# Challenge 07: exact classical-ancilla reduction + +## Finding + +Challenge 07's reference is correct, but the published circuit admits an +unexpected exact reduction: + +```text +16 qubits x 64 measured trajectories + | + | analytic ancilla sampling + | prefix-XOR inversion + v +8 data qubits x unique weighted branches +``` + +For the public seed, the 64 complete two-layer trajectories contain only two +unique branches with multiplicities 63 and 1. The proof of concept evaluates +those two eight-qubit TensorCircuit circuits, weights them by `63/64` and +`1/64`, and reconstructs the required 64 final energies. + +This is a challenge-design loophole, not a generic acceleration of +framework-native mid-circuit measurement. The canonical task, evaluator, and +human reference are unchanged by this variant. + +Files in this directory: + +- `solution_7_classical_ancilla.py`: runnable proof of concept; +- `audit_classical_ancilla_reduction.py`: literal 16-qubit versus reduced + numerical audit. + +## Why the reduction is exact + +At the start of each layer, every ancilla is in a computational-basis state +`|b>`. After `RY(theta)`, its pre-ladder source bit `x` satisfies + +```text +P(x=1 | b=0) = sin(theta/2)^2, +P(x=1 | b=1) = cos(theta/2)^2. +``` + +The following data-ancilla `RZZ` is diagonal in the ancilla basis. Conditioned +on `x`, it applies a norm-preserving data unitary, so it cannot change the +ancilla Z-basis probability. + +The ordered ancilla ladder + +```text +CNOT(a[0], a[1]), ..., CNOT(a[6], a[7]) +``` + +is the reversible prefix-XOR map + +```text +m[0] = x[0], +m[i] = m[i-1] xor x[i], +x[i] = m[i] xor m[i-1]. +``` + +It can therefore be sampled analytically with the same fixed uniforms and +TensorCircuit's strict `status > 1-P(bit=1)` comparison. + +Conditioning on source and measured bits converts the two data-ancilla +interactions into data-only rotations: + +```text +RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta), +RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). +``` + +The rotations commute and are emitted as one summed `RZ` angle. The remaining +quantum computation is the original eight-data-qubit circuit and TFIM +expectation. + +For a fixed branch, projective normalization cancels the magnitude of the +ancilla `RY` amplitude. The discrete comparison has no pathwise derivative, +so the exact ancilla-angle gradients are zero and the branch table remains +fixed during Adam optimization. + +## Reproduction + +Run the self-contained audit from the repository root: + +```bash +python3 optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py +``` + +Run the 100-step proof of concept: + +```bash +PYTHONPATH="$PWD/optimized_solutions/challenge-07" \ + python3 tasks/challenge-07/tests/evaluate_7.py \ + --solution solution_7_classical_ancilla +``` + +The no-network, six-CPU/7-GiB TensorCircuit run produced: + +| Check | Result | +| --- | ---: | +| Canonical evaluator | PASS, 3.15 s | +| Full versus analytic measurement bits | all 1,024 equal | +| Unique branch counts | 63, 1 | +| Initial-energy absolute error | `1.1921e-5` | +| Maximum trajectory-energy error | `1.1444e-5` | +| Maximum non-ancilla gradient error | `1.9896e-6` | +| Full / reduced ancilla-gradient max | `4.6529e-7` / `0` | +| Post-one-Adam-update energy error | `3.3379e-6` | + +The tiny full-circuit ancilla gradient is complex64 contraction residue on an +exactly zero pathwise derivative. + +## Paired performance evidence + +A separate same-container benchmark used six CPUs, 7 GiB, no network, fresh +evaluator processes, and alternating pair order: + +| Metric | Human expert | Reduced variant | +| --- | ---: | ---: | +| Passing runs | 6/6 | 6/6 | +| Mean runtime | 140.076441 s | 3.070839 s | +| Median runtime | 140.069298 s | 3.046739 s | + +The reduced variant won 6/6 pairs. Mean paired speedup was 45.758x with a 95% +Student-t interval of [39.385x, 52.131x]. No successful value was filtered or +rerun. Full logs and hashes are preserved in +[OrbitBreakersExpertBenchmarks PR #11](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11). + +The proof-of-concept SHA-256 is +`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. +These are same-machine workload results, not a cross-hardware SOTA claim. + +## Benchmark implications + +The executable checks allow this solution because it still: + +- uses TensorCircuit for all remaining quantum evolution and expectations; +- consumes all fixed status rows and keeps the 96-parameter layout; +- performs exactly 100 Adam updates; +- returns the required history and 64 trajectory energies. + +It does not construct the ancilla register or call `cond_measure` during +optimization. If Challenge 07 is intended to measure framework support for +hybrid measurement-feedback programs, the stronger fix is to redesign the +circuit so that measurement probabilities depend on the data state, for +example with a non-diagonal ancilla operation after data-ancilla interaction. +Changing only the seed or trajectory count does not remove the analytic +controller. + +The problem statement also defines 64 trajectories but writes a `1/128` +objective, and repeats the "Data Post-Processing Layer" heading. These +documentation issues are independent of the reduction. + +Maintainers can either accept the reduction as scientific problem solving or +revise the circuit/policy to require intrinsic framework-native mid-circuit +measurement. diff --git a/scripts/audit_challenge_07_classical_reduction.py b/optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py similarity index 100% rename from scripts/audit_challenge_07_classical_reduction.py rename to optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py diff --git a/optimized_sloutions/challenge-07/solution_7_classical_ancilla.py b/optimized_solutions/challenge-07/solution_7_classical_ancilla.py similarity index 100% rename from optimized_sloutions/challenge-07/solution_7_classical_ancilla.py rename to optimized_solutions/challenge-07/solution_7_classical_ancilla.py From 07900bdd809fe22c9599fa834e80c7aa599262b1 Mon Sep 17 00:00:00 2001 From: qingyunqian Date: Thu, 30 Jul 2026 05:29:46 +0800 Subject: [PATCH 3/5] Add Task 07 final benchmark ablation evidence --- .../CLASSICAL_ANCILLA_REDUCTION_REPORT.md | 279 ++++++ .../research/IMPLEMENTATION_COMPARISON.md | 198 +++++ .../challenge-07/research/INSIGHTS.md | 136 +++ .../challenge-07/research/LOG.md | 800 ++++++++++++++++++ .../challenge-07/research/README.md | 15 + .../challenge-07/research/SURVEY.md | 216 +++++ .../profiles/bootstrap-reference.json | 78 ++ .../profiles/e01-single-state-screen.json | 73 ++ .../profiles/e02-feedback-rz-screen.json | 62 ++ .../profiles/e03-training-scan-screen.json | 35 + .../profiles/e04a-omeco-1x1-screen.json | 42 + .../research/profiles/e04b-greedy-screen.json | 19 + .../e05-measurement-round-screen.json | 43 + .../research/profiles/e06-vvag-screen.json | 18 + .../profiles/e07-classical-ancilla-audit.json | 30 + .../e11-contractor-six-pair-screen.json | 76 ++ .../e11-final-canonical-six-pairs.json | 630 ++++++++++++++ .../profiles/final-canonical-six-pairs.json | 123 +++ .../profiles/final-reference-six.json | 141 +++ .../research/run_docker_matrix.py | 418 +++++++++ .../validate_classical_ancilla_reduction.py | 320 +++++++ .../research/validate_e01_equivalence.py | 116 +++ .../research/validate_feedback_identity.py | 51 ++ .../challenge-07/solution_7_conservative.py | 151 ++++ 24 files changed, 4070 insertions(+) create mode 100644 optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md create mode 100644 optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md create mode 100644 optimized_solutions/challenge-07/research/INSIGHTS.md create mode 100644 optimized_solutions/challenge-07/research/LOG.md create mode 100644 optimized_solutions/challenge-07/research/README.md create mode 100644 optimized_solutions/challenge-07/research/SURVEY.md create mode 100644 optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json create mode 100644 optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json create mode 100644 optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json create mode 100644 optimized_solutions/challenge-07/research/profiles/final-reference-six.json create mode 100644 optimized_solutions/challenge-07/research/run_docker_matrix.py create mode 100644 optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py create mode 100644 optimized_solutions/challenge-07/research/validate_e01_equivalence.py create mode 100644 optimized_solutions/challenge-07/research/validate_feedback_identity.py create mode 100644 optimized_solutions/challenge-07/solution_7_conservative.py diff --git a/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md b/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md new file mode 100644 index 0000000..5fc201c --- /dev/null +++ b/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md @@ -0,0 +1,279 @@ +# Task 07 Challenge-Design Reduction Report + +## Executive result + +Task 07 appears to require 64 differentiable trajectories of a 16-qubit +mid-circuit measurement-feedback VQE. For the published circuit, that +description hides an exact reduction: + +```text +16 qubits x 64 measured trajectories + | + | exact analytic ancilla sampling + | exact reversible-bit inversion + v +8 data qubits x 2 unique weighted circuits +``` + +For the fixed public seed, 63 trajectories select the same all-zero +two-layer pattern and only trajectory 36 selects a second pattern. The final +implementation evaluates those two data-only TensorCircuit circuits, weights +them by `63/64` and `1/64`, and expands their final energies back to the +required 64 entries. + +In six counterbalanced canonical pairs, every cell passes and the reduced +candidate wins 6/6: + +| Metric | Human expert | Reduced candidate | +| --- | ---: | ---: | +| Passing runs | 6/6 | 6/6 | +| Mean runtime | 140.076441 s | 3.070839 s | +| Median runtime | 140.069298 s | 3.046739 s | +| Sample standard deviation | 15.386367 s | 0.124233 s | +| Standard error | 6.281458 s | 0.050718 s | +| Minimum / maximum | 123.286060 / 159.579514 s | 2.966582 / 3.311737 s | + +Ratio-of-means speedup is **45.615x** and evaluator time falls by +**97.8077%**. Mean paired speedup is **45.758x**, with a two-sided 95% +Student-t interval of **[39.385x, 52.131x]**. + +This is the repository campaign-best result for the public workload. It is +not a cross-hardware or global SOTA claim. + +## Why the reduction is exact + +### 1. The ancilla source distribution is classical + +At the beginning of each layer every ancilla is in a computational-basis +state. In layer zero that state is `|0>`; in the next layer it is the +previous measured bit `b`. + +After `RY(theta)`, the probability of the pre-ladder source bit `x=1` is: + +```text +P(x=1 | b=0) = sin(theta/2)^2 +P(x=1 | b=1) = cos(theta/2)^2 + = 1 - sin(theta/2)^2. +``` + +The following paired data-ancilla `RZZ` is diagonal in the ancilla +computational basis. Conditioned on `x`, it applies a unitary data rotation, +so it preserves the norm of each ancilla branch and cannot alter these +probabilities. Different ancillas remain independent before the ancilla +CNOT ladder. + +### 2. The CNOT ladder is a prefix XOR + +The expert applies the ordered ladder +`CNOT(a[0],a[1]), ..., CNOT(a[6],a[7])`. It maps independent source bits +`x` to measured bits `m` as: + +```text +m[0] = x[0] +m[i] = m[i-1] xor x[i] + = x[0] xor ... xor x[i]. +``` + +The map is bijective: + +```text +x[0] = m[0] +x[i] = m[i] xor m[i-1]. +``` + +Sequential measurement therefore has the simple conditional law +`m[i] = m[i-1] xor x[i]`. The implementation uses the same float32 uniforms +and the same strict TensorCircuit condition +`status > 1-P(m[i]=1)`. + +An independent audit compares this analytic rule with the full 16-qubit +TensorCircuit `cond_measure` program. All **1,024** bits +(`64 trajectories x 2 layers x 8 ancillas`) are identical. + +### 3. Conditioned quantum action stays on the data register + +Once `x` and `m` are fixed, the data-ancilla entangler and feedback gates +become data-only rotations: + +```text +RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta) +RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). +``` + +Both are Z rotations and commute, so the candidate emits their summed angle +as one native TensorCircuit `RZ` before the data CNOT ladder. The remaining +quantum circuit has eight data qubits and the unchanged open-boundary TFIM +Hamiltonian. + +### 4. Equal trajectories can be merged + +Applying the analytic sampler to all public fixed uniforms produces exactly +two complete two-layer patterns: + +| Pattern | Count | Trajectory indices | +| --- | ---: | --- | +| all measured/source bits zero | 63 | all except 36 | +| rare nonzero pattern | 1 | 36 | + +The rare measured-bit pattern, flattened by layer, is: + +```text +00001111 00001010 +``` + +Its inverse pre-ladder source pattern is: + +```text +00001000 00001111 +``` + +Because the objective is a mean over fixed trajectories, evaluating the two +unique circuits with weights `63/64` and `1/64` is algebraically identical +to evaluating 64 duplicates. + +## Numerical audit + +The proof is exact over real arithmetic. Complex64 contraction order changes +introduce small rounding differences, which are reported explicitly. + +| Check against full accepted 16-qubit implementation | Result | +| --- | ---: | +| Analytic/full measured bits equal | true | +| Initial energy absolute error | `4.7684e-6` | +| Maximum per-trajectory energy error | `4.2915e-6` | +| Maximum non-ancilla gradient error | `1.5116e-6` | +| Full ancilla gradient maximum magnitude | `4.6559e-7` | +| Reduced ancilla gradient maximum magnitude | `0` | +| Post-one-Adam-update energy error | `4.6730e-5` | +| Audit decision | PASS | + +The ideal pathwise derivative of a fixed discrete sample with respect to its +sampling angle is zero. The full complex64 graph leaves only sub-micro +rounding residue on those ancilla gradients. Adam can normalize tiny residue +into a visible parameter-coordinate movement, but parameters are not part of +the executable output contract and the physical energy checks remain close. + +The complete 100-update evaluator also passes: + +```text +initial history energy: -6.8462696075 +final history energy: -10.0277128220 +improvement: 3.1814432144 +final trajectory mean: -10.0331783295 +final trajectory std: 0.0007445384 +history length: 100 +``` + +## Formal six-pair benchmark + +All cells used one no-network Docker container, a fresh evaluator process, +six CPUs, 7 GiB, TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`, +and the unchanged 300-second limit. Pair order alternated to balance position. + +| Pair | Order | Expert (s) | Candidate (s) | Speedup | +| ---: | --- | ---: | ---: | ---: | +| 1 | expert -> candidate | 123.286060 | 3.062554 | 40.2560x | +| 2 | candidate -> expert | 126.247088 | 3.311737 | 38.1211x | +| 3 | expert -> candidate | 150.224728 | 2.989908 | 50.2439x | +| 4 | candidate -> expert | 129.913867 | 3.030923 | 42.8628x | +| 5 | expert -> candidate | 159.579514 | 3.063330 | 52.0935x | +| 6 | candidate -> expert | 151.207388 | 2.966582 | 50.9702x | + +No successful value was filtered or rerun. The report retains every raw +stdout/stderr hash and passes the frozen promotion rule. + +| Artifact | SHA-256 | +| --- | --- | +| Immutable expert | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | +| Reduced candidate | `0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e` | +| Evaluator | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | +| Docker image | `b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` | +| Staging snapshot | `d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f` | +| Paired report | `068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f` | + +## Secondary tuning after the reduction + +Once only two eight-qubit circuits remained, the earlier large-network +choices were re-evaluated: + +| Experiment | Canonical result | Decision | +| --- | ---: | --- | +| Python loop | 2.998 s exploratory | Keep | +| Whole-training `K.jaxy_scan` | 3.206 s | Reject | +| Explicit `RY`/`RZ` dense-gate fusion | 3.531 s | Reject | +| TensorNetwork greedy | 2.947 s six-run mean | Reject | +| OMECo 1x1 | 2.949 s six-run mean | Reject | +| TensorCircuit `plain-experimental` | 2.823/2.839 s comparison means | Keep | + +The local contractor beat greedy in 6/6 paired screens with a mean +`1.0442x` speedup and 95% interval `[1.0029x, 1.0855x]`. It beat OMECo-1x1 +in 5/6 pairs; that smaller `1.0395x` mean advantage has interval +`[0.9933x, 1.0856x]`. The default local setting was retained because it is +the simplest native small-graph choice and avoids OMECo path search. + +## Is this a valid optimization or a loophole? + +There are two defensible interpretations. + +Under the executable public contract, it is valid: + +- all 64 seeded statuses are consumed; +- all 96 parameters retain their layout; +- exactly 100 Adam updates are performed; +- the required pre-update history and 64 final trajectory energies are + returned; +- no energy, output, threshold, or reference value is hard-coded; +- TensorCircuit performs all remaining quantum gate evolution and Hamiltonian + expectations. + +Under the likely benchmark-design intent, it is a loophole: + +- the candidate no longer constructs 16 qubits; +- it does not call TensorCircuit `cond_measure` during optimization; +- it benchmarks an exact classical controller plus two eight-qubit circuits, + not generic differentiable mid-circuit measurement at scale. + +The problem statement does not explicitly prohibit exact analytic elimination +of measured ancillas or deduplication of fixed trajectories. If Task 07 is +intended to test TensorCircuit's mid-circuit measurement machinery, the +contract is under-specified. + +## Recommended maintainer action + +Keep two implementations visible: + +1. The registered `conservative` e04a variant at + `src/solutions/task-07/variants/solution_7_conservative.py` is the + appropriate answer when literal 16-qubit TensorCircuit `cond_measure` + execution is required. It preserves every intended operation and measured + a 4.479x paired speedup. +2. The e11 reduction is the campaign-best answer to the current executable + contract and should be used to document/fix the challenge-design gap. + +To close the loophole in a future benchmark revision, require at least one of: + +- explicit use of the full data-plus-ancilla register and framework-native + mid-circuit measurement in the timed region; +- hidden instances with randomized layer counts, ancilla coupling topology, + non-diagonal data-ancilla gates, or feedback that prevents branch + classicalization; +- trainable sampling distributions whose gradients are defined by a stated + estimator rather than pathwise differentiation through discrete branches; +- a policy check that rejects analytic elimination of the measured subsystem. + +The strongest fix is semantic rather than cosmetic: introduce a +non-computational-basis ancilla interaction after entanglement so that an +ancilla measurement probability genuinely depends on the data state. Merely +changing the seed or increasing trajectory count does not remove the +reduction; it only changes the number of unique classical patterns. + +## PR positioning + +Suggested title: + +`Task 07: expose exact classical-ancilla reduction (45.76x paired)` + +The PR should explicitly label this as a challenge-design reduction, link the +full audit and conservative 4.48x alternative, and invite maintainers to +decide whether the public executable contract or the intended +mid-circuit-measurement semantics should govern acceptance. diff --git a/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md b/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md new file mode 100644 index 0000000..7ce23f9 --- /dev/null +++ b/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md @@ -0,0 +1,198 @@ +# Task 07 Conservative Human-Expert Optimization Report + +> **Status:** retained as the literal 16-qubit / `cond_measure` fallback. +> The current executable-contract winner is the exact classical-ancilla +> reduction documented in +> [`CLASSICAL_ANCILLA_REDUCTION_REPORT.md`](CLASSICAL_ANCILLA_REDUCTION_REPORT.md): +> 3.070839-second candidate mean versus 140.076441-second expert mean, +> 45.757921x mean paired speedup, 95% CI +> [39.384711x, 52.131131x]. Unlike the conservative implementation below, +> that candidate exposes a challenge-design loophole and does not literally +> execute the measured ancilla register. The implementation below is retained +> as the runnable `conservative` variant at +> `src/solutions/task-07/variants/solution_7_conservative.py`. + +## Scope and claim + +This campaign optimizes only ORBIT-Q Task 07: the 16-qubit, two-layer +measurement-feedback VQE with 64 fixed trajectories and exactly 100 Adam +updates. + +The conservative candidate passes all public functional checks in all six measured +runs and wins all six counterbalanced pairs against the immutable human +expert. Mean paired speedup is **4.479x**, with a two-sided 95% Student-t +interval of **[3.891x, 5.067x]**. Ratio-of-means speedup is **4.438x** +(77.47% lower runtime). + +No external implementation reports a matched runtime for this exact +evaluator, seed, trajectory batch, container, and software stack. The result +was the **campaign-best / repository-SOTA Task 07 implementation before the +exact e11 reduction**, not a global hardware-independent SOTA claim. + +| Artifact | Path | SHA-256 | +| --- | --- | --- | +| Immutable human expert | `references/task-07/solution_7.py` | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | +| Final candidate | `src/solutions/task-07/solution_7.py` | `0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592` | +| Evaluator | `tasks/task-07/evaluator/evaluate_7.py` | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | +| Paired report | `profiles/final-canonical-six-pairs.json` | `6e03db1f37e8bbe0b38247f017d9259177a2858d54289fa2a5615542b499b54a` | +| Reference gate report | `profiles/final-reference-six.json` | `743f493120dd89e6c75a309499c28d819ae00aee09d57e7feb374b35c0310224` | + +## Final paired result + +All measurements used one no-network Docker container, six CPUs, 7 GiB, +TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`, and a fresh +evaluator process per cell. Odd pairs ran reference then candidate; even +pairs reversed the order. + +| Metric | Human expert | Candidate | +| --- | ---: | ---: | +| Passing runs | 6/6 | 6/6 | +| Mean runtime | 116.264691 s | 26.196276 s | +| Median runtime | 114.756293 s | 24.598863 s | +| Sample standard deviation | 10.035012 s | 2.980442 s | +| Standard error | 4.096777 s | 1.216760 s | +| Minimum / maximum | 106.038165 / 131.316223 s | 24.221592 / 31.684172 s | + +| Pair | Order | Expert (s) | Candidate (s) | Speedup | +| ---: | --- | ---: | ---: | ---: | +| 1 | expert -> candidate | 106.038165 | 24.481295 | 4.3314x | +| 2 | candidate -> expert | 119.427967 | 24.221592 | 4.9306x | +| 3 | expert -> candidate | 123.188182 | 24.716431 | 4.9841x | +| 4 | candidate -> expert | 107.532991 | 24.421997 | 4.4031x | +| 5 | expert -> candidate | 110.084619 | 31.684172 | 3.4744x | +| 6 | candidate -> expert | 131.316223 | 27.652166 | 4.7489x | + +The candidate wins 6/6 pairs. Mean pairwise speedup is 4.478752x +(standard error 0.228662x); the frozen Student-t rule gives +`4.478752 +/- 2.5705818366 * 0.228662`, or +**[3.890959x, 5.066545x]**. The lower bound exceeds 1.0, so every research +and promotion gate passes. + +## Why the expert is slow + +The expert performs three expensive generic operations: + +1. Each trajectory energy is seven separate `ZZ` plus eight separate `X` + `expectation_ps` calls. The same final adaptive tensor network is + contracted 15 times in both forward and gradient work. +2. After each Z measurement, `conditional_gate` still builds and selects a + dense two-qubit `RZZ` tensor, even though the measured ancilla is already + a computational-basis eigenstate. +3. The expert requests OMECo `TreeSA(ntrials=32,niters=32)`. Path search lies + inside the timed first JAX trace, and this simplified 16-qubit graph does + not benefit enough from the extra search. + +Update-count profiling confirms the split: the expert's one-step run takes +47.853 seconds, while 100 steps take 135.816 seconds. Both graph/path +construction and repeated quantum contractions matter. + +## Final implementation + +### 1. Contract the final trajectory once + +The final ancillas were Z-measured and are subsequently touched only by +diagonal feedback. The state therefore factorizes: + +`|Psi_final> = |psi_data> tensor |measured ancilla bitstring>`. + +The candidate contracts the TensorCircuit state once, reshapes it to +`(2^8, 2^8)`, and sums the ancilla basis axis; exactly one column is nonzero. +It initializes an eight-qubit TensorCircuit from that data state and evaluates +the complete TFIM with one TensorCircuit-native sparse operator built by +`PauliStringSum2COO` and +`templates.measurements.operator_expectation`. + +This replaces 15 final-circuit expectation contractions with one state +contraction and one small sparse Hamiltonian expectation. The isolated e01 +canonical screen falls from 135.816 to 61.397 seconds. + +### 2. Reduce measured feedback exactly + +For measured ancilla bit `b`, TensorCircuit's convention gives the exact +identity + +`RZZ(theta_b) |b,psi> = + |b> RZ((1-2b) theta_b) |psi>`. + +The candidate selects the same independent `theta0/theta1` parameter and +applies the signed angle through the native data-qubit `c.rz`. The ancilla is +unchanged, so the identity remains valid before the next layer. + +An independent four-case complex64 matrix-action audit covers both bits and +two signed angles; maximum error is `2.98e-8` under a frozen `1e-7` +tolerance. Removing 16 selected two-qubit nodes lowers the canonical screen +again from 61.397 to 33.546 seconds. + +### 3. Match path-search effort to the simplified graph + +The final source requests `omeco-1-1`, the TensorCircuit-NG native shortcut +for one TreeSA trial and iteration. The path remains adequate: 50- and +100-step evaluators pass with final energies matching the expert. Timed search +latency falls enough to lower the canonical screen from 33.546 to 24.362 +seconds. + +This is not a framework patch or an environment override. Both roles use the +same latest TensorCircuit-NG image; only the candidate asks the existing +framework contractor for a smaller task-appropriate search budget. + +## Preserved scientific semantics + +The candidate retains: + +- eight data and eight ancilla qubits, two adaptive layers, and the exact + order of all data/ancilla rotations, entanglers, measurements, feedback, + and CNOT ladders; +- all 96 independent trainable parameters and their seeded float32 + initialization; +- the same 64x16 seed-2048 float32 trajectory-uniform matrix, all 64 + trajectories, all 16 normalized TensorCircuit `cond_measure` operations + per trajectory, and identical bit/trajectory order; +- the two independent feedback angles for each measured pair; +- the open-boundary eight-site TFIM with transverse field 1.05; +- exactly 100 sequential Optax Adam updates at learning rate 0.02, recording + every pre-update energy; +- the final post-update 64-entry trajectory vector; +- complex64 TensorCircuit/JAX quantum computation and the exact output + keys/shapes. + +All six candidate canonical runs pass energy decrease, minimum improvement, +target energy, history length, trajectory shape, and NumPy output checks. + +## Explored alternatives + +| Experiment | Result | Decision | +| --- | --- | --- | +| e01: one native state/Hamiltonian expectation | 61.397 s canonical screen; energy/gradient errors `3.34e-6` / `1.01e-6` | Keep | +| e02: exact feedback `RZZ -> RZ` | 33.546 s; identity error `2.98e-8` | Keep | +| e03: whole-training `K.jaxy_scan` | 36.747 s vs 33.546 s | Reject: extra control-flow compilation | +| e04a: OMECo 1x1 | 24.362 s | Keep | +| e04b: greedy contractor | 23.234 s one-step vs 20.672 s for 1x1 | Reject | +| e05: joint state-based measurement rounds | fastest at 1/50 steps (4.606/14.523 s), but 26.531 s at 100 | Reject for canonical; dense-state AD crossover | +| e06: `K.vvag` trajectory gradients | 39.420 s one-step | Reject: mapped reverse-mode duplication | + +The e05 crossover is useful beyond this exact evaluator: state materialization +is excellent when staging dominates or updates are few, whereas native +tensor-network `cond_measure` wins once many gradients amortize compilation. + +## Measurement integrity and report recovery + +The paired runner successfully wrote all 24 raw stdout/stderr files and +stopped the container after all 12 passing cells. It then hit a final +serialization typo (`true` instead of Python `True`). The bug occurred after +measurement and did not affect source bytes, ordering, runtimes, or outputs. + +The runner is fixed and now checkpoints every completed cell. The tracked +paired report was reconstructed from all 12 raw logs without rerunning, +filtering, or changing any value; it records every stdout SHA-256 and the +staging snapshot hash. The fail-closed gate reports `promotion_ready: true`. + +## PR summary + +Suggested title: + +`Task 07: collapse repeated energy/feedback contractions (4.48x)` + +The PR should emphasize that the gain comes from exact Task 07 structure and +existing TensorCircuit-NG primitives—not fewer trajectories, fewer updates, +changed thresholds, hard-coded outputs, a framework downgrade, or a raw +NumPy/JAX simulator. diff --git a/optimized_solutions/challenge-07/research/INSIGHTS.md b/optimized_solutions/challenge-07/research/INSIGHTS.md new file mode 100644 index 0000000..094a60a --- /dev/null +++ b/optimized_solutions/challenge-07/research/INSIGHTS.md @@ -0,0 +1,136 @@ +# Task 07 Research Insights + +Task: `task-07` + +Last consolidated: 2026-07-29 + +Evidence ledger: [`LOG.md`](LOG.md) + +## Current best + +Experiment `e11` analytically eliminates the measured ancilla subsystem, +deduplicates the 64 fixed trajectories into two weighted patterns, and runs +the remaining eight-qubit data circuits with TensorCircuit's native local +contractor. Six final counterbalanced Docker pairs all pass and all win: +candidate mean 3.070839 seconds versus expert mean 140.076441 seconds; mean +paired speedup 45.757921x (95% Student-t CI +39.384711x-52.131131x). + +This is explicitly a challenge-design reduction. The conservative `e04a` +implementation remains available when literal 16-qubit `cond_measure` +execution is required; its six-pair result is 4.478752x. + +## Preserved semantics + +- Two adaptive layers and all 96 float32 parameters in the expert's layout; + ancilla rotation parameters remain in place but have their exact zero + pathwise gradients. +- Seed 2047 parameter initialization and seed 2048 fixed trajectory uniforms. +- The exact measured/source bits selected by all 1,024 fixed-uniform + comparisons, with the selected trainable feedback branch for every bit. +- Exactly 64 fixed trajectories averaged per objective and exactly 100 + sequential Adam updates at learning rate 0.02; equal trajectories are + evaluated once with exact multiplicity weights. +- Pre-update energy history and post-update per-trajectory energy vector. +- The eight-site open-boundary TFIM Hamiltonian and complex64 TensorCircuit + quantum computation on the remaining data register. + +Not preserved literally: construction of the eight ancilla qubits and +framework-native `cond_measure` calls. That distinction is the loophole and +must remain visible in any PR. + +## Confirmed bottlenecks + +- Every trajectory evaluates seven `ZZ` and eight `X` expectations separately, + repeating the final circuit's bra/ket contraction 15 times in both forward + and reverse-mode work. +- Approximately 48 seconds is fixed trace/compile/path/finalization cost; the + additional 99 canonical updates average about 0.89 seconds each. +- The generic `conditional_gate` keeps a selected dense two-qubit `RZZ` node + after the ancilla is already a Z eigenstate. + +## What worked + +- The ancilla circuit is exactly a classical Bernoulli source followed by a + prefix-XOR permutation. Full TensorCircuit and analytic sampling agree on + all 1,024 measured bits. +- The fixed public batch has only two unique complete patterns, with counts + 63 and 1. Replacing 64 sixteen-qubit trajectory graphs by two weighted + eight-qubit circuits lowers the canonical screen to about 3 seconds. +- TensorCircuit's `plain-experimental` local contractor is better suited to + the reduced graph than greedy or OMECo-1x1. It beats greedy in 6/6 + contractor pairs. +- One TensorCircuit state contraction plus one native sparse eight-qubit TFIM + expectation reduces the 100-step screen from 135.816 to 61.397 seconds and + the 50-step passing screen from 91.540 to 52.769 seconds. +- One-trajectory energy and gradient agree within `3.34e-6` and `1.01e-6`; + the full 50/100-step physical outputs pass and remain close. +- Reducing post-measurement + `RZZ(theta_b)|b,psi>` to + `|b> RZ((1-2b)theta_b)|psi>` removes 16 selected two-qubit nodes. The + identity audit's maximum complex64 error is `2.98e-8`; canonical runtime + falls again from 61.397 to 33.546 seconds. + +## Measurement lesson + +- Maximum first-Adam parameter difference is a poor complex64 equivalence + gate near zero gradients. The strict e01 diagnostic failed (`0.0313`) even + though energy, gradient, post-update energy, and complete public workloads + passed. Preserve that failure, but use physical post-update outputs as the + predeclared one-step semantic criterion in later experiments. + +## What did not work + +- On the reduced graph, whole-training scan remains slower (3.206 versus + 2.998 seconds in the exploratory screen), and explicit `RZ*RY` dense-gate + fusion is slower again at 3.531 seconds. +- Whole-training `K.jaxy_scan` is correct but slower after e02: 36.747 versus + 33.546 seconds for 100 steps and 34.917 versus 31.300 seconds for 50. + Control-flow compilation outweighs only 100 cached-JIT host dispatches. +- TensorNetwork greedy takes 23.234 seconds for the frozen one-step screen, + 12.39% slower than OMECo 1x1, so it was discarded before full training. +- Joint TensorCircuit-state measurement rounds are the fastest 1/50-step + method (4.606/14.523 seconds) and closely reproduce the expert, but dense + 16-qubit state differentiation raises the 100-step time to 26.531 seconds, + 8.90% slower than e04a. This exposes a crossover between staging cost and + per-update dense-state cost. +- TensorCircuit `K.vvag` is 90.69% slower at one step (39.420 seconds) because + it maps individual reverse-mode programs; differentiating the shared mapped + mean remains superior here. + +## Contractor result + +- After simplifying the graph, OMECo 32x32 over-searches. The 1x1 budget + lowers the passing canonical screen from 33.546 to 24.362 seconds and the + 50-step screen from 31.300 to 21.473 seconds without hurting convergence. + +## High-confidence exact identities + +- Final ancillas factor from the data state because the last operation that + can mix their computational basis is followed by `cond_measure`, and the + remaining feedback is diagonal. This permits one full TensorCircuit state + contraction followed by an eight-qubit native Hamiltonian expectation. +- On a measured ancilla `|b>`, feedback `RZZ(theta_b)` is exactly data + `RZ((1-2b) theta_b)` with the ancilla unchanged. +- A `K.jaxy_scan` can emit the same pre-update values while carrying the same + Optax state and final parameters. + +## Open hypotheses + +- None for the current fixed workload. Further closed-form elimination of the + eight-qubit data circuit would likely violate the framework-fidelity policy + and is unnecessary for exposing the challenge-design issue. + +## Evidence limits + +- No matched external implementation exists, so “SOTA” can mean only the + campaign-best implementation for this repository workload. +- No scaling or cross-hardware claim is supported. +- The 45.76x implementation satisfies the executable output contract but may + be rejected if maintainers interpret Task 07 as requiring literal + mid-circuit TensorCircuit measurement. The conservative 4.48x candidate is + the fallback under that interpretation. +- In the earlier conservative e04a run, long-session thermal/system noise + widened candidate times to 24.222-31.684 seconds; no value was filtered. + The final e11 candidate ranged from 2.967 to 3.312 seconds, also without + filtering. diff --git a/optimized_solutions/challenge-07/research/LOG.md b/optimized_solutions/challenge-07/research/LOG.md new file mode 100644 index 0000000..329203c --- /dev/null +++ b/optimized_solutions/challenge-07/research/LOG.md @@ -0,0 +1,800 @@ +# Task 07 Autoresearch Campaign + +Destination: `research/task-07/LOG.md` + +Task: `task-07` + +Insights: [`INSIGHTS.md`](INSIGHTS.md) + +## Campaign selection and setup + +Selected task: `task-07` (16-qubit measurement-feedback VQE). + +Base commit: `5af98f27b9404c513df8eee0f4568b1512edee19`. + +Branch: `codex/orbitbreakers/task-07/extreme-native`. + +Worktree: +`/Users/qqy/.codex/visualizations/2026/07/28/019fa982-7244-7e20-99f5-f609bdd0cf27/task07-extreme`. + +The branch and worktree were created before the Task 07 survey and candidate +files. No candidate source was edited before the survey and public workload +gates were completed. + +Open pull requests in `hmyuuu/OrbitBreakersExpertBenchmarks` were inspected +before selection. The open optimization PRs covered Tasks 08, 09, and 10; +none covered Task 07. + +## Immutable expert bootstrap: canonical + +Date: 2026-07-29 + +Reference SHA-256: +`ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3`. + +Evaluator SHA-256: +`69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31`. + +Docker image: +`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` +(TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`). + +Allocation: six CPUs, 7 GiB memory, no network; timeout 300 seconds. + +```text +workload: canonical max_steps=100 +terminal_status: SUCCESS +valid: true +runtime_sec: 135.815605 +initial_energy: -6.8462643623 +final_history_energy: -10.0279636383 +improvement: 3.1816992760 +final_trajectory_mean: -10.0333871841 +final_trajectory_std: 0.0000000000 +history_length: 100 +``` + +Decision: `bootstrap baseline`. A performance claim still requires six +matched reference/candidate pairs in one container. + +## Immutable expert update-count profile + +Date: 2026-07-29 + +All runs used the same source, image, six-CPU/7-GiB limits, seed, layers, +trajectory batch, output schema, thresholds, and evaluator. Only the +evaluator-supported `--max-steps` argument changed. + +| Updates | Runtime (s) | Final history energy | Overall | +| ---: | ---: | ---: | --- | +| 1 | 47.853128 | -6.8462719917 | FAIL (expected thresholds) | +| 10 | 51.638506 | -7.4798407555 | FAIL (target) | +| 20 | 60.074862 | -7.8647251129 | FAIL (target) | +| 32 | 69.596274 | -8.1460399628 | FAIL (target) | +| 50 | 91.540316 | -8.7927856445 | PASS | +| 100 | 135.815605 | -10.0279636383 | PASS | + +The one-step run establishes about 48 seconds of fixed trace, compilation, +contraction-path, and final-evaluation work. The remaining 99 canonical +updates add approximately 0.89 seconds each. Decision: prioritize the +per-step energy/gradient contractions, retain 50 updates as a passing screen, +and make claims only on the canonical 100-step case. + +## Frozen hypotheses + +The complete pre-edit hypothesis definitions and falsification rules are in +`SURVEY.md`. + +Primary experiment: `e01`, single native TensorCircuit state contraction plus +one native sparse eight-data-qubit Hamiltonian expectation per trajectory. + +Secondary experiments, each isolated from the latest accepted commit: + +- `e02`: exact measured-ancilla feedback `RZZ` to data `RZ` reduction; +- `e03`: whole-training `K.jaxy_scan`; +- `e04`: OMECo contractor-budget sweep; +- `e05`: native-state measurement-round reuse, only if lower-risk ideas leave + substantial headroom. + +## Experiment `e01` + +Branch: `codex/orbitbreakers/task-07/e01-single-state-energy`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e01-single-state-energy`. + +Parent commit: `21d7271` (`research: freeze task 07 optimization campaign`). + +### Hypothesis + +Replacing 15 separate per-trajectory Pauli expectation contractions with one +TensorCircuit `state` contraction and one TensorCircuit-native sparse TFIM +operator expectation materially reduces trace/compile and repeated gradient +cost while preserving energies, gradients, one Adam update, all 100 +pre-update history values, and the final trajectory vector within declared +complex64 tolerances. + +### Pre-run frozen environment + +Public dataset version: `orbitq-workloads-v20260729.5`. + +Private evaluation used: `no`. + +Reference/evaluator/image hashes: as recorded above. + +Pair order for final promotion: odd `reference -> candidate`, even +`candidate -> reference`; six pairs; 300-second cap. + +The one-trajectory equivalence check is frozen before execution at absolute +tolerances `5e-5` for energy, `5e-4` for the maximum gradient element, and +`2e-5` for the maximum parameter difference after one Adam update. These are +strict complex64 path-rounding tolerances and are not evaluator thresholds. + +### Result + +Candidate hypothesis commit: `1e21dd41f47e3beb84b937144324227eac544b6d`. + +Candidate SHA-256: +`30f0f45073e866c7fbb24cd9a5c33d8c1254e6985136937cd454b82990681678`. + +Candidate diff SHA-256: +`3396c6b65d3f6c2eaebc647d6251547dd6561d1defac4526f9f503b2dcac8b7e`. + +Sanitized record: `profiles/e01-single-state-screen.json`. + +```text +max_steps=1: reference 47.853128 s, candidate 44.917110 s +max_steps=10: reference 51.638506 s, candidate 46.100052 s +max_steps=50: reference 91.540316 s, candidate 52.769482 s, both PASS +max_steps=100: reference 135.815605 s, candidate 61.396553 s, both PASS +canonical single-screen speedup: 2.2121x +``` + +The candidate canonical run passed every evaluator gate with initial energy +`-6.8462653160`, final history energy `-10.0263500214`, improvement +`3.1800847054`, final trajectory mean/std +`-10.0319023132 / 0.0014687895`, history length 100, and the exact required +keys and shapes. + +The predeclared one-trajectory audit measured energy error `3.34e-6` and +maximum gradient error `1.01e-6`, both comfortably passing. Its strict +maximum parameter-difference check after one first Adam update failed: +`3.13e-2` versus `2e-5`, although mean parameter difference was `2.43e-3`. +This failure is retained, not filtered. + +Decision: `keep provisionally`. The state/observable identity is exact, +energy and gradient checks pass, the one-step post-update physical energy +differs by only `2.29e-5`, and the 50/100-step public workloads both pass with +nearly identical energy trajectories. The failed parameter metric reflects +the ill-conditioning of first-step Adam updates near zero: Adam normalizes +each gradient component by its magnitude, so a complex64 sign change in an +otherwise negligible component can create an order-learning-rate parameter +difference without a corresponding energy difference. Final paired +performance evidence is still pending. + +## Append-only corrections + +Append corrections below this heading. Never rewrite a result after it has +informed another experiment. + +### Correction: e01 one-update acceptance observable + +The strict per-parameter first-Adam maximum was over-specified as a semantic +criterion. The executable contract does not return parameters, and this +metric is discontinuously sensitive at zero gradient. It remains visible as +a failed diagnostic. Subsequent candidates will predeclare post-update +energy/trajectory checks as the physical one-update criterion while continuing +to report gradient errors and any parameter differences. + +## Experiment `e02`: measured-ancilla feedback reduction + +Branch: `codex/orbitbreakers/task-07/e02-feedback-rz`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e02-feedback-rz`. + +Parent commit: `2e5cd61` (accepted e01 code and complete provisional evidence). + +### Hypothesis + +After `cond_measure`, ancilla `a` is the Z eigenstate with eigenvalue +`1-2*bit`. Therefore the selected +`RZZ(theta_bit)` on `(ancilla_a, data_a)` is exactly +`RZ((1-2*bit)*theta_bit)` on the data qubit, with the ancilla unchanged. +Replacing all 16 generic selected two-qubit tensors with those native +TensorCircuit `RZ` gates reduces graph/path/gradient work without changing +any measurement, selected parameter, branch state, or observable. + +### Pre-run frozen checks + +The exact two-branch gate identity will be checked at complex64 precision. +The frozen matrix-action tolerance is `1e-7` for both bit values and two +nontrivial signed angles. +The physical one-step criteria are initial energy absolute error at most +`5e-5` versus accepted e01 and post-update final-trajectory mean absolute +error at most `1e-4`; the strict parameter maximum remains diagnostic only. +Both the public 50-step and canonical 100-step evaluators must pass. A +candidate is retained only if its canonical screen is faster than e01's +61.396553 seconds. + +### Result + +Candidate hypothesis commit: `067a1d365e8ef4a9e3f81d6dd62939c0b3af6b39`. + +Candidate SHA-256: +`b3dcbaa35a233d8dde4576de7257c79a1a81034eee49f1f0bef6489116dcafcd`. + +Candidate diff SHA-256: +`759b7139a8463d53c80f2d48148eca189235a872fac5402ae9f64be4100bac45`. + +Sanitized record: `profiles/e02-feedback-rz-screen.json`. + +The independent two-branch matrix-action audit passed all four cases. Maximum +complex64 error was `2.98e-8` against the frozen `1e-7` threshold. + +```text +max_steps=1: e01 44.917110 s, e02 29.918828 s +max_steps=50: reference 91.540316 s, e01 52.769482 s, + e02 31.299628 s, e02 PASS +max_steps=100: reference 135.815605 s, e01 61.396553 s, + e02 33.546170 s, e02 PASS +canonical e02/reference single-screen speedup: 4.0487x +canonical e02/e01 single-screen speedup: 1.8302x +``` + +The one-step initial energy and post-update trajectory-mean differences from +accepted e01 are `1.43e-6` and `7.53e-5`, passing the frozen `5e-5` and +`1e-4` physical thresholds. The canonical run passed every evaluator gate: +initial `-6.8462653160`, final history `-10.0280771255`, improvement +`3.1818118095`, final trajectory mean/std +`-10.0335464478 / 0.0000002666`, history length 100, required keys/shapes. + +Decision: `keep`. The exact feedback reduction removes a major trace, +path-search, contraction, and gradient burden. Proceed from e02 to isolate +whole-training scan. + +## Experiment `e03`: whole-training TensorCircuit scan + +Branch: `codex/orbitbreakers/task-07/e03-training-scan`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e03-training-scan`. + +Parent commit: `74d632d` (accepted e02 implementation and evidence). + +### Hypothesis + +Carrying parameters and the Optax state through `K.jaxy_scan` for exactly 100 +iterations and emitting each pre-update value preserves the sequential Adam +trajectory while eliminating 100 Python-to-JAX dispatches. The expected gain +is small because e02's step is already cheap relative to compilation. + +### Pre-run frozen checks + +The public 50-step and canonical 100-step evaluators must both pass. Initial, +final-history, and post-update trajectory-mean energies must remain within +`5e-3` of accepted e02, allowing normal complex64 optimizer divergence but +not a changed objective. Retain only if the canonical screen is faster than +e02's 33.546170 seconds. + +### Result + +Candidate hypothesis commit: `8b977faa5a9eea4e4ead88e24f4193cbfbc66aa0`. + +Candidate SHA-256: +`767c82d6c0be9af2ee526d130afba3f6eb95d81d42efcbb7f62665a9753a3b2c`. + +Candidate diff SHA-256: +`5bffe6df6108a72656dfd56cdc9d4a39aeaaa0037e3545e3d4bb1a754d4229d3`. + +Sanitized record: `profiles/e03-training-scan-screen.json`. + +```text +max_steps=50: e02 31.299628 s, scan 34.916768 s, scan/e02 1.11556 +max_steps=100: e02 33.546170 s, scan 36.747307 s, scan/e02 1.09542 +``` + +Both scan runs passed every evaluator criterion. The canonical initial, +final-history, and final-trajectory-mean energies differ from e02 by +`6.68e-6`, `1.80e-3`, and `1.71e-3`, all within the frozen `5e-3` +physical threshold. + +Decision: `discard`. Staging the already optimized value/gradient/Adam body +inside a scan adds more control-flow compile cost than 100 cached-JIT Python +dispatches. Continue from accepted e02 without scan. + +## Experiment `e04a`: OMECo 1x1 path-search budget + +Branch: `codex/orbitbreakers/task-07/e04-omeco-1x1`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e04-omeco-1x1`. + +Parent commit: `945430e` (e02 restored after the rejected scan). + +### Hypothesis and frozen rule + +For e02's simplified low-depth graph, `TreeSA(ntrials=1,niters=1)` can reduce +timed path-search latency more than it increases compiled contraction work. +Screen `max_steps=1`; retain for a full 50/100-step validation only if it is +faster than e02's 29.918828-second one-step screen and the initial/post-update +energies remain within `1e-4`. + +### Result + +Candidate hypothesis commit: `1eb52b206dacd848dd8efae29473415c1e37d3b0`. + +Candidate SHA-256: +`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. + +Candidate diff SHA-256: +`673f016863a7b777669c83dc399753004ebb19e8bc6f49003259699666d438d3`. + +Sanitized record: `profiles/e04a-omeco-1x1-screen.json`. + +```text +max_steps=1: e02/32x32 29.918828 s, 1x1 20.672377 s +max_steps=50: reference 91.540316 s, 1x1 21.473078 s, PASS +max_steps=100: reference 135.815605 s, e02/32x32 33.546170 s, + 1x1 24.362414 s, PASS +canonical 1x1/reference single-screen speedup: 5.5757x +``` + +Initial and one-step post-update trajectory-mean differences from e02 are +`4.77e-7` and `5.19e-5`, within the frozen `1e-4` rule. The canonical run +passes with final history `-10.0276298523`, improvement `3.1813645363`, and +final trajectory mean/std `-10.0331916809 / 0.0014021704`. + +Decision: `keep`. For the simplified graph, TreeSA 1x1 finds an adequate +repeated contraction path while saving most of the timed search latency. + +## Experiment `e04b`: TensorNetwork greedy contractor + +Branch: `codex/orbitbreakers/task-07/e04-greedy`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e04-greedy`. + +Parent commit: `945430e`. + +### Hypothesis and frozen rule + +The built-in greedy contractor may eliminate nearly all path-search latency. +Retain only if its one-step screen is faster than OMECo-1x1's +`20.672377` seconds and energies remain within `1e-4`. + +### Result + +Candidate hypothesis commit: `834de2a4f8e06b23cc9555b7fee4c25ff843a053`. + +Candidate SHA-256: +`96e2cd89224867352de887bec17058c43deb798a2e8200df670854a8538c3eda`. + +Candidate diff SHA-256: +`080396317aee29749b4c075b18778756af94b6621f1c52c9daaba270575eddd1`. + +Sanitized record: `profiles/e04b-greedy-screen.json`. + +The physical comparison passed, but greedy required 23.234316 seconds versus +OMECo-1x1's 20.672377 seconds. + +Decision: `discard` without 50/100-step runs; greedy is 12.39% slower at the +predeclared screen. + +## Experiment `e05`: joint TensorCircuit-state measurement rounds + +Branch: `codex/orbitbreakers/task-07/e05-batched-measurement-rounds`. + +Fresh hypothesis worktree: +`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e05-batched-measurement-rounds`. + +Parent commit: `e38891f` (accepted OMECo-1x1 plus greedy rejection evidence). + +### Hypothesis + +Before each eight-ancilla measurement round, one TensorCircuit `c.state()` +contains the exact joint ancilla distribution. Sequentially condition that +distribution with the same eight fixed uniforms and strict +`status > p0` rule used by TensorCircuit `_unitary_kraus_template`, select and +normalize the corresponding TensorCircuit state column, and continue the +adaptive circuit from that collapsed state. This replaces eight separately +contracted `cond_measure` probability networks per layer with one +TensorCircuit state contraction while preserving the exact projective +measurement law, bit order, fixed uniforms, feedback branches, and central +TensorCircuit gate/state computation. + +### Frozen policy and numerical checks + +This is explicitly a higher-risk framework-native restructuring: JAX is used +only to condition probabilities and select a column of a state computed by +TensorCircuit; all quantum state evolution, gates, and Hamiltonian evaluation +remain TensorCircuit APIs. Screen one step first. Initial and post-update +trajectory-mean energies must be within `5e-3` of accepted e04a, all outputs +must be finite, and memory must remain below 7 GiB. Continue to 50/100 steps +only if the one-step runtime is below 20.672377 seconds. Retain only if both +public workloads pass and canonical runtime is below 24.362414 seconds. + +### Result + +Candidate hypothesis commit: `5c4f0ba61509625c4c2bf76bcb3e21adf9fc09c9`. + +Candidate SHA-256: +`5f4ec8d45e1fa91c053f3ed2027c90bdb1abf1e9e7d87add399c6c5ce883add7`. + +Candidate diff SHA-256: +`d4a0277c7c1184b22be90dc51215a63690b39cb23871d9fcd3d6d6818aafd64b`. + +Sanitized record: `profiles/e05-measurement-round-screen.json`. + +```text +max_steps=1: e04a 20.672377 s, e05 4.606171 s +max_steps=50: reference 91.540316 s, e04a 21.473078 s, + e05 14.522625 s, e05 PASS +max_steps=100: reference 135.815605 s, e04a 24.362414 s, + e05 26.530668 s, e05 PASS +``` + +All physical checks and both public workloads pass. The canonical result is +especially close to the immutable expert: final history +`-10.0279579163` versus `-10.0279636383`, with improvement +`3.1816935539` and final trajectory mean/std +`-10.0334491730 / 0.0000033379`. + +Decision: `discard for the canonical metric`. Joint measurement rounds cut +the fixed trace/path cost by 16 seconds and dominate at 1/50 updates, but +materializing and differentiating full 16-qubit states makes each update +roughly 0.20 seconds slower. At 100 updates it is 8.90% slower than accepted +e04a. Preserve it as a valuable scaling crossover insight, not the final +candidate. + +## Experiment `e06`: TensorCircuit vectorized value-and-gradient + +Branch: `codex/orbitbreakers/task-07/e06-vvag`. + +Parent commit: `f8da3bb`. + +Hypothesis: `K.vvag` may generate a better batched-trajectory AD program than +differentiating through the mapped mean. Retain only if its one-step runtime +beats e04a's 20.672377 seconds with physical outputs within `1e-4`. + +Candidate commit: `828e921ddf69709054d5fa52a5e3e62d9fac475e`; +source SHA-256 +`4f0a8757af372c41db677981f1551c363f82f128e0f295073228defece065c68`; +diff SHA-256 +`82e90bad5bb428a53d623e268808a22a1ca321a686540f8e7c8ea5b46a15d7fa`. + +Sanitized record: `profiles/e06-vvag-screen.json`. + +Result: physical outputs pass, but one step takes 39.419801 seconds, +1.90687x e04a. Decision: `discard` without longer runs. Mapping individual +value-and-gradient programs duplicates reverse-mode structure for this +shared-parameter objective. + +## Frozen final candidate and paired run + +Final candidate: accepted e04a source +`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. + +No candidate tuning follows this freeze. The final command is: + +```bash +python -u research/task-07/run_docker_matrix.py \ + --repeat 6 --max-steps 100 --timeout 300 --cpus 6 --memory 7g \ + --output results/task-07-final-canonical-6-pairs +``` + +It stages immutable source snapshots, uses one no-network container and fresh +evaluator processes, alternates pair order, and applies the survey's frozen +Student-t promotion rule. + +## Final paired result + +Date: 2026-07-29. + +Candidate SHA-256: +`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. + +Staging snapshot SHA-256: +`e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44`. + +Container: `orbit-task07-matrix-34ea5ae79e` +(ID prefix `b8199b0e1e6a`), six CPUs, 7 GiB, no network. + +Sanitized paired report: +`profiles/final-canonical-six-pairs.json` +(`sha256:6e03db1f37e8bbe0b38247f017d9259177a2858d54289fa2a5615542b499b54a`). + +Fail-closed reference report: +`profiles/final-reference-six.json` +(`sha256:743f493120dd89e6c75a309499c28d819ae00aee09d57e7feb374b35c0310224`). + +```text +terminal_status: SUCCESS x 12 +valid cells: 12/12 +passing pairs: 6/6 +candidate wins: 6/6 + +reference runtimes: +106.038165, 119.427967, 123.188182, +107.532991, 110.084619, 131.316223 + +candidate runtimes: +24.481295, 24.221592, 24.716431, +24.421997, 31.684172, 27.652166 + +reference mean / median / stderr: +116.264691 / 114.756293 / 4.096777 s + +candidate mean / median / stderr: +26.196276 / 24.598863 / 1.216760 s + +ratio-of-means speedup: 4.438215x +ratio-of-means improvement: 77.4684% +mean paired speedup: 4.478752x +paired speedup stderr: 0.228662x +95% Student-t CI: [3.890959x, 5.066545x] +``` + +Decision: `promote`. Every cell passes, mean and median are lower, all six +pairs win, and the frozen confidence lower bound is above 1.0. + +### Final report serialization failure and recovery + +After cell 12 passed and the shared container stopped, the runner raised a +`NameError` while constructing the final JSON because two Python booleans +were written as lowercase `true`. All 24 raw stdout/stderr logs already +existed; stderr logs were empty and every stdout contained `Overall: PASS`. +No benchmark cell was rerun or filtered. The sanitized reports above were +reconstructed from all raw logs, with every stdout hash retained. + +The runner is corrected to use `True` and now writes a checkpoint after each +cell. `research/check_gates.py --task 07 --baseline-report +research/task-07/profiles/final-reference-six.json` returns +`promotion_ready: true`. + +## Experiment `e07`: exact classical-ancilla reduction + +Branch: `codex/orbitbreakers/task-07/e07-classical-ancilla`. + +Parent commit: `529a5c5` (the published e04a implementation and six-pair +evidence). + +### Structural derivation + +This experiment follows a user-supplied concern that the apparent +measurement-feedback workload may contain an unintended exact reduction. +The eight ancillas enter each layer as a computational-basis product state. +Their `RY` gates create independent Bernoulli source bits. Each following +data-ancilla `RZZ` is diagonal and applies a norm-preserving data unitary +conditioned on its source bit, so it cannot change the ancilla Z-basis +probabilities. The ordered ancilla CNOT ladder is only the reversible map + +```text +measured[0] = source[0] +measured[i] = source[0] xor ... xor source[i]. +``` + +Its inverse is +`source[0] = measured[0]` and +`source[i] = measured[i] xor measured[i-1]`. +Conditioning on one measured string therefore selects one unique source +string and an eight-qubit data-only circuit. The pre-measurement entangler +becomes `RZ((1-2*source) theta_entangler)` on data; measured feedback becomes +`RZ((1-2*measured) theta_feedback[measured])`. They commute and combine into +one data `RZ`. + +For an ancilla entering as previous measured bit `b`, the next independent +source probability is + +```text +P(source=1 | b=0) = sin(theta/2)^2 +P(source=1 | b=1) = cos(theta/2)^2. +``` + +The implementation reconstructs TensorCircuit's strict +`status > 1-P(bit=1)` sampling rule, maps the fixed seed-2048 uniforms to +complete two-layer patterns, and deduplicates equal patterns before quantum +evaluation. + +### Independent audit + +Audit program: +`validate_classical_ancilla_reduction.py` +(`sha256:86e30424397d816be4db109a5eb64013de152db25477aba15bff7d7db44c4d3e`). + +Sanitized record: +`profiles/e07-classical-ancilla-audit.json` +(`sha256:f371e2429a3a5724583db82eb6a45089e4040c4e699b7db3d51a50035ad126c3`). + +All 1,024 measured bits produced by the analytic sampler are identical to +the full 16-qubit TensorCircuit `cond_measure` implementation. The 64 fixed +trajectories contain only two distinct complete patterns: the all-zero +pattern occurs 63 times and trajectory 36 supplies the sole rare pattern. + +Against the accepted full 16-qubit e04a implementation: + +```text +initial energy absolute error: 4.7684e-6 +trajectory energy maximum error: 4.2915e-6 +full ancilla-gradient maximum magnitude:4.6559e-7 +reduced ancilla-gradient magnitude: 0 +non-ancilla gradient maximum error: 1.5116e-6 +post-one-update energy error: 4.6730e-5 +audit passed: true +``` + +The ideal pathwise derivative of a fixed discrete branch with respect to +the ancilla sampling angle is exactly zero. The full complex64 graph produces +only sub-micro numerical residue there; Adam can amplify that residue into +a parameter-coordinate difference, but the corresponding physical energy +checks remain close. This distinction is disclosed rather than hidden. + +### Exploratory evaluator screens + +These screens were exploratory and occurred before a final candidate freeze; +they are not the promotional paired measurement. + +Candidate source SHA-256: +`29d4d94101c21d757f57f3c639752533bfb84feb8acae5a8b2659a40e0f78631`. + +```text +max_steps=50: 3.008539 s, PASS + initial/final history: -6.8462691307 / -8.7942304611 +max_steps=100: 2.998158 s, PASS + initial/final history: -6.8462700844 / -10.0277271271 + final trajectory mean/std: -10.0331859589 / 0.0007448916 +``` + +Decision: `keep provisionally`. The canonical screen is about 8.1x faster +than e04a's 24.362-second screen and about 45.3x faster than the original +expert's 135.816-second bootstrap. Because compilation now dominates and +50 versus 100 updates costs almost the same, isolate a whole-training scan +and small-circuit gate/contractor choices before freezing a new paired run. + +### Scope and policy caveat + +This is an exact reduction of the public fixed workload, not hard-coded +energies or fewer requested trajectories. All 64 statuses are consumed, all +96 parameters retain their original layout, all trajectory outputs are +reconstructed, and TensorCircuit performs every remaining quantum evolution +and Hamiltonian expectation. It nevertheless removes the explicit +16-qubit/mid-circuit-measurement execution that the task prose may have +intended to benchmark. The final report must present this openly as a +challenge-design loophole and keep the conservative e04a implementation +available if maintainers require literal `cond_measure` use. + +## Post-reduction experiment sweep + +All variants below start from the provisionally accepted e07 reduction and +retain the 64-to-2 exact pattern map. + +### `e08`: whole-training `K.jaxy_scan` + +Candidate commit: `7c9476a`. +Source SHA-256: +`a6a9c882edabbf88bdb175d5cf7dd4b39bf09f923c373a939929380a616b7376`. + +Canonical screen: `3.205596 s`, PASS, versus the e07 exploratory +`2.998158 s`. Final-history energy differs by `1.53e-5`. + +Decision: `discard`. Even after the dimensional collapse, staging the +100-update control flow costs more than the cached Python dispatches it +removes. + +### `e09`: fuse pre-CNOT `RY` and reduced `RZ` + +Candidate commit: `7d0fd29`. +Source SHA-256: +`96c0ca51d49fa334758e8c60985062250aae6f3f516b5c42aaed3eb26adbe754`. + +The exact product `RZ(z) RY(y)` was emitted as a differentiable +TensorCircuit `any` gate. Canonical screen: `3.530851 s`, PASS. + +Decision: `discard`. TensorCircuit's contraction preprocessing already +handles the neighboring one-qubit gates more cheaply than explicitly +constructing the parameterized dense matrix. + +### `e10`-`e13`: contractor selection + +Single canonical screens: + +| Variant | Runtime (s) | Result | +| --- | ---: | --- | +| e10 `greedy` | 2.910894 | PASS | +| e11 `plain-experimental`, default local steps 2 | 2.921477 | PASS | +| e12 `plain-experimental`, local steps 1 | 3.100929 | PASS | +| e13 `plain-experimental`, local steps 3 | 2.822912 | PASS | + +Because greedy, OMECo-1x1, and the default local contractor differed by only +tenths of a second, e11 was selected through counterbalanced six-pair +screens rather than a single timing. Sanitized record: +`profiles/e11-contractor-six-pair-screen.json`. + +```text +greedy mean: 2.947290 s +plain-experimental mean: 2.823417 s +plain wins: 6/6 +mean paired speedup: 1.044198x +95% Student-t CI: [1.002914x, 1.085481x] + +OMECo-1x1 mean: 2.949023 s +plain-experimental mean: 2.839041 s +plain wins: 5/6 +mean paired speedup: 1.039493x +95% Student-t CI: [0.993346x, 1.085640x] +``` + +An earlier attempt mounted a comparison worktree from `/private/tmp`; Docker +turned the unavailable file mount into a directory and every greedy cell +failed before evaluator execution. Those values are explicitly excluded and +the complete six-pair screen was rerun from a Docker-visible workspace. + +Decision: `keep e11`. The exact reduced graph is small enough that +TensorCircuit's native local contractor avoids global path-search overhead. +Local-step values 1 and 3 do not provide sufficient repeat evidence to +supplant the stable default of 2. + +## Frozen e11 candidate for new expert comparison + +Candidate source SHA-256: +`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. + +The final comparison will use six canonical matched pairs, alternating the +immutable human expert and e11 in one no-network container with six CPUs, +7 GiB, the same evaluator and latest repository TensorCircuit image. No +candidate tuning follows this freeze. + +## Final e11 six-pair expert comparison + +Date: 2026-07-29. + +Candidate implementation commit: `b7d34dd`. + +Candidate SHA-256: +`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. + +Staging snapshot SHA-256: +`d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f`. + +Docker image: +`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` +(TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`). + +Sanitized paired report: +`profiles/e11-final-canonical-six-pairs.json` +(`sha256:068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f`). + +```text +terminal_status: SUCCESS x 12 +valid cells: 12/12 +passing pairs: 6/6 +candidate wins: 6/6 + +reference runtimes: +123.286060, 126.247088, 150.224728, +129.913867, 159.579514, 151.207388 + +candidate runtimes: +3.062554, 3.311737, 2.989908, +3.030923, 3.063330, 2.966582 + +reference mean / median / stderr: +140.076441 / 140.069298 / 6.281458 s + +candidate mean / median / stderr: +3.070839 / 3.046739 / 0.050718 s + +ratio-of-means speedup: 45.615039x +ratio-of-means improvement: 97.8077% +mean paired speedup: 45.757921x +paired speedup stderr: 2.479287x +95% Student-t CI: [39.384711x, 52.131131x] +``` + +Decision: `promote under the executable contract`. Every cell passes, every +pair wins, and the frozen confidence lower bound is far above 1.0. The +separate challenge-design report marks the semantic caveat: this exact +reduction should not be represented as a generic acceleration of +mid-circuit measurement, and maintainers may prefer the conservative e04a +implementation if literal 16-qubit `cond_measure` execution is the intended +policy. diff --git a/optimized_solutions/challenge-07/research/README.md b/optimized_solutions/challenge-07/research/README.md new file mode 100644 index 0000000..21e8edd --- /dev/null +++ b/optimized_solutions/challenge-07/research/README.md @@ -0,0 +1,15 @@ +# Benchmark evidence mirror + +This directory mirrors the final reviewed Task 07 research record from +[`hmyuuu/OrbitBreakersExpertBenchmarks#11`](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11), +using Benchmark `main` at `7e2298b`. + +`CLASSICAL_ANCILLA_REDUCTION_REPORT.md` contains the full six-pair result and +challenge-design analysis; `IMPLEMENTATION_COMPARISON.md` records the +conservative literal-ancilla campaign; `profiles/` contains the sanitized +machine-readable ablations and paired timings. The concise maintainer-facing +report remains one directory above as `CLASSICAL_ANCILLA_REDUCTION.md`. + +Both the canonical ORBIT-Q task and its human expert remain unchanged. +Benchmark-harness reproduction commands in these records should be run in the +Benchmark repository pinned above. diff --git a/optimized_solutions/challenge-07/research/SURVEY.md b/optimized_solutions/challenge-07/research/SURVEY.md new file mode 100644 index 0000000..15921bc --- /dev/null +++ b/optimized_solutions/challenge-07/research/SURVEY.md @@ -0,0 +1,216 @@ +# ORBIT-Q Task 07 Runtime Optimization Survey + +**Status: READY** + +Campaign task: `task-07` + +Survey freeze: `2026-07-29T00:04:56Z` + +Reference commit: `5af98f27b9404c513df8eee0f4568b1512edee19` + +This campaign covers only Task 07. The survey, immutable expert, public +workloads, hypotheses, and measurement rule are frozen before the first +candidate edit. + +## Evidence and claim boundary + +The immutable human expert is `references/task-07/solution_7.py` +(`sha256:ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3`). +The public contract and evaluator are `tasks/task-07/problem.md` +(`sha256:e267f59cdda3d7602ecfdde1a45cb3981e39d52a4bae2f87b4dbb375bcab9680`) +and `tasks/task-07/evaluator/evaluate_7.py` +(`sha256:69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31`). + +The historical ORBIT-Q table records 63.8 seconds for Task 07 without a +matched host or environment, and the repository's 2026-07-27 shared-container +bootstrap measured two byte-identical reference cells at +109.332 +/- 0.081 seconds on an eight-CPU/9-GiB allocation. Those values are +context only. No external publication reports this exact evaluator, circuit, +trajectory batch, seed, optimizer trajectory, hardware, and software stack. +This campaign may therefore claim only a paired gain over the bundled expert, +not a global SOTA result. + +The problem text contains an internal typo: its displayed objective divides +128 trajectories by 128, while the fixed configuration, interface, evaluator, +and expert all use 64 trajectories and `K.mean`. The executable public +contract is unambiguous. Every candidate must preserve the expert/evaluator's +64-trajectory mean and must not exploit the prose inconsistency. + +## Inspected environment and framework paths + +Measurements use Docker image +`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` +with six CPUs, 7 GiB memory, no network, and fresh evaluator processes. The +tracked dependency lock is `envs/tensorcircuit-py311/requirements.lock` +(`sha256:cd5ac5cb2102ea7b40bd46dc81320cc59e0ce0671ab88c597f81d82b384a824b`). +Per maintainer direction, this campaign uses the image's latest installed +TensorCircuit-NG and does not downgrade it. + +| Component | Version | Inspected path / symbol | +| --- | --- | --- | +| TensorCircuit-NG | `1.8.0.dev20260726` | `Circuit.cond_measure`, `conditional_gate`, `state`, and `wavefunction` in `tensorcircuit/circuit.py` (`sha256:5c4d569325369d957dc60bbeca8a581508549ff9813a7a163de61a6294864662`) and `tensorcircuit/basecircuit.py` (`sha256:2f47be7f215c73bfbc41788661b0dd86a77054503f63e7bfbb6c4d2a84004e98`) | +| TensorCircuit measurement templates | same package | `operator_expectation` / `sparse_expectation` in `tensorcircuit/templates/measurements.py` (`sha256:7a69043bd81745254ab106f3cdd0911720fdb91e0be70b784f86c96fbcfaa615`) | +| TensorCircuit sparse operators | same package | `PauliStringSum2COO` in `tensorcircuit/quantum.py` (`sha256:fcaee21ba5ccde1b89c46e2f5424c48d342e3bfaedf72adba672ab6bd4ded703`) | +| JAX / JAXLIB | `0.10.0` / `0.10.0` | `jit`, `vmap`, reverse-mode AD, and `lax.scan`, wrapped by `tensorcircuit/backends/jax_backend.py` (`sha256:88657aebf8e5d566ac4e653abe327083da0253f02a3a297a134b871ffe4baab9`) | +| Optax | `0.2.8` | `optax.adam(0.02)` and `apply_updates` | +| OMECo | `0.2.0` | `TreeSA` contractor shortcuts; the expert requests `omeco-32-32` | +| TensorNetwork-NG | `0.5.1` | TensorCircuit node graph and contraction execution | +| Quimb | `1.11.1` | OMECo path-search support | + +TensorCircuit's [measurement documentation](https://tensorcircuit.readthedocs.io/en/stable/faq.html) +states that `cond_measure` performs a normalized Z-basis collapse and returns +a jittable integer tensor, while `conditional_gate` applies a gate selected by +that outcome. Its [Pauli-sum tutorial](https://tensorcircuit.readthedocs.io/en/latest/whitepaper/6-2-pauli-string-expectation.html) +documents both repeated `expectation_ps` evaluation and a single sparse +Hamiltonian `operator_expectation`. The +[TensorCircuit paper](https://quantum-journal.org/papers/q-2023-02-02-912/) +describes the framework's tensor-network, AD, JIT, and vectorization model. +JAX documents `scan` as a single lowered loop for a fixed iteration count in +the [official API](https://docs.jax.dev/en/latest/_autosummary/jax.lax.scan.html), +and its [benchmarking guide](https://docs.jax.dev/en/latest/benchmarking.html) +requires synchronization or host conversion when measuring asynchronous +work. OMECo documents `TreeSA` as a simulated-annealing contraction-order +optimizer in its [public API](https://docs.rs/omeco/latest/omeco/). + +## Task 07: measurement-feedback TFIM VQE + +### Required algorithm and output + +The expert optimizes a 16-qubit, two-layer adaptive circuit. Eight data qubits +and eight ancillas receive trainable `RY` rotations, pairwise `RZZ` +entanglers, and fixed CNOT ladders. Each layer measures all eight ancillas +with fixed per-trajectory uniforms, applies one of two trainable feedback +`RZZ` gates per pair, then applies a data CNOT ladder and trainable `RZ` +rotations. Sixty-four fixed measurement trajectories are mapped with +`K.vmap`, averaged, differentiated, and optimized through exactly 100 +sequential Adam updates. + +Each trajectory returns the expectation of the open-boundary eight-site TFIM + +`H = -sum_i Z_i Z_(i+1) - 1.05 sum_i X_i`. + +The solution must return a NumPy `energy_history` of shape `(100,)` containing +pre-update trajectory means and `final_trajectory_energies` of shape `(64,)` +for the same fixed uniforms after the final update. + +### Dominant work and measured bottleneck + +The expert evaluates every trajectory energy as 15 separate +`Circuit.expectation_ps` calls: seven `ZZ` terms and eight `X` terms. Each +call constructs and contracts a bra/ket tensor network, so the same final +adaptive circuit is effectively contracted 15 times in both the forward and +reverse passes. The final post-training trajectory evaluation repeats the +same pattern. + +The immutable expert passes the canonical evaluator in 135.815605 seconds in +the fixed six-CPU container. One update takes 47.853128 seconds end to end, +while 10, 20, 32, and 50 updates take 51.638506, 60.074862, 69.596274, and +91.540316 seconds. Thus roughly 48 seconds is trace/compile/path/finalization +cost, and the remaining 99 canonical updates add about 0.89 seconds each. +Removing Python dispatch alone cannot produce a large gain; the repeated +energy contractions and their gradients are the primary target. + +`conditional_gate` also materializes a differentiable dense two-qubit tensor +by one-hot selecting from two `RZZ` gate tensors. After a Z measurement the +ancilla is a computational-basis eigenstate, so this generic representation +retains a two-qubit node even though the gate's action on the data is a +one-qubit phase rotation. + +Contraction-path search is inside the timed first trace. The expert chooses +OMECo `TreeSA(ntrials=32,niters=32)`. Contraction-order research establishes +that path choice can substantially change tensor-network work, while better +search also costs more; contractor budget therefore needs end-to-end +measurement rather than FLOP estimates alone. See Schindler and Jermyn, +[Algorithms for Tensor Network Contraction Ordering](https://arxiv.org/abs/2001.08063). + +### Exact structural opportunities + +At the end of a trajectory, every ancilla was just Z-measured and is touched +only by a diagonal feedback `RZZ`; therefore the final state factorizes as +`|psi_data> tensor |measured_ancilla_bitstring>`. A single TensorCircuit +`c.state()` contraction can be reshaped into `(2^8, 2^8)` and reduced along +the ancilla basis axis to obtain the normalized data state. Feeding that +state to an eight-qubit `tc.Circuit` and TensorCircuit's native sparse +`operator_expectation` evaluates all 15 TFIM terms after one circuit-state +contraction. + +For a measured bit `b`, the feedback identity is exact: + +`RZZ(theta_b) (|b> tensor |psi>) = + |b> tensor RZ((1 - 2 b) theta_b) |psi>`. + +Replacing the generic conditional two-qubit feedback with the corresponding +TensorCircuit `RZ` on the data qubit preserves the branch, measurement +probability, selected trainable angle, and gradient. It also remains valid +between layers because the feedback never changes the measured ancilla. + +### Candidate hypotheses frozen before editing + +Every candidate must preserve the seeded float32 initialization, all 96 +trainable parameters and their layout, 16 fixed measurement uniforms per +trajectory, normalized `cond_measure` semantics, 64 trajectories and their +order, two layers, exactly 100 Adam updates, pre-update history, final +post-update trajectory values, complex64 behavior, and TensorCircuit as the +central quantum computation. + +1. **e01—single native Hamiltonian evaluation.** Contract each final + trajectory once with `Circuit.state`, extract the factorized data state, + and evaluate a TensorCircuit-native sparse TFIM operator with + `templates.measurements.operator_expectation`. Expected value: high. + Validate energy, parameter gradient, one Adam update, and full history. +2. **e02—measured-ancilla feedback reduction.** Replace each selected + two-qubit `RZZ` after Z measurement with the exact selected/sign-adjusted + data `RZ`. Expected value: medium. Validate both branches and full + trajectory behavior independently before combining it with e01. +3. **e03—whole-training `K.jaxy_scan`.** Carry parameters and Optax state + through 100 updates and emit the same pre-update values. Expected value: + small to medium because it removes host dispatch but not quantum work. +4. **e04—contractor budget.** Compare the frozen best circuit under + OMECo 1x1, 4x4, 8x8, 16x16, and 32x32 or greedy where supported. + Path-search time and all repeated contractions must be measured together. +5. **e05—further state/measurement reuse.** Contract once before an + eight-ancilla measurement round and derive sequential conditional + probabilities from the TensorCircuit state, then reinitialize a + TensorCircuit circuit from the collapsed branch. Potential value: high, + but risk is also high because fixed-uniform sequential collapse and + framework-fidelity boundaries must remain exact. Pursue only after the + lower-risk native changes. + +The ideas are separate falsifiable hypotheses. No candidate implementation +was edited before this survey and dataset freeze. + +## Frozen measurement and promotion rule + +All eligible comparisons use one long-lived container with six CPUs and +7 GiB, the image ID above, no network, a 300-second per-cell cap, and a fresh +evaluator process per cell. Six matched pairs will be run, exceeding the +user's five-run requirement: + +- odd pairs: reference then candidate; +- even pairs: candidate then reference. + +Report every runtime, arithmetic mean, median, sample standard deviation, +standard error, minimum, maximum, ratio-of-means improvement, and each +pairwise speedup `S_i = R_i / C_i`. The primary confidence interval is the +two-sided 95% Student-t interval on the arithmetic mean of pairwise speedups: + +`mean(S) +/- t_(0.975,5) * sample_stdev(S) / sqrt(6)`, + +where `t_(0.975,5)=2.5705818366`. + +Promotion requires all 12 cells to pass, candidate mean and median below the +reference, at least five of six pair wins, and a confidence-interval lower +bound above 1.0. The canonical 100-step workload is the claim workload; the +public 50-step passing workload is only for screening and robustness. + +## Open evidence gaps + +- No matched external implementation/hardware runtime exists for this exact + adaptive VQE evaluator. +- Peak intermediate memory and contractor-estimated FLOPs are not yet + recorded. +- The current full canonical expert result is one bootstrap run; six + counterbalanced reference cells will be collected only against the frozen + winning candidate. +- Results will apply only to the fixed eight-data/eight-ancilla, + two-layer/64-trajectory workload on this host; no scaling claim is planned. diff --git a/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json b/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json new file mode 100644 index 0000000..10abaaf --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json @@ -0,0 +1,78 @@ +{ + "schema_version": 1, + "task_id": "07", + "generated_at_utc": "2026-07-29T00:04:56Z", + "classification": "immutable expert bootstrap and update-count profile", + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "environment": { + "image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "tensorcircuit_ng": "1.8.0.dev20260726", + "jax": "0.10.0", + "jaxlib": "0.10.0", + "cpus": 6, + "memory": "7 GiB", + "network": "none", + "host_fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" + }, + "results": [ + { + "max_steps": 1, + "runtime_sec": 47.853128, + "initial_energy": -6.8462719917, + "final_history_energy": -6.8462719917, + "final_trajectory_mean": -6.9686288834, + "final_trajectory_std": 0.0004866889, + "passed": false, + "failure_reason": "minimum improvement and target thresholds" + }, + { + "max_steps": 10, + "runtime_sec": 51.638506, + "initial_energy": -6.8462643623, + "final_history_energy": -7.4798407555, + "final_trajectory_mean": -7.5244884491, + "final_trajectory_std": 0.004178, + "passed": false, + "failure_reason": "target final energy threshold" + }, + { + "max_steps": 20, + "runtime_sec": 60.074862, + "initial_energy": -6.8462643623, + "final_history_energy": -7.8647251129, + "passed": false, + "failure_reason": "target final energy threshold" + }, + { + "max_steps": 32, + "runtime_sec": 69.596274, + "initial_energy": -6.8462643623, + "final_history_energy": -8.1460399628, + "passed": false, + "failure_reason": "target final energy threshold" + }, + { + "max_steps": 50, + "runtime_sec": 91.540316, + "initial_energy": -6.8462719917, + "final_history_energy": -8.7927856445, + "improvement": 1.9465136528, + "final_trajectory_mean": -8.8296632767, + "final_trajectory_std": 0.003031878, + "history_length": 50, + "passed": true + }, + { + "max_steps": 100, + "runtime_sec": 135.815605, + "initial_energy": -6.8462643623, + "final_history_energy": -10.0279636383, + "improvement": 3.181699276, + "final_trajectory_mean": -10.0333871841, + "final_trajectory_std": 0.0, + "history_length": 100, + "passed": true + } + ] +} diff --git a/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json b/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json new file mode 100644 index 0000000..9606a47 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json @@ -0,0 +1,73 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e01", + "candidate_commit": "1e21dd41f47e3beb84b937144324227eac544b6d", + "candidate_sha256": "30f0f45073e866c7fbb24cd9a5c33d8c1254e6985136937cd454b82990681678", + "candidate_diff_sha256": "3396c6b65d3f6c2eaebc647d6251547dd6561d1defac4526f9f503b2dcac8b7e", + "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "cpus": 6, + "memory": "7 GiB", + "performance_screens": [ + { + "max_steps": 1, + "reference_runtime_sec": 47.853128, + "candidate_runtime_sec": 44.91711, + "reference_initial_energy": -6.8462719917, + "candidate_initial_energy": -6.8462643623, + "reference_post_update_trajectory_mean": -6.9686288834, + "candidate_post_update_trajectory_mean": -6.9686059952, + "expected_threshold_failure": true + }, + { + "max_steps": 10, + "reference_runtime_sec": 51.638506, + "candidate_runtime_sec": 46.100052, + "reference_final_history_energy": -7.4798407555, + "candidate_final_history_energy": -7.479578495, + "expected_threshold_failure": true + }, + { + "max_steps": 50, + "reference_runtime_sec": 91.540316, + "candidate_runtime_sec": 52.769482, + "screen_speedup": 1.73434, + "reference_final_history_energy": -8.7927856445, + "candidate_final_history_energy": -8.7949237823, + "reference_post_update_trajectory_mean": -8.8296632767, + "candidate_post_update_trajectory_mean": -8.8320827484, + "reference_passed": true, + "candidate_passed": true + }, + { + "max_steps": 100, + "reference_runtime_sec": 135.815605, + "candidate_runtime_sec": 61.396553, + "screen_speedup": 2.2121, + "reference_final_history_energy": -10.0279636383, + "candidate_final_history_energy": -10.0263500214, + "reference_post_update_trajectory_mean": -10.0333871841, + "candidate_post_update_trajectory_mean": -10.0319023132, + "reference_passed": true, + "candidate_passed": true + } + ], + "one_trajectory_equivalence": { + "tolerances": { + "energy_abs": 5e-05, + "gradient_max_abs": 0.0005, + "adam_parameter_max_abs": 2e-05 + }, + "reference_energy": -6.846258640289307, + "candidate_energy": -6.846261978149414, + "energy_abs_error": 3.337860107421875e-06, + "gradient_max_abs_error": 1.0132789611816406e-06, + "gradient_mean_abs_error": 2.6805633979165577e-07, + "adam_parameter_max_abs_error": 0.031341224908828735, + "adam_parameter_mean_abs_error": 0.002425061771646142, + "energy_check": true, + "gradient_check": true, + "strict_parameter_check": false + }, + "decision": "keep provisionally; exact quantum identity and physical output checks pass, while a predeclared strict first-Adam parameter metric is retained as a failed diagnostic because elementwise Adam normalization amplifies near-zero complex64 gradient sign changes" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json b/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json new file mode 100644 index 0000000..df2c7ab --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json @@ -0,0 +1,62 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e02", + "candidate_commit": "067a1d365e8ef4a9e3f81d6dd62939c0b3af6b39", + "candidate_sha256": "b3dcbaa35a233d8dde4576de7257c79a1a81034eee49f1f0bef6489116dcafcd", + "candidate_diff_sha256": "759b7139a8463d53c80f2d48148eca189235a872fac5402ae9f64be4100bac45", + "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "cpus": 6, + "memory": "7 GiB", + "identity_audit": { + "dtype": "complex64", + "tolerance": 1e-07, + "cases": [ + {"bit": 0, "theta": -0.37, "max_abs_error": 0.0}, + {"bit": 0, "theta": 1.23, "max_abs_error": 2.9802322387695312e-08}, + {"bit": 1, "theta": -0.37, "max_abs_error": 0.0}, + {"bit": 1, "theta": 1.23, "max_abs_error": 0.0} + ], + "max_abs_error": 2.9802322387695312e-08, + "passed": true + }, + "performance_screens": [ + { + "max_steps": 1, + "accepted_e01_runtime_sec": 44.91711, + "candidate_runtime_sec": 29.918828, + "accepted_e01_initial_energy": -6.8462643623, + "candidate_initial_energy": -6.8462657928, + "initial_energy_abs_error": 1.4305e-06, + "accepted_e01_post_update_trajectory_mean": -6.9686059952, + "candidate_post_update_trajectory_mean": -6.9686813354, + "post_update_mean_abs_error": 7.53402e-05, + "physical_checks_passed": true + }, + { + "max_steps": 50, + "reference_runtime_sec": 91.540316, + "accepted_e01_runtime_sec": 52.769482, + "candidate_runtime_sec": 31.299628, + "speedup_over_reference": 2.92465, + "candidate_final_history_energy": -8.7978668213, + "candidate_post_update_trajectory_mean": -8.8353881836, + "candidate_passed": true + }, + { + "max_steps": 100, + "reference_runtime_sec": 135.815605, + "accepted_e01_runtime_sec": 61.396553, + "candidate_runtime_sec": 33.54617, + "speedup_over_reference": 4.0487, + "speedup_over_e01": 1.83023, + "candidate_initial_energy": -6.846265316, + "candidate_final_history_energy": -10.0280771255, + "candidate_improvement": 3.1818118095, + "candidate_post_update_trajectory_mean": -10.0335464478, + "candidate_post_update_trajectory_std": 2.666e-07, + "candidate_passed": true + } + ], + "decision": "keep; exact branch identity and all predeclared physical/public checks pass, with a 4.0487x canonical single-screen speedup over the immutable reference" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json b/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json new file mode 100644 index 0000000..00cad40 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json @@ -0,0 +1,35 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e03", + "candidate_commit": "8b977faa5a9eea4e4ead88e24f4193cbfbc66aa0", + "candidate_sha256": "767c82d6c0be9af2ee526d130afba3f6eb95d81d42efcbb7f62665a9753a3b2c", + "candidate_diff_sha256": "5bffe6df6108a72656dfd56cdc9d4a39aeaaa0037e3545e3d4bb1a754d4229d3", + "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "cpus": 6, + "memory": "7 GiB", + "screens": [ + { + "max_steps": 50, + "accepted_e02_runtime_sec": 31.299628, + "candidate_runtime_sec": 34.916768, + "candidate_over_e02_ratio": 1.11556, + "candidate_final_history_energy": -8.7939605713, + "candidate_post_update_trajectory_mean": -8.8310813904, + "candidate_passed": true + }, + { + "max_steps": 100, + "accepted_e02_runtime_sec": 33.54617, + "candidate_runtime_sec": 36.747307, + "candidate_over_e02_ratio": 1.09542, + "candidate_initial_energy": -6.8462719917, + "candidate_final_history_energy": -10.0262737274, + "candidate_improvement": 3.1800017357, + "candidate_post_update_trajectory_mean": -10.031832695, + "candidate_post_update_trajectory_std": 0.0054257438, + "candidate_passed": true + } + ], + "decision": "discard; all semantic gates pass but scan is 9.54% slower on the canonical screen because added control-flow compile cost exceeds 100 host dispatches" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json b/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json new file mode 100644 index 0000000..3eb3d28 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e04a", + "candidate_commit": "1eb52b206dacd848dd8efae29473415c1e37d3b0", + "candidate_sha256": "0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592", + "candidate_diff_sha256": "673f016863a7b777669c83dc399753004ebb19e8bc6f49003259699666d438d3", + "contractor": "omeco-1-1", + "screens": [ + { + "max_steps": 1, + "accepted_e02_runtime_sec": 29.918828, + "candidate_runtime_sec": 20.672377, + "candidate_initial_energy": -6.846265316, + "candidate_post_update_trajectory_mean": -6.9686279297 + }, + { + "max_steps": 50, + "reference_runtime_sec": 91.540316, + "candidate_runtime_sec": 21.473078, + "speedup_over_reference": 4.26394, + "candidate_final_history_energy": -8.7932806015, + "candidate_post_update_trajectory_mean": -8.8302116394, + "candidate_passed": true + }, + { + "max_steps": 100, + "reference_runtime_sec": 135.815605, + "accepted_e02_runtime_sec": 33.54617, + "candidate_runtime_sec": 24.362414, + "speedup_over_reference": 5.57573, + "speedup_over_e02": 1.37696, + "candidate_initial_energy": -6.846265316, + "candidate_final_history_energy": -10.0276298523, + "candidate_improvement": 3.1813645363, + "candidate_post_update_trajectory_mean": -10.0331916809, + "candidate_post_update_trajectory_std": 0.0014021704, + "candidate_passed": true + } + ], + "decision": "keep; all public checks pass and the low-budget path search cuts the canonical screen to 24.362414 seconds" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json b/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json new file mode 100644 index 0000000..0ce6c26 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json @@ -0,0 +1,19 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e04b", + "candidate_commit": "834de2a4f8e06b23cc9555b7fee4c25ff843a053", + "candidate_sha256": "96e2cd89224867352de887bec17058c43deb798a2e8200df670854a8538c3eda", + "candidate_diff_sha256": "080396317aee29749b4c075b18778756af94b6621f1c52c9daaba270575eddd1", + "contractor": "greedy", + "screen": { + "max_steps": 1, + "omeco_1x1_runtime_sec": 20.672377, + "candidate_runtime_sec": 23.234316, + "candidate_over_omeco_1x1_ratio": 1.12393, + "candidate_initial_energy": -6.8462648392, + "candidate_post_update_trajectory_mean": -6.9686841965, + "physical_outputs_within_tolerance": true + }, + "decision": "discard; greedy is 12.39% slower than OMECo 1x1 at the frozen one-step screen" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json b/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json new file mode 100644 index 0000000..a826b9e --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json @@ -0,0 +1,43 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e05", + "candidate_commit": "5c4f0ba61509625c4c2bf76bcb3e21adf9fc09c9", + "candidate_sha256": "5f4ec8d45e1fa91c053f3ed2027c90bdb1abf1e9e7d87add399c6c5ce883add7", + "candidate_diff_sha256": "d4a0277c7c1184b22be90dc51215a63690b39cb23871d9fcd3d6d6818aafd64b", + "screens": [ + { + "max_steps": 1, + "accepted_e04a_runtime_sec": 20.672377, + "candidate_runtime_sec": 4.606171, + "candidate_initial_energy": -6.8462643623, + "candidate_post_update_trajectory_mean": -6.9686303139, + "physical_outputs_within_tolerance": true + }, + { + "max_steps": 50, + "reference_runtime_sec": 91.540316, + "accepted_e04a_runtime_sec": 21.473078, + "candidate_runtime_sec": 14.522625, + "speedup_over_reference": 6.3033, + "candidate_final_history_energy": -8.7917070389, + "candidate_post_update_trajectory_mean": -8.8286552429, + "candidate_passed": true + }, + { + "max_steps": 100, + "reference_runtime_sec": 135.815605, + "accepted_e04a_runtime_sec": 24.362414, + "candidate_runtime_sec": 26.530668, + "candidate_over_e04a_ratio": 1.089, + "speedup_over_reference": 5.11841, + "candidate_initial_energy": -6.8462643623, + "candidate_final_history_energy": -10.0279579163, + "candidate_improvement": 3.1816935539, + "candidate_post_update_trajectory_mean": -10.033449173, + "candidate_post_update_trajectory_std": 3.3379e-06, + "candidate_passed": true + } + ], + "decision": "discard for the canonical metric; it is fastest for one and 50 steps, but dense state materialization makes 100 steps 8.90% slower than accepted e04a" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json b/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json new file mode 100644 index 0000000..6ad677e --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "task_id": "07", + "experiment": "e06", + "candidate_commit": "828e921ddf69709054d5fa52a5e3e62d9fac475e", + "candidate_sha256": "4f0a8757af372c41db677981f1551c363f82f128e0f295073228defece065c68", + "candidate_diff_sha256": "82e90bad5bb428a53d623e268808a22a1ca321a686540f8e7c8ea5b46a15d7fa", + "screen": { + "max_steps": 1, + "accepted_e04a_runtime_sec": 20.672377, + "candidate_runtime_sec": 39.419801, + "candidate_over_e04a_ratio": 1.90687, + "candidate_initial_energy": -6.8462719917, + "candidate_post_update_trajectory_mean": -6.9686336517, + "physical_outputs_within_tolerance": true + }, + "decision": "discard; vvag duplicates per-trajectory reverse-mode structure and is 90.69% slower at the frozen screen" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json b/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json new file mode 100644 index 0000000..67445c0 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json @@ -0,0 +1,30 @@ +{ + "full_ancilla_gradient_max_abs": 4.6559398469980806e-07, + "full_vs_analytic_bits_equal": true, + "gradient_max_abs_error": 1.511594746261835e-06, + "initial_energy": { + "abs_error": 4.76837158203125e-06, + "full": -6.8462653160095215, + "reduced": -6.8462700843811035 + }, + "non_ancilla_gradient_max_abs_error": 1.511594746261835e-06, + "passed": true, + "pattern_counts": [ + 63, + 1 + ], + "post_update_energy": { + "abs_error": 4.673004150390625e-05, + "full": -6.968633651733398, + "reduced": -6.968680381774902 + }, + "post_update_parameter_max_abs_error": 0.01957935094833374, + "rare_trajectory_indices": [ + 36 + ], + "reduced_ancilla_gradient_max_abs": 0.0, + "schema_version": 1, + "task_id": "07", + "trajectory_energy_max_abs_error": 4.291534423828125e-06, + "unique_pattern_count": 2 +} diff --git a/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json b/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json new file mode 100644 index 0000000..3840488 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json @@ -0,0 +1,76 @@ +{ + "schema_version": 1, + "task_id": "07", + "purpose": "post-reduction contractor selection screen", + "configuration": { + "repeat": 6, + "max_steps": 100, + "cpus": 6, + "memory": "7g", + "network": "none", + "image": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "fresh_container_per_cell": true, + "pair_order": "odd incumbent->plain-experimental; even plain-experimental->incumbent" + }, + "greedy_vs_plain_experimental": { + "greedy_runtime_sec": [ + 3.031118, + 2.885613, + 2.866804, + 2.928691, + 2.884610, + 3.086906 + ], + "plain_experimental_runtime_sec": [ + 2.743461, + 2.857651, + 2.813869, + 2.870540, + 2.802305, + 2.852678 + ], + "greedy_mean_sec": 2.9472903333333336, + "plain_experimental_mean_sec": 2.8234173333333334, + "mean_paired_speedup": 1.0441975726959485, + "paired_speedup_stderr": 0.016060044771815166, + "paired_speedup_ci_95": [ + 1.0029139133105376, + 1.0854812320813594 + ], + "plain_experimental_wins": 6, + "all_cells_passed": true + }, + "omeco_1x1_vs_plain_experimental": { + "omeco_1x1_runtime_sec": [ + 2.964172, + 2.917681, + 2.854544, + 3.073592, + 2.902695, + 2.981453 + ], + "plain_experimental_runtime_sec": [ + 2.790114, + 2.808054, + 2.891351, + 2.763116, + 2.825308, + 2.956301 + ], + "omeco_1x1_mean_sec": 2.9490228333333333, + "plain_experimental_mean_sec": 2.8390406666666665, + "mean_paired_speedup": 1.0394928362030935, + "paired_speedup_stderr": 0.01795200077974768, + "paired_speedup_ci_95": [ + 0.9933457490680451, + 1.085639923338142 + ], + "plain_experimental_wins": 5, + "all_cells_passed": true + }, + "discarded_warmup_attempt": { + "reason": "macOS Docker could not bind-mount a /private/tmp worktree and all greedy cells failed before evaluator execution", + "used_in_statistics": false + }, + "decision": "plain-experimental" +} diff --git a/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json b/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json new file mode 100644 index 0000000..3de2b93 --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json @@ -0,0 +1,630 @@ +{ + "schema_version": 1, + "task_id": "07", + "started_at_utc": "2026-07-29T02:18:11.372804+00:00", + "finished_at_utc": "2026-07-29T02:32:55.247868+00:00", + "session_wall_sec": 883.8707169160189, + "configuration": { + "repeat": 6, + "max_steps": 100, + "timeout_sec": 300.0, + "cpus": 6.0, + "memory": "7g", + "pair_order": "odd reference->candidate; even candidate->reference", + "fresh_evaluator_process_per_cell": true, + "single_container": true + }, + "host": { + "uname": "Darwin QQYdeMacBook-Air.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:34 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8112 arm64", + "cpu": "Apple M2", + "physical_memory": "17179869184", + "fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" + }, + "image": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "snapshot": { + "reference": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "candidate": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "sitecustomize": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120" + }, + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "results": [ + { + "cell_id": "task07-01", + "pair": 1, + "position": 1, + "order": "reference->candidate", + "task_id": "07", + "solution": "reference", + "repeat_index": 1, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 123.28606, + "wall_sec": 124.74236662499607, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-01-reference.stdout.txt", + "stderr_path": "logs/cell-01-reference.stderr.txt", + "stdout_sha256": "2a23418ae98386e3fbb1cd9e0a6e993a976f585908b077e89259a7545cfd3938", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-02", + "pair": 1, + "position": 2, + "order": "reference->candidate", + "task_id": "07", + "solution": "candidate", + "repeat_index": 1, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 3.062554, + "wall_sec": 4.301580749975983, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-02-candidate.stdout.txt", + "stderr_path": "logs/cell-02-candidate.stderr.txt", + "stdout_sha256": "1e0b1c1ba0352bb0cf57a481d9ad516abe32eee0c8fa40b2fc614f835bcbce10", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-03", + "pair": 2, + "position": 1, + "order": "candidate->reference", + "task_id": "07", + "solution": "candidate", + "repeat_index": 2, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 3.311737, + "wall_sec": 4.367966541991336, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-03-candidate.stdout.txt", + "stderr_path": "logs/cell-03-candidate.stderr.txt", + "stdout_sha256": "4d906b12bdea17e8540e1d876df6757c08815210466bcb28824503c29a2979f4", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-04", + "pair": 2, + "position": 2, + "order": "candidate->reference", + "task_id": "07", + "solution": "reference", + "repeat_index": 2, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 126.247088, + "wall_sec": 127.39457612499245, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-04-reference.stdout.txt", + "stderr_path": "logs/cell-04-reference.stderr.txt", + "stdout_sha256": "81e3c7ab8cb79dcab888a9ba1f296362793331a8bd9d2ac2bbcb53f69f137c4d", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-05", + "pair": 3, + "position": 1, + "order": "reference->candidate", + "task_id": "07", + "solution": "reference", + "repeat_index": 3, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 150.224728, + "wall_sec": 151.55164112499915, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-05-reference.stdout.txt", + "stderr_path": "logs/cell-05-reference.stderr.txt", + "stdout_sha256": "2094ee9648970228aa20d78db4867c66653c74335b3793b3f3e873937cf5d7e9", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-06", + "pair": 3, + "position": 2, + "order": "reference->candidate", + "task_id": "07", + "solution": "candidate", + "repeat_index": 3, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 2.989908, + "wall_sec": 4.167482208984438, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-06-candidate.stdout.txt", + "stderr_path": "logs/cell-06-candidate.stderr.txt", + "stdout_sha256": "9335e2f49ddcd908fc919157badb1c9e122d7b4e57db8036e4bfc543eb9e0123", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-07", + "pair": 4, + "position": 1, + "order": "candidate->reference", + "task_id": "07", + "solution": "candidate", + "repeat_index": 4, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 3.030923, + "wall_sec": 4.051274541998282, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-07-candidate.stdout.txt", + "stderr_path": "logs/cell-07-candidate.stderr.txt", + "stdout_sha256": "64513b93683b9df3458a87abd45b94e4a7274fd1caaa28ce74eed3f70892c1a8", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-08", + "pair": 4, + "position": 2, + "order": "candidate->reference", + "task_id": "07", + "solution": "reference", + "repeat_index": 4, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 129.913867, + "wall_sec": 131.0978523750091, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-08-reference.stdout.txt", + "stderr_path": "logs/cell-08-reference.stderr.txt", + "stdout_sha256": "cda077fecbe4d0d58d3ce68ea476893bfc0fa38d2a6337e33e7e598a5f7e6ea5", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-09", + "pair": 5, + "position": 1, + "order": "reference->candidate", + "task_id": "07", + "solution": "reference", + "repeat_index": 5, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 159.579514, + "wall_sec": 161.19171666601324, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-09-reference.stdout.txt", + "stderr_path": "logs/cell-09-reference.stderr.txt", + "stdout_sha256": "fcce1a58beb2bde886a64d8b841f771a8d8ae249c25fb26bcc2d29732b642010", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-10", + "pair": 5, + "position": 2, + "order": "reference->candidate", + "task_id": "07", + "solution": "candidate", + "repeat_index": 5, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 3.06333, + "wall_sec": 4.332712417002767, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-10-candidate.stdout.txt", + "stderr_path": "logs/cell-10-candidate.stderr.txt", + "stdout_sha256": "cd6ddb2b9b2fce917d82a2b7eb9ef759f2f88d7b4d80d740687dac2e83556ea9", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-11", + "pair": 6, + "position": 1, + "order": "candidate->reference", + "task_id": "07", + "solution": "candidate", + "repeat_index": 6, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 2.966582, + "wall_sec": 4.002367916982621, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-11-candidate.stdout.txt", + "stderr_path": "logs/cell-11-candidate.stderr.txt", + "stdout_sha256": "2819622c79880d12faace0e820ed159aacfbc79f0c7b032940c296892efbd919", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + { + "cell_id": "task07-12", + "pair": 6, + "position": 2, + "order": "candidate->reference", + "task_id": "07", + "solution": "reference", + "repeat_index": 6, + "planned_repeats": 6, + "max_steps": 100, + "runtime_sec": 151.207388, + "wall_sec": 152.35602883298998, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "returncode": 0, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": { + "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", + "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "repo_digests": [ + "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" + ], + "created": "2026-07-27T22:15:05.362478611+08:00", + "architecture": "arm64", + "os": "linux" + }, + "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", + "container_name": "orbit-task07-matrix-ef51965c7b", + "cpu_limit": "6.0", + "memory_limit": "7g", + "timeout_sec": 300.0, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", + "stdout_path": "logs/cell-12-reference.stdout.txt", + "stderr_path": "logs/cell-12-reference.stderr.txt", + "stdout_sha256": "e529b0ab17d651cd0c88c9c96bbd130e03d3fc0c9de22cfb81e4a82ccb3e9d1b", + "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + ], + "pairs": [ + { + "pair": 1, + "reference_runtime_sec": 123.28606, + "candidate_runtime_sec": 3.062554, + "speedup": 40.25596283363493, + "candidate_won": true + }, + { + "pair": 2, + "reference_runtime_sec": 126.247088, + "candidate_runtime_sec": 3.311737, + "speedup": 38.12110925475061, + "candidate_won": true + }, + { + "pair": 3, + "reference_runtime_sec": 150.224728, + "candidate_runtime_sec": 2.989908, + "speedup": 50.24392991356256, + "candidate_won": true + }, + { + "pair": 4, + "reference_runtime_sec": 129.913867, + "candidate_runtime_sec": 3.030923, + "speedup": 42.86280680835508, + "candidate_won": true + }, + { + "pair": 5, + "reference_runtime_sec": 159.579514, + "candidate_runtime_sec": 3.06333, + "speedup": 52.09347801248967, + "candidate_won": true + }, + { + "pair": 6, + "reference_runtime_sec": 151.207388, + "candidate_runtime_sec": 2.966582, + "speedup": 50.9702371281158, + "candidate_won": true + } + ], + "summary": { + "all_cells_passed": true, + "reference": { + "n": 6, + "mean": 140.07644083333332, + "median": 140.0692975, + "sample_stdev": 15.38636653290017, + "stderr": 6.281457833506891, + "min": 123.28606, + "max": 159.579514 + }, + "candidate": { + "n": 6, + "mean": 3.070839, + "median": 3.0467385, + "sample_stdev": 0.1242332552708815, + "stderr": 0.050718014083098076, + "min": 2.966582, + "max": 3.311737 + }, + "ratio_of_means_speedup": 45.615039027879135, + "ratio_of_means_improvement_pct": 97.80774055813299, + "paired_speedup": { + "n": 6, + "mean": 45.75792065848478, + "median": 46.55336836095882, + "sample_stdev": 6.072988087094512, + "stderr": 2.4792870045637403, + "min": 38.12110925475061, + "max": 52.09347801248967 + }, + "paired_speedup_ci_95": { + "method": "two-sided Student-t interval on mean pairwise speedup", + "low": 39.38471051683481, + "high": 52.13113080013475 + }, + "candidate_wins": 6, + "promotion_rule_passed": true + } +} diff --git a/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json b/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json new file mode 100644 index 0000000..ca4751c --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json @@ -0,0 +1,123 @@ +{ + "schema_version": 1, + "task_id": "07", + "classification": "final counterbalanced canonical paired benchmark", + "measurement_window_utc": { + "first_cell_finished": "2026-07-29T00:57:01Z", + "last_cell_finished": "2026-07-29T01:09:42Z" + }, + "recovery_note": "All 12 raw stdout/stderr logs were written before a final report-serialization NameError (Python true instead of True). No cell was rerun, omitted, or altered; this sanitized report was reconstructed directly from those logs.", + "environment": { + "image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", + "container_id_prefix": "b8199b0e1e6a", + "container_name": "orbit-task07-matrix-34ea5ae79e", + "cpus": 6, + "memory": "7 GiB", + "network": "none", + "timeout_sec": 300, + "host_fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44" + }, + "source": { + "reference_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "candidate_sha256": "0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "sitecustomize_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120" + }, + "pairs": [ + { + "pair": 1, + "order": "reference->candidate", + "reference_runtime_sec": 106.038165, + "candidate_runtime_sec": 24.481295, + "speedup": 4.331395255030422, + "both_passed": true + }, + { + "pair": 2, + "order": "candidate->reference", + "reference_runtime_sec": 119.427967, + "candidate_runtime_sec": 24.221592, + "speedup": 4.930640686210881, + "both_passed": true + }, + { + "pair": 3, + "order": "reference->candidate", + "reference_runtime_sec": 123.188182, + "candidate_runtime_sec": 24.716431, + "speedup": 4.984060279576772, + "both_passed": true + }, + { + "pair": 4, + "order": "candidate->reference", + "reference_runtime_sec": 107.532991, + "candidate_runtime_sec": 24.421997, + "speedup": 4.403120309940255, + "both_passed": true + }, + { + "pair": 5, + "order": "reference->candidate", + "reference_runtime_sec": 110.084619, + "candidate_runtime_sec": 31.684172, + "speedup": 3.4744357214068904, + "both_passed": true + }, + { + "pair": 6, + "order": "candidate->reference", + "reference_runtime_sec": 131.316223, + "candidate_runtime_sec": 27.652166, + "speedup": 4.74885848001925, + "both_passed": true + } + ], + "summary": { + "passing_cells": 12, + "passing_pairs": 6, + "candidate_wins": 6, + "reference": { + "mean_runtime_sec": 116.26469116666667, + "median_runtime_sec": 114.756293, + "sample_stdev_sec": 10.035012377372944, + "stderr_sec": 4.096776647846211, + "min_sec": 106.038165, + "max_sec": 131.316223 + }, + "candidate": { + "mean_runtime_sec": 26.1962755, + "median_runtime_sec": 24.598863, + "sample_stdev_sec": 2.9804416492525903, + "stderr_sec": 1.2167602081346665, + "min_sec": 24.221592, + "max_sec": 31.684172 + }, + "ratio_of_means_speedup": 4.43821455331185, + "ratio_of_means_improvement_pct": 77.4684169053119, + "paired_speedup": { + "mean": 4.478751788697412, + "median": 4.575989394979753, + "sample_stdev": 0.5601040444343872, + "stderr": 0.22866151862223416, + "ci_95_student_t_low": 3.8909586421977242, + "ci_95_student_t_high": 5.0665449351971 + }, + "promotion_rule_passed": true + }, + "raw_stdout_sha256": [ + "07dce676f856d902098311f2a36eff06d5ccbe5bbf477a10107c6fcd4aa305fd", + "d6acf849d92b638521b558ffb23edff7eb3b923ae19be278c6e6fa829dc9e46e", + "ca3748a9698e68ade3ae1955e9d383b155b33787b4bdf9c7f0e5a18cd97f322b", + "e5fb653e281481644b90fa0f1cd6b9900a2db80b86548bae14f4d43c57232acd", + "1075dc014a7b6d99e6edc82f868fdd7fdef976ac246b6abee8056d9646a0f66a", + "e9f0ee39e311c167fe43065aa7d3ad35d2f6542e56ae215046ffa87441ed4288", + "6e9556f4206792fb29024c72349f0218f7d6276b7968be24b66397bd92e9a411", + "8c17ca159dd7a39cfd95e2f4cdb4dee416b2dfb7d322c30ecdea5f66e039086a", + "492bf197a17a8dfb1597d826418014a6f0911424a65afddcbf15fcffe906b4bf", + "9fd2be1ab0f4f41c1d162c727ef0bb41830258bb821fd0bbe0142d57aae93595", + "a961e92e87c90a05c2291196ff73f3c59c6eb9422e279ce2557aae3b3ae70b9c", + "02768532f47b20565ee382d7be8d6fed8b02b23b36a2c82dc11f69867be169c2" + ] +} diff --git a/optimized_solutions/challenge-07/research/profiles/final-reference-six.json b/optimized_solutions/challenge-07/research/profiles/final-reference-six.json new file mode 100644 index 0000000..7c1022e --- /dev/null +++ b/optimized_solutions/challenge-07/research/profiles/final-reference-six.json @@ -0,0 +1,141 @@ +{ + "schema_version": 1, + "task_id": "07", + "host": { + "fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" + }, + "results": [ + { + "task_id": "07", + "solution": "reference", + "repeat": 1, + "planned_repeats": 6, + "runtime_sec": 106.038165, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + }, + { + "task_id": "07", + "solution": "reference", + "repeat": 2, + "planned_repeats": 6, + "runtime_sec": 119.427967, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + }, + { + "task_id": "07", + "solution": "reference", + "repeat": 3, + "planned_repeats": 6, + "runtime_sec": 123.188182, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + }, + { + "task_id": "07", + "solution": "reference", + "repeat": 4, + "planned_repeats": 6, + "runtime_sec": 107.532991, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + }, + { + "task_id": "07", + "solution": "reference", + "repeat": 5, + "planned_repeats": 6, + "runtime_sec": 110.084619, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + }, + { + "task_id": "07", + "solution": "reference", + "repeat": 6, + "planned_repeats": 6, + "runtime_sec": 131.316223, + "passed": true, + "timed_out": false, + "terminal_status": "SUCCESS", + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, + "timeout_sec": 300, + "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", + "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", + "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", + "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", + "shared_container_id": "b8199b0e1e6a", + "shared_container_name": "orbit-task07-matrix-34ea5ae79e", + "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], + "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] + } + ] +} diff --git a/optimized_solutions/challenge-07/research/run_docker_matrix.py b/optimized_solutions/challenge-07/research/run_docker_matrix.py new file mode 100644 index 0000000..35d94df --- /dev/null +++ b/optimized_solutions/challenge-07/research/run_docker_matrix.py @@ -0,0 +1,418 @@ +#!/usr/bin/env python3 +"""Run counterbalanced Task 07 reference/candidate pairs in one container.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import math +import re +import shutil +import statistics +import subprocess +import tempfile +import time +import uuid +from datetime import datetime, timezone +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[2] +RUNTIME_RE = re.compile(r"End-to-end solution time:\s*([0-9.]+)s") +T_CRITICAL_95 = {5: 2.5705818366} + + +def sha256(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def utc_now() -> str: + return datetime.now(timezone.utc).isoformat() + + +def run(command: list[str], timeout: float = 30) -> subprocess.CompletedProcess[str]: + return subprocess.run( + command, + check=False, + text=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=timeout, + ) + + +def stats(values: list[float]) -> dict[str, float | int | None]: + stdev = statistics.stdev(values) if len(values) > 1 else None + return { + "n": len(values), + "mean": statistics.mean(values) if values else None, + "median": statistics.median(values) if values else None, + "sample_stdev": stdev, + "stderr": stdev / math.sqrt(len(values)) if stdev is not None else None, + "min": min(values) if values else None, + "max": max(values) if values else None, + } + + +def host_record() -> dict[str, object]: + commands = { + "uname": ["uname", "-a"], + "cpu": ["sysctl", "-n", "machdep.cpu.brand_string"], + "physical_memory": ["sysctl", "-n", "hw.memsize"], + } + record: dict[str, object] = {} + for key, command in commands.items(): + try: + result = run(command) + record[key] = result.stdout.strip() if result.returncode == 0 else None + except (OSError, subprocess.TimeoutExpired): + record[key] = None + record["fingerprint_sha256"] = hashlib.sha256( + json.dumps(record, sort_keys=True).encode() + ).hexdigest() + return record + + +def image_record(reference: str) -> dict[str, object]: + result = run(["docker", "image", "inspect", reference]) + if result.returncode: + raise RuntimeError(result.stderr.strip() or f"cannot inspect {reference}") + raw = json.loads(result.stdout)[0] + return { + "reference": reference, + "id": raw.get("Id"), + "repo_digests": raw.get("RepoDigests") or [], + "created": raw.get("Created"), + "architecture": raw.get("Architecture"), + "os": raw.get("Os"), + } + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser() + parser.add_argument("--repeat", type=int, default=6) + parser.add_argument("--max-steps", type=int, default=100) + parser.add_argument("--timeout", type=float, default=300.0) + parser.add_argument("--cpus", type=float, default=6.0) + parser.add_argument("--memory", default="7g") + parser.add_argument( + "--image", + default="orbitbreakers-expert-benchmarks:tensorcircuit-py311", + ) + parser.add_argument("--output", type=Path, required=True) + return parser.parse_args() + + +def main() -> None: + args = parse_args() + if args.repeat <= 0 or args.max_steps <= 0: + raise SystemExit("repeat and max-steps must be positive") + timeout = min(args.timeout, 300.0) + output = args.output.expanduser().resolve() + logs = output / "logs" + logs.mkdir(parents=True, exist_ok=True) + + sources = { + "reference": ROOT / "references/task-07/solution_7.py", + "candidate": ROOT / "src/solutions/task-07/solution_7.py", + } + evaluator = ROOT / "tasks/task-07/evaluator/evaluate_7.py" + sitecustomize = ROOT / "envs/tensorcircuit-py311/sitecustomize.py" + for path in [*sources.values(), evaluator, sitecustomize]: + if not path.is_file(): + raise SystemExit(f"missing required file: {path}") + + image = image_record(args.image) + host = host_record() + container_name = f"orbit-task07-matrix-{uuid.uuid4().hex[:10]}" + started_at = utc_now() + session_started = time.perf_counter() + rows: list[dict[str, object]] = [] + + staging_root = ROOT / ".tmp" + staging_root.mkdir(exist_ok=True) + with tempfile.TemporaryDirectory(prefix="task07-matrix-", dir=staging_root) as tmp: + staging = Path(tmp) + shutil.copy2(evaluator, staging / "evaluate_7.py") + environment = staging / "environment" + environment.mkdir() + shutil.copy2(sitecustomize, environment / "sitecustomize.py") + modules: dict[str, str] = {} + snapshot: dict[str, str] = {} + for role, source in sources.items(): + module = f"solution_7_{role}" + modules[role] = module + target = staging / f"{module}.py" + shutil.copy2(source, target) + snapshot[role] = sha256(target) + snapshot["evaluator"] = sha256(staging / "evaluate_7.py") + snapshot["sitecustomize"] = sha256(environment / "sitecustomize.py") + snapshot_sha256 = hashlib.sha256( + json.dumps(snapshot, sort_keys=True).encode() + ).hexdigest() + + start_command = [ + "docker", + "run", + "--detach", + "--rm", + "--name", + container_name, + "--network", + "none", + "--tmpfs", + "/tmp:rw,noexec,nosuid,size=1g", + "--mount", + f"type=bind,src={staging.resolve()},dst=/session,readonly", + "--workdir", + "/session", + "--env", + "NUMBA_DISABLE_JIT=1", + "--env", + "PYTHONPATH=/session:/session/environment", + "--cpus", + str(args.cpus), + "--memory", + args.memory, + args.image, + "tail", + "-f", + "/dev/null", + ] + started = run(start_command, timeout=60) + if started.returncode: + raise SystemExit(started.stderr.strip() or "container start failed") + container_id = started.stdout.strip() + + plan: list[tuple[int, int, str, str]] = [] + for pair in range(1, args.repeat + 1): + roles = ( + ("reference", "candidate") + if pair % 2 + else ("candidate", "reference") + ) + order = "->".join(roles) + for position, role in enumerate(roles, start=1): + plan.append((pair, position, role, order)) + + try: + for cell, (pair, position, role, order) in enumerate(plan, start=1): + command = [ + "docker", + "exec", + "--workdir", + "/session", + "--env", + "NUMBA_DISABLE_JIT=1", + "--env", + "PYTHONPATH=/session:/session/environment", + container_name, + "python", + "/session/evaluate_7.py", + "--solution", + modules[role], + "--max-steps", + str(args.max_steps), + ] + wall_started = time.perf_counter() + timed_out = False + try: + result = run(command, timeout=timeout) + stdout, stderr, returncode = ( + result.stdout, + result.stderr, + result.returncode, + ) + except subprocess.TimeoutExpired as exc: + timed_out = True + stdout = exc.stdout or "" + stderr = exc.stderr or "" + returncode = None + wall_sec = time.perf_counter() - wall_started + stdout_path = logs / f"cell-{cell:02d}-{role}.stdout.txt" + stderr_path = logs / f"cell-{cell:02d}-{role}.stderr.txt" + stdout_path.write_text(stdout, encoding="utf-8") + stderr_path.write_text(stderr, encoding="utf-8") + match = RUNTIME_RE.search(stdout) + runtime = float(match.group(1)) if match else None + passed = ( + not timed_out + and returncode == 0 + and runtime is not None + and "Overall: PASS" in stdout + ) + row = { + "cell_id": f"task07-{cell:02d}", + "pair": pair, + "position": position, + "order": order, + "task_id": "07", + "solution": role, + "repeat_index": pair, + "planned_repeats": args.repeat, + "max_steps": args.max_steps, + "runtime_sec": runtime, + "wall_sec": wall_sec, + "passed": passed, + "timed_out": timed_out, + "terminal_status": "SUCCESS" if passed else "FAILED", + "returncode": returncode, + "engine": "docker", + "environment": "tensorcircuit-py311", + "environment_image_provenance": image, + "container_id": container_id, + "container_name": container_name, + "cpu_limit": str(args.cpus), + "memory_limit": args.memory, + "timeout_sec": timeout, + "source_sha256": snapshot[role], + "evaluator_sha256": snapshot["evaluator"], + "staging_snapshot_sha256": snapshot_sha256, + "stdout_path": str(stdout_path.relative_to(output)), + "stderr_path": str(stderr_path.relative_to(output)), + "stdout_sha256": sha256(stdout_path), + "stderr_sha256": sha256(stderr_path), + } + rows.append(row) + (output / "checkpoint.json").write_text( + json.dumps( + { + "schema_version": 1, + "task_id": "07", + "configuration": { + "repeat": args.repeat, + "max_steps": args.max_steps, + "cpus": args.cpus, + "memory": args.memory, + }, + "host": host, + "image": image, + "snapshot": snapshot, + "staging_snapshot_sha256": snapshot_sha256, + "results": rows, + }, + indent=2, + ) + + "\n", + encoding="utf-8", + ) + print( + f"cell {cell:02d}/{len(plan)} pair={pair} role={role} " + f"runtime={runtime} passed={passed}", + flush=True, + ) + finally: + run(["docker", "stop", container_name], timeout=60) + + reference = [ + float(row["runtime_sec"]) + for row in rows + if row["solution"] == "reference" and row["passed"] + ] + candidate = [ + float(row["runtime_sec"]) + for row in rows + if row["solution"] == "candidate" and row["passed"] + ] + by_pair: dict[int, dict[str, float]] = {} + for row in rows: + if row["passed"]: + by_pair.setdefault(int(row["pair"]), {})[str(row["solution"])] = float( + row["runtime_sec"] + ) + pair_rows = [] + speedups = [] + for pair in sorted(by_pair): + values = by_pair[pair] + if set(values) == {"reference", "candidate"}: + speedup = values["reference"] / values["candidate"] + speedups.append(speedup) + pair_rows.append( + { + "pair": pair, + "reference_runtime_sec": values["reference"], + "candidate_runtime_sec": values["candidate"], + "speedup": speedup, + "candidate_won": values["candidate"] < values["reference"], + } + ) + + speedup_stats = stats(speedups) + ci_low = ci_high = None + if len(speedups) > 1: + critical = T_CRITICAL_95.get(len(speedups) - 1) + if critical is not None: + radius = critical * float(speedup_stats["stderr"]) + ci_low = float(speedup_stats["mean"]) - radius + ci_high = float(speedup_stats["mean"]) + radius + ref_stats, cand_stats = stats(reference), stats(candidate) + all_passed = len(rows) == 2 * args.repeat and all(row["passed"] for row in rows) + promotion = ( + all_passed + and len(speedups) == args.repeat + and float(cand_stats["mean"]) < float(ref_stats["mean"]) + and float(cand_stats["median"]) < float(ref_stats["median"]) + and sum(row["candidate_won"] for row in pair_rows) + >= math.ceil(0.8 * args.repeat) + and ci_low is not None + and ci_low > 1.0 + ) + report = { + "schema_version": 1, + "task_id": "07", + "started_at_utc": started_at, + "finished_at_utc": utc_now(), + "session_wall_sec": time.perf_counter() - session_started, + "configuration": { + "repeat": args.repeat, + "max_steps": args.max_steps, + "timeout_sec": timeout, + "cpus": args.cpus, + "memory": args.memory, + "pair_order": "odd reference->candidate; even candidate->reference", + "fresh_evaluator_process_per_cell": True, + "single_container": True, + }, + "host": host, + "image": image, + "snapshot": snapshot, + "staging_snapshot_sha256": snapshot_sha256, + "results": rows, + "pairs": pair_rows, + "summary": { + "all_cells_passed": all_passed, + "reference": ref_stats, + "candidate": cand_stats, + "ratio_of_means_speedup": ( + float(ref_stats["mean"]) / float(cand_stats["mean"]) + if reference and candidate + else None + ), + "ratio_of_means_improvement_pct": ( + 100 + * (float(ref_stats["mean"]) - float(cand_stats["mean"])) + / float(ref_stats["mean"]) + if reference and candidate + else None + ), + "paired_speedup": speedup_stats, + "paired_speedup_ci_95": { + "method": "two-sided Student-t interval on mean pairwise speedup", + "low": ci_low, + "high": ci_high, + }, + "candidate_wins": sum(row["candidate_won"] for row in pair_rows), + "promotion_rule_passed": promotion, + }, + } + (output / "results.json").write_text( + json.dumps(report, indent=2) + "\n", encoding="utf-8" + ) + print(json.dumps(report["summary"], indent=2), flush=True) + if not promotion: + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py b/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py new file mode 100644 index 0000000..c1f9464 --- /dev/null +++ b/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py @@ -0,0 +1,320 @@ +#!/usr/bin/env python3 +"""Audit the exact classical-ancilla reduction proposed for Task 07.""" + +from __future__ import annotations + +import argparse +import importlib.util +import json +from pathlib import Path +from typing import Any + +import jax +import numpy as np +import optax +import tensorcircuit as tc + + +CONFIG = { + "n_data_qubits": 8, + "n_ancilla_qubits": 8, + "n_qubits": 16, + "n_layers": 2, + "n_trajectories": 64, + "initial_parameter_scale": 0.1, + "max_steps": 100, + "learning_rate": 0.02, + "seed": 2047, + "transverse_field": 1.05, + "minimum_improvement": 0.3, + "target_final_energy": -8.3, +} + +K = tc.set_backend("jax") +tc.set_dtype("complex64") +tc.set_contractor("omeco-1-1") + + +def load_solution(path: Path) -> Any: + spec = importlib.util.spec_from_file_location("task07_current_candidate", path) + if spec is None or spec.loader is None: + raise RuntimeError(f"cannot import candidate: {path}") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +def ready(value: Any) -> Any: + return jax.tree.map( + lambda leaf: leaf.block_until_ready() + if hasattr(leaf, "block_until_ready") + else leaf, + value, + ) + + +def exact_full_bits(params: Any, status: Any) -> Any: + c = tc.Circuit(CONFIG["n_qubits"]) + pidx = 0 + sidx = 0 + layers = [] + for _ in range(CONFIG["n_layers"]): + for q in range(CONFIG["n_data_qubits"]): + c.ry(q, theta=params[pidx + q]) + pidx += CONFIG["n_data_qubits"] + for a in range(CONFIG["n_ancilla_qubits"]): + c.ry(CONFIG["n_data_qubits"] + a, theta=params[pidx + a]) + pidx += CONFIG["n_ancilla_qubits"] + for a in range(CONFIG["n_ancilla_qubits"]): + c.rzz( + CONFIG["n_data_qubits"] + a, + a, + theta=params[pidx + a], + ) + pidx += CONFIG["n_ancilla_qubits"] + for a in range(CONFIG["n_ancilla_qubits"] - 1): + c.cnot( + CONFIG["n_data_qubits"] + a, + CONFIG["n_data_qubits"] + a + 1, + ) + theta0 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] + pidx += CONFIG["n_ancilla_qubits"] + theta1 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] + pidx += CONFIG["n_ancilla_qubits"] + bits = [] + for a in range(CONFIG["n_ancilla_qubits"]): + bit = c.cond_measure( + CONFIG["n_data_qubits"] + a, status=status[sidx] + ) + bitf = K.cast(bit, "float32") + feedback = theta0[a] + bitf * (theta1[a] - theta0[a]) + c.rz(a, theta=(1.0 - 2.0 * bitf) * feedback) + bits.append(bit) + sidx += 1 + for q in range(CONFIG["n_data_qubits"] - 1): + c.cnot(q, q + 1) + for q in range(CONFIG["n_data_qubits"]): + c.rz(q, theta=params[pidx + q]) + pidx += CONFIG["n_data_qubits"] + layers.append(K.stack(bits)) + return K.stack(layers) + + +def analytic_bits(params: Any, status: Any) -> tuple[Any, Any]: + previous_measured = K.zeros([CONFIG["n_ancilla_qubits"]], dtype="int32") + measured_layers = [] + pre_ladder_layers = [] + sidx = 0 + for layer in range(CONFIG["n_layers"]): + offset = layer * 48 + ancilla_angles = params[offset + 8 : offset + 16] + base_probability_one = K.sin(ancilla_angles / 2.0) ** 2 + previous_float = K.cast(previous_measured, "float32") + probability_one = base_probability_one + previous_float * ( + 1.0 - 2.0 * base_probability_one + ) + measured = [] + pre_ladder = [] + previous_output = K.convert_to_tensor(0, dtype="int32") + for a in range(CONFIG["n_ancilla_qubits"]): + previous_output_float = K.cast(previous_output, "float32") + measured_probability_one = probability_one[a] + previous_output_float * ( + 1.0 - 2.0 * probability_one[a] + ) + bit = K.cast( + status[sidx] > (1.0 - measured_probability_one), "int32" + ) + source_bit = bit + previous_output - 2 * bit * previous_output + measured.append(bit) + pre_ladder.append(source_bit) + previous_output = bit + sidx += 1 + previous_measured = K.stack(measured) + measured_layers.append(previous_measured) + pre_ladder_layers.append(K.stack(pre_ladder)) + return K.stack(measured_layers), K.stack(pre_ladder_layers) + + +def make_reduced_energy() -> Any: + strings = [] + weights = [] + for i in range(CONFIG["n_data_qubits"] - 1): + term = [0] * CONFIG["n_data_qubits"] + term[i] = 3 + term[i + 1] = 3 + strings.append(term) + weights.append(-1.0) + for i in range(CONFIG["n_data_qubits"]): + term = [0] * CONFIG["n_data_qubits"] + term[i] = 1 + strings.append(term) + weights.append(-CONFIG["transverse_field"]) + hamiltonian = tc.quantum.PauliStringSum2COO(strings, weights) + + def reduced_energy(params: Any, pattern: Any) -> Any: + measured, pre_ladder = pattern + c = tc.Circuit(CONFIG["n_data_qubits"]) + for layer in range(CONFIG["n_layers"]): + offset = layer * 48 + for q in range(CONFIG["n_data_qubits"]): + c.ry(q, theta=params[offset + q]) + theta0 = params[offset + 24 : offset + 32] + theta1 = params[offset + 32 : offset + 40] + for q in range(CONFIG["n_data_qubits"]): + measured_float = K.cast(measured[layer, q], "float32") + source_float = K.cast(pre_ladder[layer, q], "float32") + feedback = theta0[q] + measured_float * ( + theta1[q] - theta0[q] + ) + angle = ( + (1.0 - 2.0 * source_float) * params[offset + 16 + q] + + (1.0 - 2.0 * measured_float) * feedback + ) + c.rz(q, theta=angle) + for q in range(CONFIG["n_data_qubits"] - 1): + c.cnot(q, q + 1) + for q in range(CONFIG["n_data_qubits"]): + c.rz(q, theta=params[offset + 40 + q]) + return tc.templates.measurements.operator_expectation(c, hamiltonian) + + return reduced_energy + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument( + "--solution", + type=Path, + default=Path("/workspace/src/solutions/task-07/solution_7.py"), + ) + parser.add_argument("--output", type=Path) + args = parser.parse_args() + + solution = load_solution(args.solution) + params = solution.initial_parameters(CONFIG) + statuses = solution.trajectory_status(CONFIG) + + full_bits = ready( + K.jit(K.vmap(exact_full_bits, vectorized_argnums=1))(params, statuses) + ) + analytic = K.jit(K.vmap(analytic_bits, vectorized_argnums=1)) + analytic_measured, analytic_pre_ladder = ready(analytic(params, statuses)) + patterns = K.stack([analytic_measured, analytic_pre_ladder], axis=1) + + pattern_array = np.asarray(patterns, dtype=np.int32) + flat_patterns = pattern_array.reshape(CONFIG["n_trajectories"], -1) + unique_flat, inverse, counts = np.unique( + flat_patterns, axis=0, return_inverse=True, return_counts=True + ) + unique_patterns = K.convert_to_tensor( + unique_flat.reshape(-1, 2, CONFIG["n_layers"], 8) + ) + inverse_tensor = K.convert_to_tensor(inverse, dtype="int32") + counts_tensor = K.convert_to_tensor(counts, dtype="float32") + + full_one = solution.make_one_trajectory(CONFIG) + full_batch = K.jit(K.vmap(full_one, vectorized_argnums=1)) + reduced_one = make_reduced_energy() + reduced_batch = K.jit(K.vmap(reduced_one, vectorized_argnums=1)) + + def full_loss(p: Any) -> Any: + return K.mean(full_batch(p, statuses)) + + def reduced_loss(p: Any) -> Any: + values = reduced_batch(p, unique_patterns) + return K.sum(values * counts_tensor) / CONFIG["n_trajectories"] + + full_energy, full_grad = ready( + K.jit(K.value_and_grad(full_loss))(params) + ) + reduced_energy, reduced_grad = ready( + K.jit(K.value_and_grad(reduced_loss))(params) + ) + full_values = ready(full_batch(params, statuses)) + unique_values = ready(reduced_batch(params, unique_patterns)) + reduced_values = unique_values[inverse_tensor] + + ancilla_indices = np.array( + [*range(8, 16), *range(56, 64)], dtype=np.int32 + ) + non_ancilla_mask = np.ones(96, dtype=bool) + non_ancilla_mask[ancilla_indices] = False + full_grad_np = np.asarray(full_grad) + reduced_grad_np = np.asarray(reduced_grad) + + optimizer = optax.adam(CONFIG["learning_rate"]) + full_state = optimizer.init(params) + reduced_state = optimizer.init(params) + full_updates, full_state = optimizer.update(full_grad, full_state, params) + reduced_updates, reduced_state = optimizer.update( + reduced_grad, reduced_state, params + ) + full_post = optax.apply_updates(params, full_updates) + reduced_post = optax.apply_updates(params, reduced_updates) + full_post_energy = ready(K.jit(full_loss)(full_post)) + reduced_post_energy = ready(K.jit(reduced_loss)(reduced_post)) + + report = { + "schema_version": 1, + "task_id": "07", + "full_vs_analytic_bits_equal": bool( + np.array_equal(np.asarray(full_bits), np.asarray(analytic_measured)) + ), + "unique_pattern_count": int(len(unique_flat)), + "pattern_counts": [int(value) for value in counts], + "rare_trajectory_indices": [ + int(index) for index in np.where(inverse != inverse[0])[0] + ], + "initial_energy": { + "full": float(full_energy), + "reduced": float(reduced_energy), + "abs_error": abs(float(full_energy) - float(reduced_energy)), + }, + "trajectory_energy_max_abs_error": float( + np.max(np.abs(np.asarray(full_values) - np.asarray(reduced_values))) + ), + "gradient_max_abs_error": float( + np.max(np.abs(full_grad_np - reduced_grad_np)) + ), + "non_ancilla_gradient_max_abs_error": float( + np.max( + np.abs( + full_grad_np[non_ancilla_mask] + - reduced_grad_np[non_ancilla_mask] + ) + ) + ), + "full_ancilla_gradient_max_abs": float( + np.max(np.abs(full_grad_np[ancilla_indices])) + ), + "reduced_ancilla_gradient_max_abs": float( + np.max(np.abs(reduced_grad_np[ancilla_indices])) + ), + "post_update_parameter_max_abs_error": float( + np.max(np.abs(np.asarray(full_post) - np.asarray(reduced_post))) + ), + "post_update_energy": { + "full": float(full_post_energy), + "reduced": float(reduced_post_energy), + "abs_error": abs( + float(full_post_energy) - float(reduced_post_energy) + ), + }, + } + report["passed"] = bool( + report["full_vs_analytic_bits_equal"] + and report["unique_pattern_count"] == 2 + and report["initial_energy"]["abs_error"] <= 5e-5 + and report["non_ancilla_gradient_max_abs_error"] <= 5e-4 + and report["post_update_energy"]["abs_error"] <= 2e-3 + ) + rendered = json.dumps(report, indent=2, sort_keys=True) + "\n" + if args.output is not None: + args.output.write_text(rendered, encoding="utf-8") + print(rendered, end="") + if not report["passed"]: + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/optimized_solutions/challenge-07/research/validate_e01_equivalence.py b/optimized_solutions/challenge-07/research/validate_e01_equivalence.py new file mode 100644 index 0000000..87567aa --- /dev/null +++ b/optimized_solutions/challenge-07/research/validate_e01_equivalence.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +"""Compare one Task 07 trajectory through value, gradient, and one Adam update.""" + +from __future__ import annotations + +import importlib.util +import json +import sys +import time +from pathlib import Path + +import numpy as np +import optax +import tensorcircuit as tc + + +ROOT = Path(__file__).resolve().parents[2] +CONFIG = { + "n_data_qubits": 8, + "n_ancilla_qubits": 8, + "n_qubits": 16, + "n_layers": 2, + "n_trajectories": 64, + "initial_parameter_scale": 0.1, + "max_steps": 100, + "learning_rate": 0.02, + "seed": 2047, + "transverse_field": 1.05, +} +TOLERANCES = { + "energy_abs": 5e-5, + "gradient_max_abs": 5e-4, + "adam_parameter_max_abs": 2e-5, +} + + +def load(path: Path, name: str): + spec = importlib.util.spec_from_file_location(name, path) + if spec is None or spec.loader is None: + raise RuntimeError(f"cannot load {path}") + module = importlib.util.module_from_spec(spec) + sys.modules[name] = module + spec.loader.exec_module(module) + return module + + +def evaluate(module, params, status): + one_trajectory = module.make_one_trajectory(CONFIG) + value_and_grad = tc.backend.jit( + tc.backend.value_and_grad(lambda p: one_trajectory(p, status)) + ) + started = time.perf_counter() + value, gradient = value_and_grad(params) + value_np = np.asarray(tc.backend.numpy(value)) + gradient_np = np.asarray(tc.backend.numpy(gradient)) + elapsed = time.perf_counter() - started + + optimizer = optax.adam(CONFIG["learning_rate"]) + state = optimizer.init(params) + updates, _ = optimizer.update(gradient, state, params) + next_params = optax.apply_updates(params, updates) + next_params_np = np.asarray(tc.backend.numpy(next_params)) + return value_np, gradient_np, next_params_np, elapsed + + +def main(): + reference = load( + ROOT / "references/task-07/solution_7.py", "task07_reference_equivalence" + ) + candidate = load( + ROOT / "src/solutions/task-07/solution_7.py", "task07_candidate_equivalence" + ) + params = reference.initial_parameters(CONFIG) + status = reference.trajectory_status(CONFIG)[0] + + rv, rg, rp, rt = evaluate(reference, params, status) + cv, cg, cp, ct = evaluate(candidate, params, status) + metrics = { + "reference_energy": float(rv), + "candidate_energy": float(cv), + "energy_abs_error": float(np.abs(rv - cv)), + "gradient_max_abs_error": float(np.max(np.abs(rg - cg))), + "gradient_mean_abs_error": float(np.mean(np.abs(rg - cg))), + "adam_parameter_max_abs_error": float(np.max(np.abs(rp - cp))), + "adam_parameter_mean_abs_error": float(np.mean(np.abs(rp - cp))), + "reference_elapsed_sec": rt, + "candidate_elapsed_sec": ct, + } + checks = { + "energy": metrics["energy_abs_error"] <= TOLERANCES["energy_abs"], + "gradient": metrics["gradient_max_abs_error"] + <= TOLERANCES["gradient_max_abs"], + "one_adam_update": metrics["adam_parameter_max_abs_error"] + <= TOLERANCES["adam_parameter_max_abs"], + } + print( + json.dumps( + { + "schema_version": 1, + "task_id": "07", + "experiment": "e01", + "trajectory_index": 0, + "tolerances": TOLERANCES, + "metrics": metrics, + "checks": checks, + "passed": all(checks.values()), + }, + indent=2, + ) + ) + if not all(checks.values()): + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/optimized_solutions/challenge-07/research/validate_feedback_identity.py b/optimized_solutions/challenge-07/research/validate_feedback_identity.py new file mode 100644 index 0000000..3f277da --- /dev/null +++ b/optimized_solutions/challenge-07/research/validate_feedback_identity.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +"""Validate the measured-ancilla RZZ to data-RZ identity for both branches.""" + +from __future__ import annotations + +import json + +import numpy as np +import tensorcircuit as tc + + +K = tc.set_backend("jax") +tc.set_dtype("complex64") +TOLERANCE = 1e-7 + + +def main(): + data = np.asarray([0.6 + 0.2j, -0.3 + 0.7j], dtype=np.complex64) + data /= np.linalg.norm(data) + cases = [] + for bit, theta in ((0, -0.37), (0, 1.23), (1, -0.37), (1, 1.23)): + ancilla = np.eye(2, dtype=np.complex64)[bit] + input_state = np.kron(ancilla, data) + rzz = np.asarray(K.numpy(tc.gates.rzz(theta=theta).tensor)).reshape(4, 4) + rz = np.asarray( + K.numpy(tc.gates.rz(theta=(1 - 2 * bit) * theta).tensor) + ).reshape(2, 2) + lhs = rzz @ input_state + rhs = np.kron(ancilla, rz @ data) + error = float(np.max(np.abs(lhs - rhs))) + cases.append({"bit": bit, "theta": theta, "max_abs_error": error}) + + maximum = max(case["max_abs_error"] for case in cases) + report = { + "schema_version": 1, + "task_id": "07", + "experiment": "e02", + "identity": "RZZ(theta_b)|b,psi> = |b> RZ((1-2b)theta_b)|psi>", + "dtype": "complex64", + "tolerance": TOLERANCE, + "cases": cases, + "max_abs_error": maximum, + "passed": maximum <= TOLERANCE, + } + print(json.dumps(report, indent=2)) + if not report["passed"]: + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/optimized_solutions/challenge-07/solution_7_conservative.py b/optimized_solutions/challenge-07/solution_7_conservative.py new file mode 100644 index 0000000..c6c5db7 --- /dev/null +++ b/optimized_solutions/challenge-07/solution_7_conservative.py @@ -0,0 +1,151 @@ +""" +Task Suite Problem 7: 16-qubit measurement-feedback VQE. + +The TensorCircuit-NG baseline uses cond_measure for ancilla measurements and +batches fixed trajectories with vmap for deterministic trajectory-averaged +energy optimization. +""" + +import numpy as np +import optax + +import tensorcircuit as tc + +K = tc.set_backend("jax") +tc.set_dtype("complex64") +tc.set_contractor("omeco-1-1") + +PARAMS_PER_LAYER = 48 + + +def initial_parameters(config): + rng = np.random.default_rng(config["seed"]) + return K.convert_to_tensor( + rng.normal( + scale=config["initial_parameter_scale"], + size=(config["n_layers"] * PARAMS_PER_LAYER,), + ).astype(np.float32) + ) + + +def trajectory_status(config): + rng = np.random.default_rng(config["seed"] + 1) + return K.convert_to_tensor( + rng.random( + (config["n_trajectories"], config["n_layers"] * config["n_ancilla_qubits"]), + dtype=np.float32, + ) + ) + + +def make_one_trajectory(config): + n_data = config["n_data_qubits"] + n_anc = config["n_ancilla_qubits"] + n_qubits = config["n_qubits"] + n_layers = config["n_layers"] + transverse_field = config["transverse_field"] + + pauli_strings = [] + weights = [] + for i in range(n_data - 1): + term = [0] * n_data + term[i] = 3 + term[i + 1] = 3 + pauli_strings.append(term) + weights.append(-1.0) + for i in range(n_data): + term = [0] * n_data + term[i] = 1 + pauli_strings.append(term) + weights.append(-transverse_field) + hamiltonian = tc.quantum.PauliStringSum2COO(pauli_strings, weights) + + def energy_of_data(c): + # The final Z-measured ancillas remain computational-basis states + # under diagonal RZZ feedback, so exactly one ancilla column is + # nonzero. Contract the adaptive circuit once, recover the data state, + # and evaluate all TFIM terms with one TensorCircuit-native operator. + full_state = K.reshape(c.state(), [2**n_data, 2**n_anc]) + data_state = K.sum(full_state, axis=1) + data_circuit = tc.Circuit(n_data, inputs=data_state) + return tc.templates.measurements.operator_expectation( + data_circuit, hamiltonian + ) + + def one_trajectory(params, status): + c = tc.Circuit(n_qubits) + pidx = 0 + sidx = 0 + + for _ in range(n_layers): + for q in range(n_data): + c.ry(q, theta=params[pidx + q]) + pidx += n_data + + for a in range(n_anc): + c.ry(n_data + a, theta=params[pidx + a]) + pidx += n_anc + + for a in range(n_anc): + c.rzz(n_data + a, a, theta=params[pidx + a]) + pidx += n_anc + + for a in range(n_anc - 1): + c.cnot(n_data + a, n_data + a + 1) + + theta0 = params[pidx : pidx + n_anc] + pidx += n_anc + theta1 = params[pidx : pidx + n_anc] + pidx += n_anc + + for a in range(n_anc): + anc = n_data + a + bit = c.cond_measure(anc, status=status[sidx]) + bitf = K.cast(bit, "float32") + feedback_theta = theta0[a] + bitf * (theta1[a] - theta0[a]) + c.rz( + a, + theta=(1.0 - 2.0 * bitf) * feedback_theta, + ) + sidx += 1 + + for q in range(n_data - 1): + c.cnot(q, q + 1) + + for q in range(n_data): + c.rz(q, theta=params[pidx + q]) + pidx += n_data + + return energy_of_data(c) + + return one_trajectory + + +def run_solution(config): + params = initial_parameters(config) + status = trajectory_status(config) + one_trajectory = make_one_trajectory(config) + batched_trajectories = K.jit(K.vmap(one_trajectory, vectorized_argnums=1)) + optimizer = optax.adam(config["learning_rate"]) + + def loss_fn(p): + return K.mean(batched_trajectories(p, status)) + + def train_step(p, state): + value, grads = K.value_and_grad(loss_fn)(p) + updates, state = optimizer.update(grads, state, p) + p = optax.apply_updates(p, updates) + return p, state, value + + train_step = K.jit(train_step) + opt_state = optimizer.init(params) + energy_history = [] + for _ in range(config["max_steps"]): + params, opt_state, value = train_step(params, opt_state) + energy_history.append(value) + + final_trajectory_energies = batched_trajectories(params, status) + return { + "energy_history": K.numpy(K.stack(energy_history)), + "final_trajectory_energies": K.numpy(final_trajectory_energies), + } From d0ad3900385a253257a69f0fe73987a203b28f9e Mon Sep 17 00:00:00 2001 From: qingyunqian Date: Thu, 30 Jul 2026 11:57:19 +0800 Subject: [PATCH 4/5] Simplify Task 07 optimization evidence --- README.md | 8 - .../README.md | 6 - .../challenge-01/solution_1_mpo.py | 0 .../challenge-05/solution_5_omeco.py | 0 .../CLASSICAL_ANCILLA_REDUCTION.md | 155 ---- optimized_solutions/challenge-07/README.md | 45 + .../audit_classical_ancilla_reduction.py | 381 --------- .../challenge-07/factor-ablation.svg | 279 ++++++ .../CLASSICAL_ANCILLA_REDUCTION_REPORT.md | 279 ------ .../research/IMPLEMENTATION_COMPARISON.md | 198 ----- .../challenge-07/research/INSIGHTS.md | 136 --- .../challenge-07/research/LOG.md | 800 ------------------ .../challenge-07/research/README.md | 15 - .../challenge-07/research/SURVEY.md | 216 ----- .../profiles/bootstrap-reference.json | 78 -- .../profiles/e01-single-state-screen.json | 73 -- .../profiles/e02-feedback-rz-screen.json | 62 -- .../profiles/e03-training-scan-screen.json | 35 - .../profiles/e04a-omeco-1x1-screen.json | 42 - .../research/profiles/e04b-greedy-screen.json | 19 - .../e05-measurement-round-screen.json | 43 - .../research/profiles/e06-vvag-screen.json | 18 - .../profiles/e07-classical-ancilla-audit.json | 30 - .../e11-contractor-six-pair-screen.json | 76 -- .../e11-final-canonical-six-pairs.json | 630 -------------- .../profiles/final-canonical-six-pairs.json | 123 --- .../profiles/final-reference-six.json | 141 --- .../research/run_docker_matrix.py | 418 --------- .../validate_classical_ancilla_reduction.py | 320 ------- .../research/validate_e01_equivalence.py | 116 --- .../research/validate_feedback_identity.py | 51 -- .../challenge-07/solution_7_conservative.py | 151 ---- 32 files changed, 324 insertions(+), 4620 deletions(-) rename {optimized_solutions => optimized_sloutions}/README.md (78%) rename {optimized_solutions => optimized_sloutions}/challenge-01/solution_1_mpo.py (100%) rename {optimized_solutions => optimized_sloutions}/challenge-05/solution_5_omeco.py (100%) delete mode 100644 optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md create mode 100644 optimized_solutions/challenge-07/README.md delete mode 100644 optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py create mode 100644 optimized_solutions/challenge-07/factor-ablation.svg delete mode 100644 optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md delete mode 100644 optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md delete mode 100644 optimized_solutions/challenge-07/research/INSIGHTS.md delete mode 100644 optimized_solutions/challenge-07/research/LOG.md delete mode 100644 optimized_solutions/challenge-07/research/README.md delete mode 100644 optimized_solutions/challenge-07/research/SURVEY.md delete mode 100644 optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json delete mode 100644 optimized_solutions/challenge-07/research/profiles/final-reference-six.json delete mode 100644 optimized_solutions/challenge-07/research/run_docker_matrix.py delete mode 100644 optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py delete mode 100644 optimized_solutions/challenge-07/research/validate_e01_equivalence.py delete mode 100644 optimized_solutions/challenge-07/research/validate_feedback_identity.py delete mode 100644 optimized_solutions/challenge-07/solution_7_conservative.py diff --git a/README.md b/README.md index 666ca43..34d671f 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,6 @@ Each task is framework-neutral; the required framework is selected only through The task-level map shows why a single pass rate is not enough: different frameworks and agents fail on different physical workflows, and valid artifacts can vary substantially in runtime relative to the expert TC reference. -### Challenge-design notes - -- [Challenge 07 exact classical-ancilla reduction](optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md) - documents an unexpected reduction of the published measurement-feedback - circuit, provides an independently auditable proof of concept, and discusses - whether future revisions should accept the reduction or strengthen the - intended mid-circuit-measurement contract. - ## What ORBIT-Q Measures Surface-level functional tests are not enough for scientific programming. diff --git a/optimized_solutions/README.md b/optimized_sloutions/README.md similarity index 78% rename from optimized_solutions/README.md rename to optimized_sloutions/README.md index 974c70b..84297ed 100644 --- a/optimized_solutions/README.md +++ b/optimized_sloutions/README.md @@ -19,9 +19,3 @@ Host: MacBook Pro with Apple M4 Pro, 14-core CPU, 48 GB memory. Software: JAX 0. | --- | --- | --- | ---: | --- | | `challenge-01/solution_1_mpo.py` | 2026-07-07 | `evaluate_1.py --solution solution_1_mpo --max-steps 500` | 19.34s | PASS | | `challenge-05/solution_5_omeco.py` | 2026-07-07 | `evaluate_5.py --solution solution_5_omeco --max-steps 600` (reference baseline 48.27s) | 34.85s | PASS | -| `challenge-07/solution_7_classical_ancilla.py` | 2026-07-29 | six paired canonical Docker runs; see `challenge-07/CLASSICAL_ANCILLA_REDUCTION.md` | 3.070839s mean | PASS | - -The Challenge 07 variant is intentionally labeled a challenge-design -reduction. It analytically removes the measured ancilla subsystem and should -not be interpreted as a generic speedup of framework-native mid-circuit -measurement. diff --git a/optimized_solutions/challenge-01/solution_1_mpo.py b/optimized_sloutions/challenge-01/solution_1_mpo.py similarity index 100% rename from optimized_solutions/challenge-01/solution_1_mpo.py rename to optimized_sloutions/challenge-01/solution_1_mpo.py diff --git a/optimized_solutions/challenge-05/solution_5_omeco.py b/optimized_sloutions/challenge-05/solution_5_omeco.py similarity index 100% rename from optimized_solutions/challenge-05/solution_5_omeco.py rename to optimized_sloutions/challenge-05/solution_5_omeco.py diff --git a/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md b/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md deleted file mode 100644 index fda9ba1..0000000 --- a/optimized_solutions/challenge-07/CLASSICAL_ANCILLA_REDUCTION.md +++ /dev/null @@ -1,155 +0,0 @@ -# Challenge 07: exact classical-ancilla reduction - -## Finding - -Challenge 07's reference is correct, but the published circuit admits an -unexpected exact reduction: - -```text -16 qubits x 64 measured trajectories - | - | analytic ancilla sampling - | prefix-XOR inversion - v -8 data qubits x unique weighted branches -``` - -For the public seed, the 64 complete two-layer trajectories contain only two -unique branches with multiplicities 63 and 1. The proof of concept evaluates -those two eight-qubit TensorCircuit circuits, weights them by `63/64` and -`1/64`, and reconstructs the required 64 final energies. - -This is a challenge-design loophole, not a generic acceleration of -framework-native mid-circuit measurement. The canonical task, evaluator, and -human reference are unchanged by this variant. - -Files in this directory: - -- `solution_7_classical_ancilla.py`: runnable proof of concept; -- `audit_classical_ancilla_reduction.py`: literal 16-qubit versus reduced - numerical audit. - -## Why the reduction is exact - -At the start of each layer, every ancilla is in a computational-basis state -`|b>`. After `RY(theta)`, its pre-ladder source bit `x` satisfies - -```text -P(x=1 | b=0) = sin(theta/2)^2, -P(x=1 | b=1) = cos(theta/2)^2. -``` - -The following data-ancilla `RZZ` is diagonal in the ancilla basis. Conditioned -on `x`, it applies a norm-preserving data unitary, so it cannot change the -ancilla Z-basis probability. - -The ordered ancilla ladder - -```text -CNOT(a[0], a[1]), ..., CNOT(a[6], a[7]) -``` - -is the reversible prefix-XOR map - -```text -m[0] = x[0], -m[i] = m[i-1] xor x[i], -x[i] = m[i] xor m[i-1]. -``` - -It can therefore be sampled analytically with the same fixed uniforms and -TensorCircuit's strict `status > 1-P(bit=1)` comparison. - -Conditioning on source and measured bits converts the two data-ancilla -interactions into data-only rotations: - -```text -RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta), -RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). -``` - -The rotations commute and are emitted as one summed `RZ` angle. The remaining -quantum computation is the original eight-data-qubit circuit and TFIM -expectation. - -For a fixed branch, projective normalization cancels the magnitude of the -ancilla `RY` amplitude. The discrete comparison has no pathwise derivative, -so the exact ancilla-angle gradients are zero and the branch table remains -fixed during Adam optimization. - -## Reproduction - -Run the self-contained audit from the repository root: - -```bash -python3 optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py -``` - -Run the 100-step proof of concept: - -```bash -PYTHONPATH="$PWD/optimized_solutions/challenge-07" \ - python3 tasks/challenge-07/tests/evaluate_7.py \ - --solution solution_7_classical_ancilla -``` - -The no-network, six-CPU/7-GiB TensorCircuit run produced: - -| Check | Result | -| --- | ---: | -| Canonical evaluator | PASS, 3.15 s | -| Full versus analytic measurement bits | all 1,024 equal | -| Unique branch counts | 63, 1 | -| Initial-energy absolute error | `1.1921e-5` | -| Maximum trajectory-energy error | `1.1444e-5` | -| Maximum non-ancilla gradient error | `1.9896e-6` | -| Full / reduced ancilla-gradient max | `4.6529e-7` / `0` | -| Post-one-Adam-update energy error | `3.3379e-6` | - -The tiny full-circuit ancilla gradient is complex64 contraction residue on an -exactly zero pathwise derivative. - -## Paired performance evidence - -A separate same-container benchmark used six CPUs, 7 GiB, no network, fresh -evaluator processes, and alternating pair order: - -| Metric | Human expert | Reduced variant | -| --- | ---: | ---: | -| Passing runs | 6/6 | 6/6 | -| Mean runtime | 140.076441 s | 3.070839 s | -| Median runtime | 140.069298 s | 3.046739 s | - -The reduced variant won 6/6 pairs. Mean paired speedup was 45.758x with a 95% -Student-t interval of [39.385x, 52.131x]. No successful value was filtered or -rerun. Full logs and hashes are preserved in -[OrbitBreakersExpertBenchmarks PR #11](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11). - -The proof-of-concept SHA-256 is -`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. -These are same-machine workload results, not a cross-hardware SOTA claim. - -## Benchmark implications - -The executable checks allow this solution because it still: - -- uses TensorCircuit for all remaining quantum evolution and expectations; -- consumes all fixed status rows and keeps the 96-parameter layout; -- performs exactly 100 Adam updates; -- returns the required history and 64 trajectory energies. - -It does not construct the ancilla register or call `cond_measure` during -optimization. If Challenge 07 is intended to measure framework support for -hybrid measurement-feedback programs, the stronger fix is to redesign the -circuit so that measurement probabilities depend on the data state, for -example with a non-diagonal ancilla operation after data-ancilla interaction. -Changing only the seed or trajectory count does not remove the analytic -controller. - -The problem statement also defines 64 trajectories but writes a `1/128` -objective, and repeats the "Data Post-Processing Layer" heading. These -documentation issues are independent of the reduction. - -Maintainers can either accept the reduction as scientific problem solving or -revise the circuit/policy to require intrinsic framework-native mid-circuit -measurement. diff --git a/optimized_solutions/challenge-07/README.md b/optimized_solutions/challenge-07/README.md new file mode 100644 index 0000000..f32eec3 --- /dev/null +++ b/optimized_solutions/challenge-07/README.md @@ -0,0 +1,45 @@ +# Task 07 — exact classical-ancilla reduction + +> **Take-home insight:** the published circuit does not require 64 full +> 16-qubit measured trajectories. Its measured ancillas form an analytically +> sampled classical controller, and the fixed workload contains only two unique +> eight-qubit branches with weights `63/64` and `1/64`. + +## Factor speedups + +| Factor | Measured speedup | Decision | +|---|---:|---| +| Eliminate the classical ancillas and merge duplicate trajectories | **45.758x** end to end | Keep — dominant | +| Whole-training `K.jaxy_scan` after reduction | 0.935x | Discard — regression | +| Explicit dense `RY`/`RZ` gate fusion after reduction | 0.849x | Discard — regression | +| Default local contractor over greedy | 1.044x | Keep default — minor | +| Default local contractor over OMECo 1x1 | 1.040x, CI crosses 1x | Do not switch | + +![Task 07 expert and reduced runtimes](factor-ablation.svg) + +## What the factors mean + +- **Classical-ancilla reduction:** sample the independent pre-ladder ancilla + bits analytically, invert the CNOT prefix-XOR exactly, and replace conditioned + `RZZ` operations with data-only `RZ` gates. +- **Trajectory merging:** evaluate the two unique fixed branch patterns once + and weight them by their multiplicities instead of contracting 64 duplicates. +- **Training scan:** compile all optimizer steps as one scan after the graph is + already small; its extra compile cost is not recovered here. +- **Dense gate fusion:** materialize fused local gates; this is slower than the + native small-gate sequence for the reduced circuit. +- **Contractor changes:** path-search tuning is negligible once only two + eight-qubit branches remain. + +## End-to-end result + +All six matched pairs passed. Mean runtime fell from `140.076441 s` to +`3.070839 s`, for a mean paired speedup of **45.757921x** (6/6 candidate +wins). This is an exact reduction of the published workload, but it also +exposes a challenge-design loophole rather than a generic mid-circuit +measurement acceleration. + +To preserve the intended framework test, a future task should require the full +measured register or use non-diagonal ancilla interactions that make +measurement probabilities depend on the data state; changing only the seed +does not close the reduction. diff --git a/optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py b/optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py deleted file mode 100644 index d76b126..0000000 --- a/optimized_solutions/challenge-07/audit_classical_ancilla_reduction.py +++ /dev/null @@ -1,381 +0,0 @@ -#!/usr/bin/env python3 -"""Audit the exact classical-ancilla reduction proposed for Task 07.""" - -from __future__ import annotations - -import argparse -import json -from pathlib import Path -from typing import Any - -import jax -import numpy as np -import optax -import tensorcircuit as tc - - -CONFIG = { - "n_data_qubits": 8, - "n_ancilla_qubits": 8, - "n_qubits": 16, - "n_layers": 2, - "n_trajectories": 64, - "initial_parameter_scale": 0.1, - "max_steps": 100, - "learning_rate": 0.02, - "seed": 2047, - "transverse_field": 1.05, - "minimum_improvement": 0.3, - "target_final_energy": -8.3, -} - -K = tc.set_backend("jax") -tc.set_dtype("complex64") -tc.set_contractor("greedy") - - -def initial_parameters() -> Any: - rng = np.random.default_rng(CONFIG["seed"]) - return K.convert_to_tensor( - rng.normal( - scale=CONFIG["initial_parameter_scale"], - size=(CONFIG["n_layers"] * 48,), - ).astype(np.float32) - ) - - -def trajectory_status() -> Any: - rng = np.random.default_rng(CONFIG["seed"] + 1) - return K.convert_to_tensor( - rng.random( - ( - CONFIG["n_trajectories"], - CONFIG["n_layers"] * CONFIG["n_ancilla_qubits"], - ), - dtype=np.float32, - ) - ) - - -def ready(value: Any) -> Any: - return jax.tree.map( - lambda leaf: leaf.block_until_ready() - if hasattr(leaf, "block_until_ready") - else leaf, - value, - ) - - -def exact_full_bits(params: Any, status: Any) -> Any: - c = tc.Circuit(CONFIG["n_qubits"]) - pidx = 0 - sidx = 0 - layers = [] - for _ in range(CONFIG["n_layers"]): - for q in range(CONFIG["n_data_qubits"]): - c.ry(q, theta=params[pidx + q]) - pidx += CONFIG["n_data_qubits"] - for a in range(CONFIG["n_ancilla_qubits"]): - c.ry(CONFIG["n_data_qubits"] + a, theta=params[pidx + a]) - pidx += CONFIG["n_ancilla_qubits"] - for a in range(CONFIG["n_ancilla_qubits"]): - c.rzz( - CONFIG["n_data_qubits"] + a, - a, - theta=params[pidx + a], - ) - pidx += CONFIG["n_ancilla_qubits"] - for a in range(CONFIG["n_ancilla_qubits"] - 1): - c.cnot( - CONFIG["n_data_qubits"] + a, - CONFIG["n_data_qubits"] + a + 1, - ) - theta0 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] - pidx += CONFIG["n_ancilla_qubits"] - theta1 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] - pidx += CONFIG["n_ancilla_qubits"] - bits = [] - for a in range(CONFIG["n_ancilla_qubits"]): - bit = c.cond_measure( - CONFIG["n_data_qubits"] + a, status=status[sidx] - ) - bitf = K.cast(bit, "float32") - feedback = theta0[a] + bitf * (theta1[a] - theta0[a]) - c.rz(a, theta=(1.0 - 2.0 * bitf) * feedback) - bits.append(bit) - sidx += 1 - for q in range(CONFIG["n_data_qubits"] - 1): - c.cnot(q, q + 1) - for q in range(CONFIG["n_data_qubits"]): - c.rz(q, theta=params[pidx + q]) - pidx += CONFIG["n_data_qubits"] - layers.append(K.stack(bits)) - return K.stack(layers) - - -def analytic_bits(params: Any, status: Any) -> tuple[Any, Any]: - previous_measured = K.zeros([CONFIG["n_ancilla_qubits"]], dtype="int32") - measured_layers = [] - pre_ladder_layers = [] - sidx = 0 - for layer in range(CONFIG["n_layers"]): - offset = layer * 48 - ancilla_angles = params[offset + 8 : offset + 16] - base_probability_one = K.sin(ancilla_angles / 2.0) ** 2 - previous_float = K.cast(previous_measured, "float32") - probability_one = base_probability_one + previous_float * ( - 1.0 - 2.0 * base_probability_one - ) - measured = [] - pre_ladder = [] - previous_output = K.convert_to_tensor(0, dtype="int32") - for a in range(CONFIG["n_ancilla_qubits"]): - previous_output_float = K.cast(previous_output, "float32") - measured_probability_one = probability_one[a] + previous_output_float * ( - 1.0 - 2.0 * probability_one[a] - ) - bit = K.cast( - status[sidx] > (1.0 - measured_probability_one), "int32" - ) - source_bit = bit + previous_output - 2 * bit * previous_output - measured.append(bit) - pre_ladder.append(source_bit) - previous_output = bit - sidx += 1 - previous_measured = K.stack(measured) - measured_layers.append(previous_measured) - pre_ladder_layers.append(K.stack(pre_ladder)) - return K.stack(measured_layers), K.stack(pre_ladder_layers) - - -def make_full_energy() -> Any: - """Build the literal 16-qubit measurement circuit used for comparison.""" - - def full_energy(params: Any, status: Any) -> Any: - c = tc.Circuit(CONFIG["n_qubits"]) - status_index = 0 - for layer in range(CONFIG["n_layers"]): - offset = layer * 48 - for q in range(CONFIG["n_data_qubits"]): - c.ry(q, theta=params[offset + q]) - for a in range(CONFIG["n_ancilla_qubits"]): - c.ry( - CONFIG["n_data_qubits"] + a, - theta=params[offset + 8 + a], - ) - for a in range(CONFIG["n_ancilla_qubits"]): - c.rzz( - CONFIG["n_data_qubits"] + a, - a, - theta=params[offset + 16 + a], - ) - for a in range(CONFIG["n_ancilla_qubits"] - 1): - c.cnot( - CONFIG["n_data_qubits"] + a, - CONFIG["n_data_qubits"] + a + 1, - ) - theta0 = params[offset + 24 : offset + 32] - theta1 = params[offset + 32 : offset + 40] - for a in range(CONFIG["n_ancilla_qubits"]): - bit = c.cond_measure( - CONFIG["n_data_qubits"] + a, - status=status[status_index], - ) - bit_float = K.cast(bit, "float32") - feedback = theta0[a] + bit_float * (theta1[a] - theta0[a]) - c.rz(a, theta=(1.0 - 2.0 * bit_float) * feedback) - status_index += 1 - for q in range(CONFIG["n_data_qubits"] - 1): - c.cnot(q, q + 1) - for q in range(CONFIG["n_data_qubits"]): - c.rz(q, theta=params[offset + 40 + q]) - - energy = 0.0 - for q in range(CONFIG["n_data_qubits"] - 1): - energy -= K.real(c.expectation_ps(z=[q, q + 1])) - for q in range(CONFIG["n_data_qubits"]): - energy -= CONFIG["transverse_field"] * K.real( - c.expectation_ps(x=[q]) - ) - return energy - - return full_energy - - -def make_reduced_energy() -> Any: - strings = [] - weights = [] - for i in range(CONFIG["n_data_qubits"] - 1): - term = [0] * CONFIG["n_data_qubits"] - term[i] = 3 - term[i + 1] = 3 - strings.append(term) - weights.append(-1.0) - for i in range(CONFIG["n_data_qubits"]): - term = [0] * CONFIG["n_data_qubits"] - term[i] = 1 - strings.append(term) - weights.append(-CONFIG["transverse_field"]) - hamiltonian = tc.quantum.PauliStringSum2COO(strings, weights) - - def reduced_energy(params: Any, pattern: Any) -> Any: - measured, pre_ladder = pattern - c = tc.Circuit(CONFIG["n_data_qubits"]) - for layer in range(CONFIG["n_layers"]): - offset = layer * 48 - for q in range(CONFIG["n_data_qubits"]): - c.ry(q, theta=params[offset + q]) - theta0 = params[offset + 24 : offset + 32] - theta1 = params[offset + 32 : offset + 40] - for q in range(CONFIG["n_data_qubits"]): - measured_float = K.cast(measured[layer, q], "float32") - source_float = K.cast(pre_ladder[layer, q], "float32") - feedback = theta0[q] + measured_float * ( - theta1[q] - theta0[q] - ) - angle = ( - (1.0 - 2.0 * source_float) * params[offset + 16 + q] - + (1.0 - 2.0 * measured_float) * feedback - ) - c.rz(q, theta=angle) - for q in range(CONFIG["n_data_qubits"] - 1): - c.cnot(q, q + 1) - for q in range(CONFIG["n_data_qubits"]): - c.rz(q, theta=params[offset + 40 + q]) - return tc.templates.measurements.operator_expectation(c, hamiltonian) - - return reduced_energy - - -def main() -> None: - parser = argparse.ArgumentParser() - parser.add_argument("--output", type=Path) - args = parser.parse_args() - - params = initial_parameters() - statuses = trajectory_status() - - full_bits = ready( - K.jit(K.vmap(exact_full_bits, vectorized_argnums=1))(params, statuses) - ) - analytic = K.jit(K.vmap(analytic_bits, vectorized_argnums=1)) - analytic_measured, analytic_pre_ladder = ready(analytic(params, statuses)) - patterns = K.stack([analytic_measured, analytic_pre_ladder], axis=1) - - pattern_array = np.asarray(patterns, dtype=np.int32) - flat_patterns = pattern_array.reshape(CONFIG["n_trajectories"], -1) - unique_flat, inverse, counts = np.unique( - flat_patterns, axis=0, return_inverse=True, return_counts=True - ) - unique_patterns = K.convert_to_tensor( - unique_flat.reshape(-1, 2, CONFIG["n_layers"], 8) - ) - inverse_tensor = K.convert_to_tensor(inverse, dtype="int32") - counts_tensor = K.convert_to_tensor(counts, dtype="float32") - - full_one = make_full_energy() - full_batch = K.jit(K.vmap(full_one, vectorized_argnums=1)) - reduced_one = make_reduced_energy() - reduced_batch = K.jit(K.vmap(reduced_one, vectorized_argnums=1)) - - def full_loss(p: Any) -> Any: - return K.mean(full_batch(p, statuses)) - - def reduced_loss(p: Any) -> Any: - values = reduced_batch(p, unique_patterns) - return K.sum(values * counts_tensor) / CONFIG["n_trajectories"] - - full_energy, full_grad = ready( - K.jit(K.value_and_grad(full_loss))(params) - ) - reduced_energy, reduced_grad = ready( - K.jit(K.value_and_grad(reduced_loss))(params) - ) - full_values = ready(full_batch(params, statuses)) - unique_values = ready(reduced_batch(params, unique_patterns)) - reduced_values = unique_values[inverse_tensor] - - ancilla_indices = np.array( - [*range(8, 16), *range(56, 64)], dtype=np.int32 - ) - non_ancilla_mask = np.ones(96, dtype=bool) - non_ancilla_mask[ancilla_indices] = False - full_grad_np = np.asarray(full_grad) - reduced_grad_np = np.asarray(reduced_grad) - - optimizer = optax.adam(CONFIG["learning_rate"]) - full_state = optimizer.init(params) - reduced_state = optimizer.init(params) - full_updates, full_state = optimizer.update(full_grad, full_state, params) - reduced_updates, reduced_state = optimizer.update( - reduced_grad, reduced_state, params - ) - full_post = optax.apply_updates(params, full_updates) - reduced_post = optax.apply_updates(params, reduced_updates) - full_post_energy = ready(K.jit(full_loss)(full_post)) - reduced_post_energy = ready(K.jit(reduced_loss)(reduced_post)) - - report = { - "schema_version": 1, - "task_id": "07", - "full_vs_analytic_bits_equal": bool( - np.array_equal(np.asarray(full_bits), np.asarray(analytic_measured)) - ), - "unique_pattern_count": int(len(unique_flat)), - "pattern_counts": [int(value) for value in counts], - "rare_trajectory_indices": [ - int(index) for index in np.where(inverse != inverse[0])[0] - ], - "initial_energy": { - "full": float(full_energy), - "reduced": float(reduced_energy), - "abs_error": abs(float(full_energy) - float(reduced_energy)), - }, - "trajectory_energy_max_abs_error": float( - np.max(np.abs(np.asarray(full_values) - np.asarray(reduced_values))) - ), - "gradient_max_abs_error": float( - np.max(np.abs(full_grad_np - reduced_grad_np)) - ), - "non_ancilla_gradient_max_abs_error": float( - np.max( - np.abs( - full_grad_np[non_ancilla_mask] - - reduced_grad_np[non_ancilla_mask] - ) - ) - ), - "full_ancilla_gradient_max_abs": float( - np.max(np.abs(full_grad_np[ancilla_indices])) - ), - "reduced_ancilla_gradient_max_abs": float( - np.max(np.abs(reduced_grad_np[ancilla_indices])) - ), - "post_update_parameter_max_abs_error": float( - np.max(np.abs(np.asarray(full_post) - np.asarray(reduced_post))) - ), - "post_update_energy": { - "full": float(full_post_energy), - "reduced": float(reduced_post_energy), - "abs_error": abs( - float(full_post_energy) - float(reduced_post_energy) - ), - }, - } - report["passed"] = bool( - report["full_vs_analytic_bits_equal"] - and report["unique_pattern_count"] == 2 - and report["initial_energy"]["abs_error"] <= 5e-5 - and report["non_ancilla_gradient_max_abs_error"] <= 5e-4 - and report["post_update_energy"]["abs_error"] <= 2e-3 - ) - rendered = json.dumps(report, indent=2, sort_keys=True) + "\n" - if args.output is not None: - args.output.write_text(rendered, encoding="utf-8") - print(rendered, end="") - if not report["passed"]: - raise SystemExit(1) - - -if __name__ == "__main__": - main() diff --git a/optimized_solutions/challenge-07/factor-ablation.svg b/optimized_solutions/challenge-07/factor-ablation.svg new file mode 100644 index 0000000..5bf64e1 --- /dev/null +++ b/optimized_solutions/challenge-07/factor-ablation.svg @@ -0,0 +1,279 @@ + + + + + + + + 2026-07-30T11:46:21.127397 + image/svg+xml + + + Matplotlib v3.10.8, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + 1 + + + + + + + + + + + + + + + + + + 1 + 0 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Mean evaluator runtime (s, log scale) + + + + + + + + + + + + + + Immutable expert + 64 × 16-qubit + + + + + + + + + + Exact reduction + 2 × 8-qubit + + + + + + + + + + + + + + + + + 140.076 s + + + 3.071 s + + + 45.758× mean paired speedup + 6 matched pairs; all runs passed + + + Exact classical-ancilla reduction removes the dominant work + + + + + + + + + diff --git a/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md b/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md deleted file mode 100644 index 5fc201c..0000000 --- a/optimized_solutions/challenge-07/research/CLASSICAL_ANCILLA_REDUCTION_REPORT.md +++ /dev/null @@ -1,279 +0,0 @@ -# Task 07 Challenge-Design Reduction Report - -## Executive result - -Task 07 appears to require 64 differentiable trajectories of a 16-qubit -mid-circuit measurement-feedback VQE. For the published circuit, that -description hides an exact reduction: - -```text -16 qubits x 64 measured trajectories - | - | exact analytic ancilla sampling - | exact reversible-bit inversion - v -8 data qubits x 2 unique weighted circuits -``` - -For the fixed public seed, 63 trajectories select the same all-zero -two-layer pattern and only trajectory 36 selects a second pattern. The final -implementation evaluates those two data-only TensorCircuit circuits, weights -them by `63/64` and `1/64`, and expands their final energies back to the -required 64 entries. - -In six counterbalanced canonical pairs, every cell passes and the reduced -candidate wins 6/6: - -| Metric | Human expert | Reduced candidate | -| --- | ---: | ---: | -| Passing runs | 6/6 | 6/6 | -| Mean runtime | 140.076441 s | 3.070839 s | -| Median runtime | 140.069298 s | 3.046739 s | -| Sample standard deviation | 15.386367 s | 0.124233 s | -| Standard error | 6.281458 s | 0.050718 s | -| Minimum / maximum | 123.286060 / 159.579514 s | 2.966582 / 3.311737 s | - -Ratio-of-means speedup is **45.615x** and evaluator time falls by -**97.8077%**. Mean paired speedup is **45.758x**, with a two-sided 95% -Student-t interval of **[39.385x, 52.131x]**. - -This is the repository campaign-best result for the public workload. It is -not a cross-hardware or global SOTA claim. - -## Why the reduction is exact - -### 1. The ancilla source distribution is classical - -At the beginning of each layer every ancilla is in a computational-basis -state. In layer zero that state is `|0>`; in the next layer it is the -previous measured bit `b`. - -After `RY(theta)`, the probability of the pre-ladder source bit `x=1` is: - -```text -P(x=1 | b=0) = sin(theta/2)^2 -P(x=1 | b=1) = cos(theta/2)^2 - = 1 - sin(theta/2)^2. -``` - -The following paired data-ancilla `RZZ` is diagonal in the ancilla -computational basis. Conditioned on `x`, it applies a unitary data rotation, -so it preserves the norm of each ancilla branch and cannot alter these -probabilities. Different ancillas remain independent before the ancilla -CNOT ladder. - -### 2. The CNOT ladder is a prefix XOR - -The expert applies the ordered ladder -`CNOT(a[0],a[1]), ..., CNOT(a[6],a[7])`. It maps independent source bits -`x` to measured bits `m` as: - -```text -m[0] = x[0] -m[i] = m[i-1] xor x[i] - = x[0] xor ... xor x[i]. -``` - -The map is bijective: - -```text -x[0] = m[0] -x[i] = m[i] xor m[i-1]. -``` - -Sequential measurement therefore has the simple conditional law -`m[i] = m[i-1] xor x[i]`. The implementation uses the same float32 uniforms -and the same strict TensorCircuit condition -`status > 1-P(m[i]=1)`. - -An independent audit compares this analytic rule with the full 16-qubit -TensorCircuit `cond_measure` program. All **1,024** bits -(`64 trajectories x 2 layers x 8 ancillas`) are identical. - -### 3. Conditioned quantum action stays on the data register - -Once `x` and `m` are fixed, the data-ancilla entangler and feedback gates -become data-only rotations: - -```text -RZZ_ent(theta) -> RZ_data((1 - 2*x) * theta) -RZZ_feedback(phi_m) -> RZ_data((1 - 2*m) * phi_m). -``` - -Both are Z rotations and commute, so the candidate emits their summed angle -as one native TensorCircuit `RZ` before the data CNOT ladder. The remaining -quantum circuit has eight data qubits and the unchanged open-boundary TFIM -Hamiltonian. - -### 4. Equal trajectories can be merged - -Applying the analytic sampler to all public fixed uniforms produces exactly -two complete two-layer patterns: - -| Pattern | Count | Trajectory indices | -| --- | ---: | --- | -| all measured/source bits zero | 63 | all except 36 | -| rare nonzero pattern | 1 | 36 | - -The rare measured-bit pattern, flattened by layer, is: - -```text -00001111 00001010 -``` - -Its inverse pre-ladder source pattern is: - -```text -00001000 00001111 -``` - -Because the objective is a mean over fixed trajectories, evaluating the two -unique circuits with weights `63/64` and `1/64` is algebraically identical -to evaluating 64 duplicates. - -## Numerical audit - -The proof is exact over real arithmetic. Complex64 contraction order changes -introduce small rounding differences, which are reported explicitly. - -| Check against full accepted 16-qubit implementation | Result | -| --- | ---: | -| Analytic/full measured bits equal | true | -| Initial energy absolute error | `4.7684e-6` | -| Maximum per-trajectory energy error | `4.2915e-6` | -| Maximum non-ancilla gradient error | `1.5116e-6` | -| Full ancilla gradient maximum magnitude | `4.6559e-7` | -| Reduced ancilla gradient maximum magnitude | `0` | -| Post-one-Adam-update energy error | `4.6730e-5` | -| Audit decision | PASS | - -The ideal pathwise derivative of a fixed discrete sample with respect to its -sampling angle is zero. The full complex64 graph leaves only sub-micro -rounding residue on those ancilla gradients. Adam can normalize tiny residue -into a visible parameter-coordinate movement, but parameters are not part of -the executable output contract and the physical energy checks remain close. - -The complete 100-update evaluator also passes: - -```text -initial history energy: -6.8462696075 -final history energy: -10.0277128220 -improvement: 3.1814432144 -final trajectory mean: -10.0331783295 -final trajectory std: 0.0007445384 -history length: 100 -``` - -## Formal six-pair benchmark - -All cells used one no-network Docker container, a fresh evaluator process, -six CPUs, 7 GiB, TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`, -and the unchanged 300-second limit. Pair order alternated to balance position. - -| Pair | Order | Expert (s) | Candidate (s) | Speedup | -| ---: | --- | ---: | ---: | ---: | -| 1 | expert -> candidate | 123.286060 | 3.062554 | 40.2560x | -| 2 | candidate -> expert | 126.247088 | 3.311737 | 38.1211x | -| 3 | expert -> candidate | 150.224728 | 2.989908 | 50.2439x | -| 4 | candidate -> expert | 129.913867 | 3.030923 | 42.8628x | -| 5 | expert -> candidate | 159.579514 | 3.063330 | 52.0935x | -| 6 | candidate -> expert | 151.207388 | 2.966582 | 50.9702x | - -No successful value was filtered or rerun. The report retains every raw -stdout/stderr hash and passes the frozen promotion rule. - -| Artifact | SHA-256 | -| --- | --- | -| Immutable expert | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | -| Reduced candidate | `0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e` | -| Evaluator | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | -| Docker image | `b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` | -| Staging snapshot | `d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f` | -| Paired report | `068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f` | - -## Secondary tuning after the reduction - -Once only two eight-qubit circuits remained, the earlier large-network -choices were re-evaluated: - -| Experiment | Canonical result | Decision | -| --- | ---: | --- | -| Python loop | 2.998 s exploratory | Keep | -| Whole-training `K.jaxy_scan` | 3.206 s | Reject | -| Explicit `RY`/`RZ` dense-gate fusion | 3.531 s | Reject | -| TensorNetwork greedy | 2.947 s six-run mean | Reject | -| OMECo 1x1 | 2.949 s six-run mean | Reject | -| TensorCircuit `plain-experimental` | 2.823/2.839 s comparison means | Keep | - -The local contractor beat greedy in 6/6 paired screens with a mean -`1.0442x` speedup and 95% interval `[1.0029x, 1.0855x]`. It beat OMECo-1x1 -in 5/6 pairs; that smaller `1.0395x` mean advantage has interval -`[0.9933x, 1.0856x]`. The default local setting was retained because it is -the simplest native small-graph choice and avoids OMECo path search. - -## Is this a valid optimization or a loophole? - -There are two defensible interpretations. - -Under the executable public contract, it is valid: - -- all 64 seeded statuses are consumed; -- all 96 parameters retain their layout; -- exactly 100 Adam updates are performed; -- the required pre-update history and 64 final trajectory energies are - returned; -- no energy, output, threshold, or reference value is hard-coded; -- TensorCircuit performs all remaining quantum gate evolution and Hamiltonian - expectations. - -Under the likely benchmark-design intent, it is a loophole: - -- the candidate no longer constructs 16 qubits; -- it does not call TensorCircuit `cond_measure` during optimization; -- it benchmarks an exact classical controller plus two eight-qubit circuits, - not generic differentiable mid-circuit measurement at scale. - -The problem statement does not explicitly prohibit exact analytic elimination -of measured ancillas or deduplication of fixed trajectories. If Task 07 is -intended to test TensorCircuit's mid-circuit measurement machinery, the -contract is under-specified. - -## Recommended maintainer action - -Keep two implementations visible: - -1. The registered `conservative` e04a variant at - `src/solutions/task-07/variants/solution_7_conservative.py` is the - appropriate answer when literal 16-qubit TensorCircuit `cond_measure` - execution is required. It preserves every intended operation and measured - a 4.479x paired speedup. -2. The e11 reduction is the campaign-best answer to the current executable - contract and should be used to document/fix the challenge-design gap. - -To close the loophole in a future benchmark revision, require at least one of: - -- explicit use of the full data-plus-ancilla register and framework-native - mid-circuit measurement in the timed region; -- hidden instances with randomized layer counts, ancilla coupling topology, - non-diagonal data-ancilla gates, or feedback that prevents branch - classicalization; -- trainable sampling distributions whose gradients are defined by a stated - estimator rather than pathwise differentiation through discrete branches; -- a policy check that rejects analytic elimination of the measured subsystem. - -The strongest fix is semantic rather than cosmetic: introduce a -non-computational-basis ancilla interaction after entanglement so that an -ancilla measurement probability genuinely depends on the data state. Merely -changing the seed or increasing trajectory count does not remove the -reduction; it only changes the number of unique classical patterns. - -## PR positioning - -Suggested title: - -`Task 07: expose exact classical-ancilla reduction (45.76x paired)` - -The PR should explicitly label this as a challenge-design reduction, link the -full audit and conservative 4.48x alternative, and invite maintainers to -decide whether the public executable contract or the intended -mid-circuit-measurement semantics should govern acceptance. diff --git a/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md b/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md deleted file mode 100644 index 7ce23f9..0000000 --- a/optimized_solutions/challenge-07/research/IMPLEMENTATION_COMPARISON.md +++ /dev/null @@ -1,198 +0,0 @@ -# Task 07 Conservative Human-Expert Optimization Report - -> **Status:** retained as the literal 16-qubit / `cond_measure` fallback. -> The current executable-contract winner is the exact classical-ancilla -> reduction documented in -> [`CLASSICAL_ANCILLA_REDUCTION_REPORT.md`](CLASSICAL_ANCILLA_REDUCTION_REPORT.md): -> 3.070839-second candidate mean versus 140.076441-second expert mean, -> 45.757921x mean paired speedup, 95% CI -> [39.384711x, 52.131131x]. Unlike the conservative implementation below, -> that candidate exposes a challenge-design loophole and does not literally -> execute the measured ancilla register. The implementation below is retained -> as the runnable `conservative` variant at -> `src/solutions/task-07/variants/solution_7_conservative.py`. - -## Scope and claim - -This campaign optimizes only ORBIT-Q Task 07: the 16-qubit, two-layer -measurement-feedback VQE with 64 fixed trajectories and exactly 100 Adam -updates. - -The conservative candidate passes all public functional checks in all six measured -runs and wins all six counterbalanced pairs against the immutable human -expert. Mean paired speedup is **4.479x**, with a two-sided 95% Student-t -interval of **[3.891x, 5.067x]**. Ratio-of-means speedup is **4.438x** -(77.47% lower runtime). - -No external implementation reports a matched runtime for this exact -evaluator, seed, trajectory batch, container, and software stack. The result -was the **campaign-best / repository-SOTA Task 07 implementation before the -exact e11 reduction**, not a global hardware-independent SOTA claim. - -| Artifact | Path | SHA-256 | -| --- | --- | --- | -| Immutable human expert | `references/task-07/solution_7.py` | `ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3` | -| Final candidate | `src/solutions/task-07/solution_7.py` | `0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592` | -| Evaluator | `tasks/task-07/evaluator/evaluate_7.py` | `69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31` | -| Paired report | `profiles/final-canonical-six-pairs.json` | `6e03db1f37e8bbe0b38247f017d9259177a2858d54289fa2a5615542b499b54a` | -| Reference gate report | `profiles/final-reference-six.json` | `743f493120dd89e6c75a309499c28d819ae00aee09d57e7feb374b35c0310224` | - -## Final paired result - -All measurements used one no-network Docker container, six CPUs, 7 GiB, -TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`, and a fresh -evaluator process per cell. Odd pairs ran reference then candidate; even -pairs reversed the order. - -| Metric | Human expert | Candidate | -| --- | ---: | ---: | -| Passing runs | 6/6 | 6/6 | -| Mean runtime | 116.264691 s | 26.196276 s | -| Median runtime | 114.756293 s | 24.598863 s | -| Sample standard deviation | 10.035012 s | 2.980442 s | -| Standard error | 4.096777 s | 1.216760 s | -| Minimum / maximum | 106.038165 / 131.316223 s | 24.221592 / 31.684172 s | - -| Pair | Order | Expert (s) | Candidate (s) | Speedup | -| ---: | --- | ---: | ---: | ---: | -| 1 | expert -> candidate | 106.038165 | 24.481295 | 4.3314x | -| 2 | candidate -> expert | 119.427967 | 24.221592 | 4.9306x | -| 3 | expert -> candidate | 123.188182 | 24.716431 | 4.9841x | -| 4 | candidate -> expert | 107.532991 | 24.421997 | 4.4031x | -| 5 | expert -> candidate | 110.084619 | 31.684172 | 3.4744x | -| 6 | candidate -> expert | 131.316223 | 27.652166 | 4.7489x | - -The candidate wins 6/6 pairs. Mean pairwise speedup is 4.478752x -(standard error 0.228662x); the frozen Student-t rule gives -`4.478752 +/- 2.5705818366 * 0.228662`, or -**[3.890959x, 5.066545x]**. The lower bound exceeds 1.0, so every research -and promotion gate passes. - -## Why the expert is slow - -The expert performs three expensive generic operations: - -1. Each trajectory energy is seven separate `ZZ` plus eight separate `X` - `expectation_ps` calls. The same final adaptive tensor network is - contracted 15 times in both forward and gradient work. -2. After each Z measurement, `conditional_gate` still builds and selects a - dense two-qubit `RZZ` tensor, even though the measured ancilla is already - a computational-basis eigenstate. -3. The expert requests OMECo `TreeSA(ntrials=32,niters=32)`. Path search lies - inside the timed first JAX trace, and this simplified 16-qubit graph does - not benefit enough from the extra search. - -Update-count profiling confirms the split: the expert's one-step run takes -47.853 seconds, while 100 steps take 135.816 seconds. Both graph/path -construction and repeated quantum contractions matter. - -## Final implementation - -### 1. Contract the final trajectory once - -The final ancillas were Z-measured and are subsequently touched only by -diagonal feedback. The state therefore factorizes: - -`|Psi_final> = |psi_data> tensor |measured ancilla bitstring>`. - -The candidate contracts the TensorCircuit state once, reshapes it to -`(2^8, 2^8)`, and sums the ancilla basis axis; exactly one column is nonzero. -It initializes an eight-qubit TensorCircuit from that data state and evaluates -the complete TFIM with one TensorCircuit-native sparse operator built by -`PauliStringSum2COO` and -`templates.measurements.operator_expectation`. - -This replaces 15 final-circuit expectation contractions with one state -contraction and one small sparse Hamiltonian expectation. The isolated e01 -canonical screen falls from 135.816 to 61.397 seconds. - -### 2. Reduce measured feedback exactly - -For measured ancilla bit `b`, TensorCircuit's convention gives the exact -identity - -`RZZ(theta_b) |b,psi> = - |b> RZ((1-2b) theta_b) |psi>`. - -The candidate selects the same independent `theta0/theta1` parameter and -applies the signed angle through the native data-qubit `c.rz`. The ancilla is -unchanged, so the identity remains valid before the next layer. - -An independent four-case complex64 matrix-action audit covers both bits and -two signed angles; maximum error is `2.98e-8` under a frozen `1e-7` -tolerance. Removing 16 selected two-qubit nodes lowers the canonical screen -again from 61.397 to 33.546 seconds. - -### 3. Match path-search effort to the simplified graph - -The final source requests `omeco-1-1`, the TensorCircuit-NG native shortcut -for one TreeSA trial and iteration. The path remains adequate: 50- and -100-step evaluators pass with final energies matching the expert. Timed search -latency falls enough to lower the canonical screen from 33.546 to 24.362 -seconds. - -This is not a framework patch or an environment override. Both roles use the -same latest TensorCircuit-NG image; only the candidate asks the existing -framework contractor for a smaller task-appropriate search budget. - -## Preserved scientific semantics - -The candidate retains: - -- eight data and eight ancilla qubits, two adaptive layers, and the exact - order of all data/ancilla rotations, entanglers, measurements, feedback, - and CNOT ladders; -- all 96 independent trainable parameters and their seeded float32 - initialization; -- the same 64x16 seed-2048 float32 trajectory-uniform matrix, all 64 - trajectories, all 16 normalized TensorCircuit `cond_measure` operations - per trajectory, and identical bit/trajectory order; -- the two independent feedback angles for each measured pair; -- the open-boundary eight-site TFIM with transverse field 1.05; -- exactly 100 sequential Optax Adam updates at learning rate 0.02, recording - every pre-update energy; -- the final post-update 64-entry trajectory vector; -- complex64 TensorCircuit/JAX quantum computation and the exact output - keys/shapes. - -All six candidate canonical runs pass energy decrease, minimum improvement, -target energy, history length, trajectory shape, and NumPy output checks. - -## Explored alternatives - -| Experiment | Result | Decision | -| --- | --- | --- | -| e01: one native state/Hamiltonian expectation | 61.397 s canonical screen; energy/gradient errors `3.34e-6` / `1.01e-6` | Keep | -| e02: exact feedback `RZZ -> RZ` | 33.546 s; identity error `2.98e-8` | Keep | -| e03: whole-training `K.jaxy_scan` | 36.747 s vs 33.546 s | Reject: extra control-flow compilation | -| e04a: OMECo 1x1 | 24.362 s | Keep | -| e04b: greedy contractor | 23.234 s one-step vs 20.672 s for 1x1 | Reject | -| e05: joint state-based measurement rounds | fastest at 1/50 steps (4.606/14.523 s), but 26.531 s at 100 | Reject for canonical; dense-state AD crossover | -| e06: `K.vvag` trajectory gradients | 39.420 s one-step | Reject: mapped reverse-mode duplication | - -The e05 crossover is useful beyond this exact evaluator: state materialization -is excellent when staging dominates or updates are few, whereas native -tensor-network `cond_measure` wins once many gradients amortize compilation. - -## Measurement integrity and report recovery - -The paired runner successfully wrote all 24 raw stdout/stderr files and -stopped the container after all 12 passing cells. It then hit a final -serialization typo (`true` instead of Python `True`). The bug occurred after -measurement and did not affect source bytes, ordering, runtimes, or outputs. - -The runner is fixed and now checkpoints every completed cell. The tracked -paired report was reconstructed from all 12 raw logs without rerunning, -filtering, or changing any value; it records every stdout SHA-256 and the -staging snapshot hash. The fail-closed gate reports `promotion_ready: true`. - -## PR summary - -Suggested title: - -`Task 07: collapse repeated energy/feedback contractions (4.48x)` - -The PR should emphasize that the gain comes from exact Task 07 structure and -existing TensorCircuit-NG primitives—not fewer trajectories, fewer updates, -changed thresholds, hard-coded outputs, a framework downgrade, or a raw -NumPy/JAX simulator. diff --git a/optimized_solutions/challenge-07/research/INSIGHTS.md b/optimized_solutions/challenge-07/research/INSIGHTS.md deleted file mode 100644 index 094a60a..0000000 --- a/optimized_solutions/challenge-07/research/INSIGHTS.md +++ /dev/null @@ -1,136 +0,0 @@ -# Task 07 Research Insights - -Task: `task-07` - -Last consolidated: 2026-07-29 - -Evidence ledger: [`LOG.md`](LOG.md) - -## Current best - -Experiment `e11` analytically eliminates the measured ancilla subsystem, -deduplicates the 64 fixed trajectories into two weighted patterns, and runs -the remaining eight-qubit data circuits with TensorCircuit's native local -contractor. Six final counterbalanced Docker pairs all pass and all win: -candidate mean 3.070839 seconds versus expert mean 140.076441 seconds; mean -paired speedup 45.757921x (95% Student-t CI -39.384711x-52.131131x). - -This is explicitly a challenge-design reduction. The conservative `e04a` -implementation remains available when literal 16-qubit `cond_measure` -execution is required; its six-pair result is 4.478752x. - -## Preserved semantics - -- Two adaptive layers and all 96 float32 parameters in the expert's layout; - ancilla rotation parameters remain in place but have their exact zero - pathwise gradients. -- Seed 2047 parameter initialization and seed 2048 fixed trajectory uniforms. -- The exact measured/source bits selected by all 1,024 fixed-uniform - comparisons, with the selected trainable feedback branch for every bit. -- Exactly 64 fixed trajectories averaged per objective and exactly 100 - sequential Adam updates at learning rate 0.02; equal trajectories are - evaluated once with exact multiplicity weights. -- Pre-update energy history and post-update per-trajectory energy vector. -- The eight-site open-boundary TFIM Hamiltonian and complex64 TensorCircuit - quantum computation on the remaining data register. - -Not preserved literally: construction of the eight ancilla qubits and -framework-native `cond_measure` calls. That distinction is the loophole and -must remain visible in any PR. - -## Confirmed bottlenecks - -- Every trajectory evaluates seven `ZZ` and eight `X` expectations separately, - repeating the final circuit's bra/ket contraction 15 times in both forward - and reverse-mode work. -- Approximately 48 seconds is fixed trace/compile/path/finalization cost; the - additional 99 canonical updates average about 0.89 seconds each. -- The generic `conditional_gate` keeps a selected dense two-qubit `RZZ` node - after the ancilla is already a Z eigenstate. - -## What worked - -- The ancilla circuit is exactly a classical Bernoulli source followed by a - prefix-XOR permutation. Full TensorCircuit and analytic sampling agree on - all 1,024 measured bits. -- The fixed public batch has only two unique complete patterns, with counts - 63 and 1. Replacing 64 sixteen-qubit trajectory graphs by two weighted - eight-qubit circuits lowers the canonical screen to about 3 seconds. -- TensorCircuit's `plain-experimental` local contractor is better suited to - the reduced graph than greedy or OMECo-1x1. It beats greedy in 6/6 - contractor pairs. -- One TensorCircuit state contraction plus one native sparse eight-qubit TFIM - expectation reduces the 100-step screen from 135.816 to 61.397 seconds and - the 50-step passing screen from 91.540 to 52.769 seconds. -- One-trajectory energy and gradient agree within `3.34e-6` and `1.01e-6`; - the full 50/100-step physical outputs pass and remain close. -- Reducing post-measurement - `RZZ(theta_b)|b,psi>` to - `|b> RZ((1-2b)theta_b)|psi>` removes 16 selected two-qubit nodes. The - identity audit's maximum complex64 error is `2.98e-8`; canonical runtime - falls again from 61.397 to 33.546 seconds. - -## Measurement lesson - -- Maximum first-Adam parameter difference is a poor complex64 equivalence - gate near zero gradients. The strict e01 diagnostic failed (`0.0313`) even - though energy, gradient, post-update energy, and complete public workloads - passed. Preserve that failure, but use physical post-update outputs as the - predeclared one-step semantic criterion in later experiments. - -## What did not work - -- On the reduced graph, whole-training scan remains slower (3.206 versus - 2.998 seconds in the exploratory screen), and explicit `RZ*RY` dense-gate - fusion is slower again at 3.531 seconds. -- Whole-training `K.jaxy_scan` is correct but slower after e02: 36.747 versus - 33.546 seconds for 100 steps and 34.917 versus 31.300 seconds for 50. - Control-flow compilation outweighs only 100 cached-JIT host dispatches. -- TensorNetwork greedy takes 23.234 seconds for the frozen one-step screen, - 12.39% slower than OMECo 1x1, so it was discarded before full training. -- Joint TensorCircuit-state measurement rounds are the fastest 1/50-step - method (4.606/14.523 seconds) and closely reproduce the expert, but dense - 16-qubit state differentiation raises the 100-step time to 26.531 seconds, - 8.90% slower than e04a. This exposes a crossover between staging cost and - per-update dense-state cost. -- TensorCircuit `K.vvag` is 90.69% slower at one step (39.420 seconds) because - it maps individual reverse-mode programs; differentiating the shared mapped - mean remains superior here. - -## Contractor result - -- After simplifying the graph, OMECo 32x32 over-searches. The 1x1 budget - lowers the passing canonical screen from 33.546 to 24.362 seconds and the - 50-step screen from 31.300 to 21.473 seconds without hurting convergence. - -## High-confidence exact identities - -- Final ancillas factor from the data state because the last operation that - can mix their computational basis is followed by `cond_measure`, and the - remaining feedback is diagonal. This permits one full TensorCircuit state - contraction followed by an eight-qubit native Hamiltonian expectation. -- On a measured ancilla `|b>`, feedback `RZZ(theta_b)` is exactly data - `RZ((1-2b) theta_b)` with the ancilla unchanged. -- A `K.jaxy_scan` can emit the same pre-update values while carrying the same - Optax state and final parameters. - -## Open hypotheses - -- None for the current fixed workload. Further closed-form elimination of the - eight-qubit data circuit would likely violate the framework-fidelity policy - and is unnecessary for exposing the challenge-design issue. - -## Evidence limits - -- No matched external implementation exists, so “SOTA” can mean only the - campaign-best implementation for this repository workload. -- No scaling or cross-hardware claim is supported. -- The 45.76x implementation satisfies the executable output contract but may - be rejected if maintainers interpret Task 07 as requiring literal - mid-circuit TensorCircuit measurement. The conservative 4.48x candidate is - the fallback under that interpretation. -- In the earlier conservative e04a run, long-session thermal/system noise - widened candidate times to 24.222-31.684 seconds; no value was filtered. - The final e11 candidate ranged from 2.967 to 3.312 seconds, also without - filtering. diff --git a/optimized_solutions/challenge-07/research/LOG.md b/optimized_solutions/challenge-07/research/LOG.md deleted file mode 100644 index 329203c..0000000 --- a/optimized_solutions/challenge-07/research/LOG.md +++ /dev/null @@ -1,800 +0,0 @@ -# Task 07 Autoresearch Campaign - -Destination: `research/task-07/LOG.md` - -Task: `task-07` - -Insights: [`INSIGHTS.md`](INSIGHTS.md) - -## Campaign selection and setup - -Selected task: `task-07` (16-qubit measurement-feedback VQE). - -Base commit: `5af98f27b9404c513df8eee0f4568b1512edee19`. - -Branch: `codex/orbitbreakers/task-07/extreme-native`. - -Worktree: -`/Users/qqy/.codex/visualizations/2026/07/28/019fa982-7244-7e20-99f5-f609bdd0cf27/task07-extreme`. - -The branch and worktree were created before the Task 07 survey and candidate -files. No candidate source was edited before the survey and public workload -gates were completed. - -Open pull requests in `hmyuuu/OrbitBreakersExpertBenchmarks` were inspected -before selection. The open optimization PRs covered Tasks 08, 09, and 10; -none covered Task 07. - -## Immutable expert bootstrap: canonical - -Date: 2026-07-29 - -Reference SHA-256: -`ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3`. - -Evaluator SHA-256: -`69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31`. - -Docker image: -`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` -(TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`). - -Allocation: six CPUs, 7 GiB memory, no network; timeout 300 seconds. - -```text -workload: canonical max_steps=100 -terminal_status: SUCCESS -valid: true -runtime_sec: 135.815605 -initial_energy: -6.8462643623 -final_history_energy: -10.0279636383 -improvement: 3.1816992760 -final_trajectory_mean: -10.0333871841 -final_trajectory_std: 0.0000000000 -history_length: 100 -``` - -Decision: `bootstrap baseline`. A performance claim still requires six -matched reference/candidate pairs in one container. - -## Immutable expert update-count profile - -Date: 2026-07-29 - -All runs used the same source, image, six-CPU/7-GiB limits, seed, layers, -trajectory batch, output schema, thresholds, and evaluator. Only the -evaluator-supported `--max-steps` argument changed. - -| Updates | Runtime (s) | Final history energy | Overall | -| ---: | ---: | ---: | --- | -| 1 | 47.853128 | -6.8462719917 | FAIL (expected thresholds) | -| 10 | 51.638506 | -7.4798407555 | FAIL (target) | -| 20 | 60.074862 | -7.8647251129 | FAIL (target) | -| 32 | 69.596274 | -8.1460399628 | FAIL (target) | -| 50 | 91.540316 | -8.7927856445 | PASS | -| 100 | 135.815605 | -10.0279636383 | PASS | - -The one-step run establishes about 48 seconds of fixed trace, compilation, -contraction-path, and final-evaluation work. The remaining 99 canonical -updates add approximately 0.89 seconds each. Decision: prioritize the -per-step energy/gradient contractions, retain 50 updates as a passing screen, -and make claims only on the canonical 100-step case. - -## Frozen hypotheses - -The complete pre-edit hypothesis definitions and falsification rules are in -`SURVEY.md`. - -Primary experiment: `e01`, single native TensorCircuit state contraction plus -one native sparse eight-data-qubit Hamiltonian expectation per trajectory. - -Secondary experiments, each isolated from the latest accepted commit: - -- `e02`: exact measured-ancilla feedback `RZZ` to data `RZ` reduction; -- `e03`: whole-training `K.jaxy_scan`; -- `e04`: OMECo contractor-budget sweep; -- `e05`: native-state measurement-round reuse, only if lower-risk ideas leave - substantial headroom. - -## Experiment `e01` - -Branch: `codex/orbitbreakers/task-07/e01-single-state-energy`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e01-single-state-energy`. - -Parent commit: `21d7271` (`research: freeze task 07 optimization campaign`). - -### Hypothesis - -Replacing 15 separate per-trajectory Pauli expectation contractions with one -TensorCircuit `state` contraction and one TensorCircuit-native sparse TFIM -operator expectation materially reduces trace/compile and repeated gradient -cost while preserving energies, gradients, one Adam update, all 100 -pre-update history values, and the final trajectory vector within declared -complex64 tolerances. - -### Pre-run frozen environment - -Public dataset version: `orbitq-workloads-v20260729.5`. - -Private evaluation used: `no`. - -Reference/evaluator/image hashes: as recorded above. - -Pair order for final promotion: odd `reference -> candidate`, even -`candidate -> reference`; six pairs; 300-second cap. - -The one-trajectory equivalence check is frozen before execution at absolute -tolerances `5e-5` for energy, `5e-4` for the maximum gradient element, and -`2e-5` for the maximum parameter difference after one Adam update. These are -strict complex64 path-rounding tolerances and are not evaluator thresholds. - -### Result - -Candidate hypothesis commit: `1e21dd41f47e3beb84b937144324227eac544b6d`. - -Candidate SHA-256: -`30f0f45073e866c7fbb24cd9a5c33d8c1254e6985136937cd454b82990681678`. - -Candidate diff SHA-256: -`3396c6b65d3f6c2eaebc647d6251547dd6561d1defac4526f9f503b2dcac8b7e`. - -Sanitized record: `profiles/e01-single-state-screen.json`. - -```text -max_steps=1: reference 47.853128 s, candidate 44.917110 s -max_steps=10: reference 51.638506 s, candidate 46.100052 s -max_steps=50: reference 91.540316 s, candidate 52.769482 s, both PASS -max_steps=100: reference 135.815605 s, candidate 61.396553 s, both PASS -canonical single-screen speedup: 2.2121x -``` - -The candidate canonical run passed every evaluator gate with initial energy -`-6.8462653160`, final history energy `-10.0263500214`, improvement -`3.1800847054`, final trajectory mean/std -`-10.0319023132 / 0.0014687895`, history length 100, and the exact required -keys and shapes. - -The predeclared one-trajectory audit measured energy error `3.34e-6` and -maximum gradient error `1.01e-6`, both comfortably passing. Its strict -maximum parameter-difference check after one first Adam update failed: -`3.13e-2` versus `2e-5`, although mean parameter difference was `2.43e-3`. -This failure is retained, not filtered. - -Decision: `keep provisionally`. The state/observable identity is exact, -energy and gradient checks pass, the one-step post-update physical energy -differs by only `2.29e-5`, and the 50/100-step public workloads both pass with -nearly identical energy trajectories. The failed parameter metric reflects -the ill-conditioning of first-step Adam updates near zero: Adam normalizes -each gradient component by its magnitude, so a complex64 sign change in an -otherwise negligible component can create an order-learning-rate parameter -difference without a corresponding energy difference. Final paired -performance evidence is still pending. - -## Append-only corrections - -Append corrections below this heading. Never rewrite a result after it has -informed another experiment. - -### Correction: e01 one-update acceptance observable - -The strict per-parameter first-Adam maximum was over-specified as a semantic -criterion. The executable contract does not return parameters, and this -metric is discontinuously sensitive at zero gradient. It remains visible as -a failed diagnostic. Subsequent candidates will predeclare post-update -energy/trajectory checks as the physical one-update criterion while continuing -to report gradient errors and any parameter differences. - -## Experiment `e02`: measured-ancilla feedback reduction - -Branch: `codex/orbitbreakers/task-07/e02-feedback-rz`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e02-feedback-rz`. - -Parent commit: `2e5cd61` (accepted e01 code and complete provisional evidence). - -### Hypothesis - -After `cond_measure`, ancilla `a` is the Z eigenstate with eigenvalue -`1-2*bit`. Therefore the selected -`RZZ(theta_bit)` on `(ancilla_a, data_a)` is exactly -`RZ((1-2*bit)*theta_bit)` on the data qubit, with the ancilla unchanged. -Replacing all 16 generic selected two-qubit tensors with those native -TensorCircuit `RZ` gates reduces graph/path/gradient work without changing -any measurement, selected parameter, branch state, or observable. - -### Pre-run frozen checks - -The exact two-branch gate identity will be checked at complex64 precision. -The frozen matrix-action tolerance is `1e-7` for both bit values and two -nontrivial signed angles. -The physical one-step criteria are initial energy absolute error at most -`5e-5` versus accepted e01 and post-update final-trajectory mean absolute -error at most `1e-4`; the strict parameter maximum remains diagnostic only. -Both the public 50-step and canonical 100-step evaluators must pass. A -candidate is retained only if its canonical screen is faster than e01's -61.396553 seconds. - -### Result - -Candidate hypothesis commit: `067a1d365e8ef4a9e3f81d6dd62939c0b3af6b39`. - -Candidate SHA-256: -`b3dcbaa35a233d8dde4576de7257c79a1a81034eee49f1f0bef6489116dcafcd`. - -Candidate diff SHA-256: -`759b7139a8463d53c80f2d48148eca189235a872fac5402ae9f64be4100bac45`. - -Sanitized record: `profiles/e02-feedback-rz-screen.json`. - -The independent two-branch matrix-action audit passed all four cases. Maximum -complex64 error was `2.98e-8` against the frozen `1e-7` threshold. - -```text -max_steps=1: e01 44.917110 s, e02 29.918828 s -max_steps=50: reference 91.540316 s, e01 52.769482 s, - e02 31.299628 s, e02 PASS -max_steps=100: reference 135.815605 s, e01 61.396553 s, - e02 33.546170 s, e02 PASS -canonical e02/reference single-screen speedup: 4.0487x -canonical e02/e01 single-screen speedup: 1.8302x -``` - -The one-step initial energy and post-update trajectory-mean differences from -accepted e01 are `1.43e-6` and `7.53e-5`, passing the frozen `5e-5` and -`1e-4` physical thresholds. The canonical run passed every evaluator gate: -initial `-6.8462653160`, final history `-10.0280771255`, improvement -`3.1818118095`, final trajectory mean/std -`-10.0335464478 / 0.0000002666`, history length 100, required keys/shapes. - -Decision: `keep`. The exact feedback reduction removes a major trace, -path-search, contraction, and gradient burden. Proceed from e02 to isolate -whole-training scan. - -## Experiment `e03`: whole-training TensorCircuit scan - -Branch: `codex/orbitbreakers/task-07/e03-training-scan`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e03-training-scan`. - -Parent commit: `74d632d` (accepted e02 implementation and evidence). - -### Hypothesis - -Carrying parameters and the Optax state through `K.jaxy_scan` for exactly 100 -iterations and emitting each pre-update value preserves the sequential Adam -trajectory while eliminating 100 Python-to-JAX dispatches. The expected gain -is small because e02's step is already cheap relative to compilation. - -### Pre-run frozen checks - -The public 50-step and canonical 100-step evaluators must both pass. Initial, -final-history, and post-update trajectory-mean energies must remain within -`5e-3` of accepted e02, allowing normal complex64 optimizer divergence but -not a changed objective. Retain only if the canonical screen is faster than -e02's 33.546170 seconds. - -### Result - -Candidate hypothesis commit: `8b977faa5a9eea4e4ead88e24f4193cbfbc66aa0`. - -Candidate SHA-256: -`767c82d6c0be9af2ee526d130afba3f6eb95d81d42efcbb7f62665a9753a3b2c`. - -Candidate diff SHA-256: -`5bffe6df6108a72656dfd56cdc9d4a39aeaaa0037e3545e3d4bb1a754d4229d3`. - -Sanitized record: `profiles/e03-training-scan-screen.json`. - -```text -max_steps=50: e02 31.299628 s, scan 34.916768 s, scan/e02 1.11556 -max_steps=100: e02 33.546170 s, scan 36.747307 s, scan/e02 1.09542 -``` - -Both scan runs passed every evaluator criterion. The canonical initial, -final-history, and final-trajectory-mean energies differ from e02 by -`6.68e-6`, `1.80e-3`, and `1.71e-3`, all within the frozen `5e-3` -physical threshold. - -Decision: `discard`. Staging the already optimized value/gradient/Adam body -inside a scan adds more control-flow compile cost than 100 cached-JIT Python -dispatches. Continue from accepted e02 without scan. - -## Experiment `e04a`: OMECo 1x1 path-search budget - -Branch: `codex/orbitbreakers/task-07/e04-omeco-1x1`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e04-omeco-1x1`. - -Parent commit: `945430e` (e02 restored after the rejected scan). - -### Hypothesis and frozen rule - -For e02's simplified low-depth graph, `TreeSA(ntrials=1,niters=1)` can reduce -timed path-search latency more than it increases compiled contraction work. -Screen `max_steps=1`; retain for a full 50/100-step validation only if it is -faster than e02's 29.918828-second one-step screen and the initial/post-update -energies remain within `1e-4`. - -### Result - -Candidate hypothesis commit: `1eb52b206dacd848dd8efae29473415c1e37d3b0`. - -Candidate SHA-256: -`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. - -Candidate diff SHA-256: -`673f016863a7b777669c83dc399753004ebb19e8bc6f49003259699666d438d3`. - -Sanitized record: `profiles/e04a-omeco-1x1-screen.json`. - -```text -max_steps=1: e02/32x32 29.918828 s, 1x1 20.672377 s -max_steps=50: reference 91.540316 s, 1x1 21.473078 s, PASS -max_steps=100: reference 135.815605 s, e02/32x32 33.546170 s, - 1x1 24.362414 s, PASS -canonical 1x1/reference single-screen speedup: 5.5757x -``` - -Initial and one-step post-update trajectory-mean differences from e02 are -`4.77e-7` and `5.19e-5`, within the frozen `1e-4` rule. The canonical run -passes with final history `-10.0276298523`, improvement `3.1813645363`, and -final trajectory mean/std `-10.0331916809 / 0.0014021704`. - -Decision: `keep`. For the simplified graph, TreeSA 1x1 finds an adequate -repeated contraction path while saving most of the timed search latency. - -## Experiment `e04b`: TensorNetwork greedy contractor - -Branch: `codex/orbitbreakers/task-07/e04-greedy`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e04-greedy`. - -Parent commit: `945430e`. - -### Hypothesis and frozen rule - -The built-in greedy contractor may eliminate nearly all path-search latency. -Retain only if its one-step screen is faster than OMECo-1x1's -`20.672377` seconds and energies remain within `1e-4`. - -### Result - -Candidate hypothesis commit: `834de2a4f8e06b23cc9555b7fee4c25ff843a053`. - -Candidate SHA-256: -`96e2cd89224867352de887bec17058c43deb798a2e8200df670854a8538c3eda`. - -Candidate diff SHA-256: -`080396317aee29749b4c075b18778756af94b6621f1c52c9daaba270575eddd1`. - -Sanitized record: `profiles/e04b-greedy-screen.json`. - -The physical comparison passed, but greedy required 23.234316 seconds versus -OMECo-1x1's 20.672377 seconds. - -Decision: `discard` without 50/100-step runs; greedy is 12.39% slower at the -predeclared screen. - -## Experiment `e05`: joint TensorCircuit-state measurement rounds - -Branch: `codex/orbitbreakers/task-07/e05-batched-measurement-rounds`. - -Fresh hypothesis worktree: -`/Users/qqy/Desktop/2026Project/ORBIT-Q-worktrees/orbitbreakers/task-07/e05-batched-measurement-rounds`. - -Parent commit: `e38891f` (accepted OMECo-1x1 plus greedy rejection evidence). - -### Hypothesis - -Before each eight-ancilla measurement round, one TensorCircuit `c.state()` -contains the exact joint ancilla distribution. Sequentially condition that -distribution with the same eight fixed uniforms and strict -`status > p0` rule used by TensorCircuit `_unitary_kraus_template`, select and -normalize the corresponding TensorCircuit state column, and continue the -adaptive circuit from that collapsed state. This replaces eight separately -contracted `cond_measure` probability networks per layer with one -TensorCircuit state contraction while preserving the exact projective -measurement law, bit order, fixed uniforms, feedback branches, and central -TensorCircuit gate/state computation. - -### Frozen policy and numerical checks - -This is explicitly a higher-risk framework-native restructuring: JAX is used -only to condition probabilities and select a column of a state computed by -TensorCircuit; all quantum state evolution, gates, and Hamiltonian evaluation -remain TensorCircuit APIs. Screen one step first. Initial and post-update -trajectory-mean energies must be within `5e-3` of accepted e04a, all outputs -must be finite, and memory must remain below 7 GiB. Continue to 50/100 steps -only if the one-step runtime is below 20.672377 seconds. Retain only if both -public workloads pass and canonical runtime is below 24.362414 seconds. - -### Result - -Candidate hypothesis commit: `5c4f0ba61509625c4c2bf76bcb3e21adf9fc09c9`. - -Candidate SHA-256: -`5f4ec8d45e1fa91c053f3ed2027c90bdb1abf1e9e7d87add399c6c5ce883add7`. - -Candidate diff SHA-256: -`d4a0277c7c1184b22be90dc51215a63690b39cb23871d9fcd3d6d6818aafd64b`. - -Sanitized record: `profiles/e05-measurement-round-screen.json`. - -```text -max_steps=1: e04a 20.672377 s, e05 4.606171 s -max_steps=50: reference 91.540316 s, e04a 21.473078 s, - e05 14.522625 s, e05 PASS -max_steps=100: reference 135.815605 s, e04a 24.362414 s, - e05 26.530668 s, e05 PASS -``` - -All physical checks and both public workloads pass. The canonical result is -especially close to the immutable expert: final history -`-10.0279579163` versus `-10.0279636383`, with improvement -`3.1816935539` and final trajectory mean/std -`-10.0334491730 / 0.0000033379`. - -Decision: `discard for the canonical metric`. Joint measurement rounds cut -the fixed trace/path cost by 16 seconds and dominate at 1/50 updates, but -materializing and differentiating full 16-qubit states makes each update -roughly 0.20 seconds slower. At 100 updates it is 8.90% slower than accepted -e04a. Preserve it as a valuable scaling crossover insight, not the final -candidate. - -## Experiment `e06`: TensorCircuit vectorized value-and-gradient - -Branch: `codex/orbitbreakers/task-07/e06-vvag`. - -Parent commit: `f8da3bb`. - -Hypothesis: `K.vvag` may generate a better batched-trajectory AD program than -differentiating through the mapped mean. Retain only if its one-step runtime -beats e04a's 20.672377 seconds with physical outputs within `1e-4`. - -Candidate commit: `828e921ddf69709054d5fa52a5e3e62d9fac475e`; -source SHA-256 -`4f0a8757af372c41db677981f1551c363f82f128e0f295073228defece065c68`; -diff SHA-256 -`82e90bad5bb428a53d623e268808a22a1ca321a686540f8e7c8ea5b46a15d7fa`. - -Sanitized record: `profiles/e06-vvag-screen.json`. - -Result: physical outputs pass, but one step takes 39.419801 seconds, -1.90687x e04a. Decision: `discard` without longer runs. Mapping individual -value-and-gradient programs duplicates reverse-mode structure for this -shared-parameter objective. - -## Frozen final candidate and paired run - -Final candidate: accepted e04a source -`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. - -No candidate tuning follows this freeze. The final command is: - -```bash -python -u research/task-07/run_docker_matrix.py \ - --repeat 6 --max-steps 100 --timeout 300 --cpus 6 --memory 7g \ - --output results/task-07-final-canonical-6-pairs -``` - -It stages immutable source snapshots, uses one no-network container and fresh -evaluator processes, alternates pair order, and applies the survey's frozen -Student-t promotion rule. - -## Final paired result - -Date: 2026-07-29. - -Candidate SHA-256: -`0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592`. - -Staging snapshot SHA-256: -`e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44`. - -Container: `orbit-task07-matrix-34ea5ae79e` -(ID prefix `b8199b0e1e6a`), six CPUs, 7 GiB, no network. - -Sanitized paired report: -`profiles/final-canonical-six-pairs.json` -(`sha256:6e03db1f37e8bbe0b38247f017d9259177a2858d54289fa2a5615542b499b54a`). - -Fail-closed reference report: -`profiles/final-reference-six.json` -(`sha256:743f493120dd89e6c75a309499c28d819ae00aee09d57e7feb374b35c0310224`). - -```text -terminal_status: SUCCESS x 12 -valid cells: 12/12 -passing pairs: 6/6 -candidate wins: 6/6 - -reference runtimes: -106.038165, 119.427967, 123.188182, -107.532991, 110.084619, 131.316223 - -candidate runtimes: -24.481295, 24.221592, 24.716431, -24.421997, 31.684172, 27.652166 - -reference mean / median / stderr: -116.264691 / 114.756293 / 4.096777 s - -candidate mean / median / stderr: -26.196276 / 24.598863 / 1.216760 s - -ratio-of-means speedup: 4.438215x -ratio-of-means improvement: 77.4684% -mean paired speedup: 4.478752x -paired speedup stderr: 0.228662x -95% Student-t CI: [3.890959x, 5.066545x] -``` - -Decision: `promote`. Every cell passes, mean and median are lower, all six -pairs win, and the frozen confidence lower bound is above 1.0. - -### Final report serialization failure and recovery - -After cell 12 passed and the shared container stopped, the runner raised a -`NameError` while constructing the final JSON because two Python booleans -were written as lowercase `true`. All 24 raw stdout/stderr logs already -existed; stderr logs were empty and every stdout contained `Overall: PASS`. -No benchmark cell was rerun or filtered. The sanitized reports above were -reconstructed from all raw logs, with every stdout hash retained. - -The runner is corrected to use `True` and now writes a checkpoint after each -cell. `research/check_gates.py --task 07 --baseline-report -research/task-07/profiles/final-reference-six.json` returns -`promotion_ready: true`. - -## Experiment `e07`: exact classical-ancilla reduction - -Branch: `codex/orbitbreakers/task-07/e07-classical-ancilla`. - -Parent commit: `529a5c5` (the published e04a implementation and six-pair -evidence). - -### Structural derivation - -This experiment follows a user-supplied concern that the apparent -measurement-feedback workload may contain an unintended exact reduction. -The eight ancillas enter each layer as a computational-basis product state. -Their `RY` gates create independent Bernoulli source bits. Each following -data-ancilla `RZZ` is diagonal and applies a norm-preserving data unitary -conditioned on its source bit, so it cannot change the ancilla Z-basis -probabilities. The ordered ancilla CNOT ladder is only the reversible map - -```text -measured[0] = source[0] -measured[i] = source[0] xor ... xor source[i]. -``` - -Its inverse is -`source[0] = measured[0]` and -`source[i] = measured[i] xor measured[i-1]`. -Conditioning on one measured string therefore selects one unique source -string and an eight-qubit data-only circuit. The pre-measurement entangler -becomes `RZ((1-2*source) theta_entangler)` on data; measured feedback becomes -`RZ((1-2*measured) theta_feedback[measured])`. They commute and combine into -one data `RZ`. - -For an ancilla entering as previous measured bit `b`, the next independent -source probability is - -```text -P(source=1 | b=0) = sin(theta/2)^2 -P(source=1 | b=1) = cos(theta/2)^2. -``` - -The implementation reconstructs TensorCircuit's strict -`status > 1-P(bit=1)` sampling rule, maps the fixed seed-2048 uniforms to -complete two-layer patterns, and deduplicates equal patterns before quantum -evaluation. - -### Independent audit - -Audit program: -`validate_classical_ancilla_reduction.py` -(`sha256:86e30424397d816be4db109a5eb64013de152db25477aba15bff7d7db44c4d3e`). - -Sanitized record: -`profiles/e07-classical-ancilla-audit.json` -(`sha256:f371e2429a3a5724583db82eb6a45089e4040c4e699b7db3d51a50035ad126c3`). - -All 1,024 measured bits produced by the analytic sampler are identical to -the full 16-qubit TensorCircuit `cond_measure` implementation. The 64 fixed -trajectories contain only two distinct complete patterns: the all-zero -pattern occurs 63 times and trajectory 36 supplies the sole rare pattern. - -Against the accepted full 16-qubit e04a implementation: - -```text -initial energy absolute error: 4.7684e-6 -trajectory energy maximum error: 4.2915e-6 -full ancilla-gradient maximum magnitude:4.6559e-7 -reduced ancilla-gradient magnitude: 0 -non-ancilla gradient maximum error: 1.5116e-6 -post-one-update energy error: 4.6730e-5 -audit passed: true -``` - -The ideal pathwise derivative of a fixed discrete branch with respect to -the ancilla sampling angle is exactly zero. The full complex64 graph produces -only sub-micro numerical residue there; Adam can amplify that residue into -a parameter-coordinate difference, but the corresponding physical energy -checks remain close. This distinction is disclosed rather than hidden. - -### Exploratory evaluator screens - -These screens were exploratory and occurred before a final candidate freeze; -they are not the promotional paired measurement. - -Candidate source SHA-256: -`29d4d94101c21d757f57f3c639752533bfb84feb8acae5a8b2659a40e0f78631`. - -```text -max_steps=50: 3.008539 s, PASS - initial/final history: -6.8462691307 / -8.7942304611 -max_steps=100: 2.998158 s, PASS - initial/final history: -6.8462700844 / -10.0277271271 - final trajectory mean/std: -10.0331859589 / 0.0007448916 -``` - -Decision: `keep provisionally`. The canonical screen is about 8.1x faster -than e04a's 24.362-second screen and about 45.3x faster than the original -expert's 135.816-second bootstrap. Because compilation now dominates and -50 versus 100 updates costs almost the same, isolate a whole-training scan -and small-circuit gate/contractor choices before freezing a new paired run. - -### Scope and policy caveat - -This is an exact reduction of the public fixed workload, not hard-coded -energies or fewer requested trajectories. All 64 statuses are consumed, all -96 parameters retain their original layout, all trajectory outputs are -reconstructed, and TensorCircuit performs every remaining quantum evolution -and Hamiltonian expectation. It nevertheless removes the explicit -16-qubit/mid-circuit-measurement execution that the task prose may have -intended to benchmark. The final report must present this openly as a -challenge-design loophole and keep the conservative e04a implementation -available if maintainers require literal `cond_measure` use. - -## Post-reduction experiment sweep - -All variants below start from the provisionally accepted e07 reduction and -retain the 64-to-2 exact pattern map. - -### `e08`: whole-training `K.jaxy_scan` - -Candidate commit: `7c9476a`. -Source SHA-256: -`a6a9c882edabbf88bdb175d5cf7dd4b39bf09f923c373a939929380a616b7376`. - -Canonical screen: `3.205596 s`, PASS, versus the e07 exploratory -`2.998158 s`. Final-history energy differs by `1.53e-5`. - -Decision: `discard`. Even after the dimensional collapse, staging the -100-update control flow costs more than the cached Python dispatches it -removes. - -### `e09`: fuse pre-CNOT `RY` and reduced `RZ` - -Candidate commit: `7d0fd29`. -Source SHA-256: -`96c0ca51d49fa334758e8c60985062250aae6f3f516b5c42aaed3eb26adbe754`. - -The exact product `RZ(z) RY(y)` was emitted as a differentiable -TensorCircuit `any` gate. Canonical screen: `3.530851 s`, PASS. - -Decision: `discard`. TensorCircuit's contraction preprocessing already -handles the neighboring one-qubit gates more cheaply than explicitly -constructing the parameterized dense matrix. - -### `e10`-`e13`: contractor selection - -Single canonical screens: - -| Variant | Runtime (s) | Result | -| --- | ---: | --- | -| e10 `greedy` | 2.910894 | PASS | -| e11 `plain-experimental`, default local steps 2 | 2.921477 | PASS | -| e12 `plain-experimental`, local steps 1 | 3.100929 | PASS | -| e13 `plain-experimental`, local steps 3 | 2.822912 | PASS | - -Because greedy, OMECo-1x1, and the default local contractor differed by only -tenths of a second, e11 was selected through counterbalanced six-pair -screens rather than a single timing. Sanitized record: -`profiles/e11-contractor-six-pair-screen.json`. - -```text -greedy mean: 2.947290 s -plain-experimental mean: 2.823417 s -plain wins: 6/6 -mean paired speedup: 1.044198x -95% Student-t CI: [1.002914x, 1.085481x] - -OMECo-1x1 mean: 2.949023 s -plain-experimental mean: 2.839041 s -plain wins: 5/6 -mean paired speedup: 1.039493x -95% Student-t CI: [0.993346x, 1.085640x] -``` - -An earlier attempt mounted a comparison worktree from `/private/tmp`; Docker -turned the unavailable file mount into a directory and every greedy cell -failed before evaluator execution. Those values are explicitly excluded and -the complete six-pair screen was rerun from a Docker-visible workspace. - -Decision: `keep e11`. The exact reduced graph is small enough that -TensorCircuit's native local contractor avoids global path-search overhead. -Local-step values 1 and 3 do not provide sufficient repeat evidence to -supplant the stable default of 2. - -## Frozen e11 candidate for new expert comparison - -Candidate source SHA-256: -`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. - -The final comparison will use six canonical matched pairs, alternating the -immutable human expert and e11 in one no-network container with six CPUs, -7 GiB, the same evaluator and latest repository TensorCircuit image. No -candidate tuning follows this freeze. - -## Final e11 six-pair expert comparison - -Date: 2026-07-29. - -Candidate implementation commit: `b7d34dd`. - -Candidate SHA-256: -`0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e`. - -Staging snapshot SHA-256: -`d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f`. - -Docker image: -`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` -(TensorCircuit-NG `1.8.0.dev20260726`, JAX/JAXLIB `0.10.0`). - -Sanitized paired report: -`profiles/e11-final-canonical-six-pairs.json` -(`sha256:068593daf65d132d1c7b3f18a0cbc2f7fc4b378558f3c4ccedf79231c0248c0f`). - -```text -terminal_status: SUCCESS x 12 -valid cells: 12/12 -passing pairs: 6/6 -candidate wins: 6/6 - -reference runtimes: -123.286060, 126.247088, 150.224728, -129.913867, 159.579514, 151.207388 - -candidate runtimes: -3.062554, 3.311737, 2.989908, -3.030923, 3.063330, 2.966582 - -reference mean / median / stderr: -140.076441 / 140.069298 / 6.281458 s - -candidate mean / median / stderr: -3.070839 / 3.046739 / 0.050718 s - -ratio-of-means speedup: 45.615039x -ratio-of-means improvement: 97.8077% -mean paired speedup: 45.757921x -paired speedup stderr: 2.479287x -95% Student-t CI: [39.384711x, 52.131131x] -``` - -Decision: `promote under the executable contract`. Every cell passes, every -pair wins, and the frozen confidence lower bound is far above 1.0. The -separate challenge-design report marks the semantic caveat: this exact -reduction should not be represented as a generic acceleration of -mid-circuit measurement, and maintainers may prefer the conservative e04a -implementation if literal 16-qubit `cond_measure` execution is the intended -policy. diff --git a/optimized_solutions/challenge-07/research/README.md b/optimized_solutions/challenge-07/research/README.md deleted file mode 100644 index 21e8edd..0000000 --- a/optimized_solutions/challenge-07/research/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Benchmark evidence mirror - -This directory mirrors the final reviewed Task 07 research record from -[`hmyuuu/OrbitBreakersExpertBenchmarks#11`](https://github.com/hmyuuu/OrbitBreakersExpertBenchmarks/pull/11), -using Benchmark `main` at `7e2298b`. - -`CLASSICAL_ANCILLA_REDUCTION_REPORT.md` contains the full six-pair result and -challenge-design analysis; `IMPLEMENTATION_COMPARISON.md` records the -conservative literal-ancilla campaign; `profiles/` contains the sanitized -machine-readable ablations and paired timings. The concise maintainer-facing -report remains one directory above as `CLASSICAL_ANCILLA_REDUCTION.md`. - -Both the canonical ORBIT-Q task and its human expert remain unchanged. -Benchmark-harness reproduction commands in these records should be run in the -Benchmark repository pinned above. diff --git a/optimized_solutions/challenge-07/research/SURVEY.md b/optimized_solutions/challenge-07/research/SURVEY.md deleted file mode 100644 index 15921bc..0000000 --- a/optimized_solutions/challenge-07/research/SURVEY.md +++ /dev/null @@ -1,216 +0,0 @@ -# ORBIT-Q Task 07 Runtime Optimization Survey - -**Status: READY** - -Campaign task: `task-07` - -Survey freeze: `2026-07-29T00:04:56Z` - -Reference commit: `5af98f27b9404c513df8eee0f4568b1512edee19` - -This campaign covers only Task 07. The survey, immutable expert, public -workloads, hypotheses, and measurement rule are frozen before the first -candidate edit. - -## Evidence and claim boundary - -The immutable human expert is `references/task-07/solution_7.py` -(`sha256:ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3`). -The public contract and evaluator are `tasks/task-07/problem.md` -(`sha256:e267f59cdda3d7602ecfdde1a45cb3981e39d52a4bae2f87b4dbb375bcab9680`) -and `tasks/task-07/evaluator/evaluate_7.py` -(`sha256:69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31`). - -The historical ORBIT-Q table records 63.8 seconds for Task 07 without a -matched host or environment, and the repository's 2026-07-27 shared-container -bootstrap measured two byte-identical reference cells at -109.332 +/- 0.081 seconds on an eight-CPU/9-GiB allocation. Those values are -context only. No external publication reports this exact evaluator, circuit, -trajectory batch, seed, optimizer trajectory, hardware, and software stack. -This campaign may therefore claim only a paired gain over the bundled expert, -not a global SOTA result. - -The problem text contains an internal typo: its displayed objective divides -128 trajectories by 128, while the fixed configuration, interface, evaluator, -and expert all use 64 trajectories and `K.mean`. The executable public -contract is unambiguous. Every candidate must preserve the expert/evaluator's -64-trajectory mean and must not exploit the prose inconsistency. - -## Inspected environment and framework paths - -Measurements use Docker image -`sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833` -with six CPUs, 7 GiB memory, no network, and fresh evaluator processes. The -tracked dependency lock is `envs/tensorcircuit-py311/requirements.lock` -(`sha256:cd5ac5cb2102ea7b40bd46dc81320cc59e0ce0671ab88c597f81d82b384a824b`). -Per maintainer direction, this campaign uses the image's latest installed -TensorCircuit-NG and does not downgrade it. - -| Component | Version | Inspected path / symbol | -| --- | --- | --- | -| TensorCircuit-NG | `1.8.0.dev20260726` | `Circuit.cond_measure`, `conditional_gate`, `state`, and `wavefunction` in `tensorcircuit/circuit.py` (`sha256:5c4d569325369d957dc60bbeca8a581508549ff9813a7a163de61a6294864662`) and `tensorcircuit/basecircuit.py` (`sha256:2f47be7f215c73bfbc41788661b0dd86a77054503f63e7bfbb6c4d2a84004e98`) | -| TensorCircuit measurement templates | same package | `operator_expectation` / `sparse_expectation` in `tensorcircuit/templates/measurements.py` (`sha256:7a69043bd81745254ab106f3cdd0911720fdb91e0be70b784f86c96fbcfaa615`) | -| TensorCircuit sparse operators | same package | `PauliStringSum2COO` in `tensorcircuit/quantum.py` (`sha256:fcaee21ba5ccde1b89c46e2f5424c48d342e3bfaedf72adba672ab6bd4ded703`) | -| JAX / JAXLIB | `0.10.0` / `0.10.0` | `jit`, `vmap`, reverse-mode AD, and `lax.scan`, wrapped by `tensorcircuit/backends/jax_backend.py` (`sha256:88657aebf8e5d566ac4e653abe327083da0253f02a3a297a134b871ffe4baab9`) | -| Optax | `0.2.8` | `optax.adam(0.02)` and `apply_updates` | -| OMECo | `0.2.0` | `TreeSA` contractor shortcuts; the expert requests `omeco-32-32` | -| TensorNetwork-NG | `0.5.1` | TensorCircuit node graph and contraction execution | -| Quimb | `1.11.1` | OMECo path-search support | - -TensorCircuit's [measurement documentation](https://tensorcircuit.readthedocs.io/en/stable/faq.html) -states that `cond_measure` performs a normalized Z-basis collapse and returns -a jittable integer tensor, while `conditional_gate` applies a gate selected by -that outcome. Its [Pauli-sum tutorial](https://tensorcircuit.readthedocs.io/en/latest/whitepaper/6-2-pauli-string-expectation.html) -documents both repeated `expectation_ps` evaluation and a single sparse -Hamiltonian `operator_expectation`. The -[TensorCircuit paper](https://quantum-journal.org/papers/q-2023-02-02-912/) -describes the framework's tensor-network, AD, JIT, and vectorization model. -JAX documents `scan` as a single lowered loop for a fixed iteration count in -the [official API](https://docs.jax.dev/en/latest/_autosummary/jax.lax.scan.html), -and its [benchmarking guide](https://docs.jax.dev/en/latest/benchmarking.html) -requires synchronization or host conversion when measuring asynchronous -work. OMECo documents `TreeSA` as a simulated-annealing contraction-order -optimizer in its [public API](https://docs.rs/omeco/latest/omeco/). - -## Task 07: measurement-feedback TFIM VQE - -### Required algorithm and output - -The expert optimizes a 16-qubit, two-layer adaptive circuit. Eight data qubits -and eight ancillas receive trainable `RY` rotations, pairwise `RZZ` -entanglers, and fixed CNOT ladders. Each layer measures all eight ancillas -with fixed per-trajectory uniforms, applies one of two trainable feedback -`RZZ` gates per pair, then applies a data CNOT ladder and trainable `RZ` -rotations. Sixty-four fixed measurement trajectories are mapped with -`K.vmap`, averaged, differentiated, and optimized through exactly 100 -sequential Adam updates. - -Each trajectory returns the expectation of the open-boundary eight-site TFIM - -`H = -sum_i Z_i Z_(i+1) - 1.05 sum_i X_i`. - -The solution must return a NumPy `energy_history` of shape `(100,)` containing -pre-update trajectory means and `final_trajectory_energies` of shape `(64,)` -for the same fixed uniforms after the final update. - -### Dominant work and measured bottleneck - -The expert evaluates every trajectory energy as 15 separate -`Circuit.expectation_ps` calls: seven `ZZ` terms and eight `X` terms. Each -call constructs and contracts a bra/ket tensor network, so the same final -adaptive circuit is effectively contracted 15 times in both the forward and -reverse passes. The final post-training trajectory evaluation repeats the -same pattern. - -The immutable expert passes the canonical evaluator in 135.815605 seconds in -the fixed six-CPU container. One update takes 47.853128 seconds end to end, -while 10, 20, 32, and 50 updates take 51.638506, 60.074862, 69.596274, and -91.540316 seconds. Thus roughly 48 seconds is trace/compile/path/finalization -cost, and the remaining 99 canonical updates add about 0.89 seconds each. -Removing Python dispatch alone cannot produce a large gain; the repeated -energy contractions and their gradients are the primary target. - -`conditional_gate` also materializes a differentiable dense two-qubit tensor -by one-hot selecting from two `RZZ` gate tensors. After a Z measurement the -ancilla is a computational-basis eigenstate, so this generic representation -retains a two-qubit node even though the gate's action on the data is a -one-qubit phase rotation. - -Contraction-path search is inside the timed first trace. The expert chooses -OMECo `TreeSA(ntrials=32,niters=32)`. Contraction-order research establishes -that path choice can substantially change tensor-network work, while better -search also costs more; contractor budget therefore needs end-to-end -measurement rather than FLOP estimates alone. See Schindler and Jermyn, -[Algorithms for Tensor Network Contraction Ordering](https://arxiv.org/abs/2001.08063). - -### Exact structural opportunities - -At the end of a trajectory, every ancilla was just Z-measured and is touched -only by a diagonal feedback `RZZ`; therefore the final state factorizes as -`|psi_data> tensor |measured_ancilla_bitstring>`. A single TensorCircuit -`c.state()` contraction can be reshaped into `(2^8, 2^8)` and reduced along -the ancilla basis axis to obtain the normalized data state. Feeding that -state to an eight-qubit `tc.Circuit` and TensorCircuit's native sparse -`operator_expectation` evaluates all 15 TFIM terms after one circuit-state -contraction. - -For a measured bit `b`, the feedback identity is exact: - -`RZZ(theta_b) (|b> tensor |psi>) = - |b> tensor RZ((1 - 2 b) theta_b) |psi>`. - -Replacing the generic conditional two-qubit feedback with the corresponding -TensorCircuit `RZ` on the data qubit preserves the branch, measurement -probability, selected trainable angle, and gradient. It also remains valid -between layers because the feedback never changes the measured ancilla. - -### Candidate hypotheses frozen before editing - -Every candidate must preserve the seeded float32 initialization, all 96 -trainable parameters and their layout, 16 fixed measurement uniforms per -trajectory, normalized `cond_measure` semantics, 64 trajectories and their -order, two layers, exactly 100 Adam updates, pre-update history, final -post-update trajectory values, complex64 behavior, and TensorCircuit as the -central quantum computation. - -1. **e01—single native Hamiltonian evaluation.** Contract each final - trajectory once with `Circuit.state`, extract the factorized data state, - and evaluate a TensorCircuit-native sparse TFIM operator with - `templates.measurements.operator_expectation`. Expected value: high. - Validate energy, parameter gradient, one Adam update, and full history. -2. **e02—measured-ancilla feedback reduction.** Replace each selected - two-qubit `RZZ` after Z measurement with the exact selected/sign-adjusted - data `RZ`. Expected value: medium. Validate both branches and full - trajectory behavior independently before combining it with e01. -3. **e03—whole-training `K.jaxy_scan`.** Carry parameters and Optax state - through 100 updates and emit the same pre-update values. Expected value: - small to medium because it removes host dispatch but not quantum work. -4. **e04—contractor budget.** Compare the frozen best circuit under - OMECo 1x1, 4x4, 8x8, 16x16, and 32x32 or greedy where supported. - Path-search time and all repeated contractions must be measured together. -5. **e05—further state/measurement reuse.** Contract once before an - eight-ancilla measurement round and derive sequential conditional - probabilities from the TensorCircuit state, then reinitialize a - TensorCircuit circuit from the collapsed branch. Potential value: high, - but risk is also high because fixed-uniform sequential collapse and - framework-fidelity boundaries must remain exact. Pursue only after the - lower-risk native changes. - -The ideas are separate falsifiable hypotheses. No candidate implementation -was edited before this survey and dataset freeze. - -## Frozen measurement and promotion rule - -All eligible comparisons use one long-lived container with six CPUs and -7 GiB, the image ID above, no network, a 300-second per-cell cap, and a fresh -evaluator process per cell. Six matched pairs will be run, exceeding the -user's five-run requirement: - -- odd pairs: reference then candidate; -- even pairs: candidate then reference. - -Report every runtime, arithmetic mean, median, sample standard deviation, -standard error, minimum, maximum, ratio-of-means improvement, and each -pairwise speedup `S_i = R_i / C_i`. The primary confidence interval is the -two-sided 95% Student-t interval on the arithmetic mean of pairwise speedups: - -`mean(S) +/- t_(0.975,5) * sample_stdev(S) / sqrt(6)`, - -where `t_(0.975,5)=2.5705818366`. - -Promotion requires all 12 cells to pass, candidate mean and median below the -reference, at least five of six pair wins, and a confidence-interval lower -bound above 1.0. The canonical 100-step workload is the claim workload; the -public 50-step passing workload is only for screening and robustness. - -## Open evidence gaps - -- No matched external implementation/hardware runtime exists for this exact - adaptive VQE evaluator. -- Peak intermediate memory and contractor-estimated FLOPs are not yet - recorded. -- The current full canonical expert result is one bootstrap run; six - counterbalanced reference cells will be collected only against the frozen - winning candidate. -- Results will apply only to the fixed eight-data/eight-ancilla, - two-layer/64-trajectory workload on this host; no scaling claim is planned. diff --git a/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json b/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json deleted file mode 100644 index 10abaaf..0000000 --- a/optimized_solutions/challenge-07/research/profiles/bootstrap-reference.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "generated_at_utc": "2026-07-29T00:04:56Z", - "classification": "immutable expert bootstrap and update-count profile", - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "environment": { - "image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "tensorcircuit_ng": "1.8.0.dev20260726", - "jax": "0.10.0", - "jaxlib": "0.10.0", - "cpus": 6, - "memory": "7 GiB", - "network": "none", - "host_fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" - }, - "results": [ - { - "max_steps": 1, - "runtime_sec": 47.853128, - "initial_energy": -6.8462719917, - "final_history_energy": -6.8462719917, - "final_trajectory_mean": -6.9686288834, - "final_trajectory_std": 0.0004866889, - "passed": false, - "failure_reason": "minimum improvement and target thresholds" - }, - { - "max_steps": 10, - "runtime_sec": 51.638506, - "initial_energy": -6.8462643623, - "final_history_energy": -7.4798407555, - "final_trajectory_mean": -7.5244884491, - "final_trajectory_std": 0.004178, - "passed": false, - "failure_reason": "target final energy threshold" - }, - { - "max_steps": 20, - "runtime_sec": 60.074862, - "initial_energy": -6.8462643623, - "final_history_energy": -7.8647251129, - "passed": false, - "failure_reason": "target final energy threshold" - }, - { - "max_steps": 32, - "runtime_sec": 69.596274, - "initial_energy": -6.8462643623, - "final_history_energy": -8.1460399628, - "passed": false, - "failure_reason": "target final energy threshold" - }, - { - "max_steps": 50, - "runtime_sec": 91.540316, - "initial_energy": -6.8462719917, - "final_history_energy": -8.7927856445, - "improvement": 1.9465136528, - "final_trajectory_mean": -8.8296632767, - "final_trajectory_std": 0.003031878, - "history_length": 50, - "passed": true - }, - { - "max_steps": 100, - "runtime_sec": 135.815605, - "initial_energy": -6.8462643623, - "final_history_energy": -10.0279636383, - "improvement": 3.181699276, - "final_trajectory_mean": -10.0333871841, - "final_trajectory_std": 0.0, - "history_length": 100, - "passed": true - } - ] -} diff --git a/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json b/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json deleted file mode 100644 index 9606a47..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e01-single-state-screen.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e01", - "candidate_commit": "1e21dd41f47e3beb84b937144324227eac544b6d", - "candidate_sha256": "30f0f45073e866c7fbb24cd9a5c33d8c1254e6985136937cd454b82990681678", - "candidate_diff_sha256": "3396c6b65d3f6c2eaebc647d6251547dd6561d1defac4526f9f503b2dcac8b7e", - "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "cpus": 6, - "memory": "7 GiB", - "performance_screens": [ - { - "max_steps": 1, - "reference_runtime_sec": 47.853128, - "candidate_runtime_sec": 44.91711, - "reference_initial_energy": -6.8462719917, - "candidate_initial_energy": -6.8462643623, - "reference_post_update_trajectory_mean": -6.9686288834, - "candidate_post_update_trajectory_mean": -6.9686059952, - "expected_threshold_failure": true - }, - { - "max_steps": 10, - "reference_runtime_sec": 51.638506, - "candidate_runtime_sec": 46.100052, - "reference_final_history_energy": -7.4798407555, - "candidate_final_history_energy": -7.479578495, - "expected_threshold_failure": true - }, - { - "max_steps": 50, - "reference_runtime_sec": 91.540316, - "candidate_runtime_sec": 52.769482, - "screen_speedup": 1.73434, - "reference_final_history_energy": -8.7927856445, - "candidate_final_history_energy": -8.7949237823, - "reference_post_update_trajectory_mean": -8.8296632767, - "candidate_post_update_trajectory_mean": -8.8320827484, - "reference_passed": true, - "candidate_passed": true - }, - { - "max_steps": 100, - "reference_runtime_sec": 135.815605, - "candidate_runtime_sec": 61.396553, - "screen_speedup": 2.2121, - "reference_final_history_energy": -10.0279636383, - "candidate_final_history_energy": -10.0263500214, - "reference_post_update_trajectory_mean": -10.0333871841, - "candidate_post_update_trajectory_mean": -10.0319023132, - "reference_passed": true, - "candidate_passed": true - } - ], - "one_trajectory_equivalence": { - "tolerances": { - "energy_abs": 5e-05, - "gradient_max_abs": 0.0005, - "adam_parameter_max_abs": 2e-05 - }, - "reference_energy": -6.846258640289307, - "candidate_energy": -6.846261978149414, - "energy_abs_error": 3.337860107421875e-06, - "gradient_max_abs_error": 1.0132789611816406e-06, - "gradient_mean_abs_error": 2.6805633979165577e-07, - "adam_parameter_max_abs_error": 0.031341224908828735, - "adam_parameter_mean_abs_error": 0.002425061771646142, - "energy_check": true, - "gradient_check": true, - "strict_parameter_check": false - }, - "decision": "keep provisionally; exact quantum identity and physical output checks pass, while a predeclared strict first-Adam parameter metric is retained as a failed diagnostic because elementwise Adam normalization amplifies near-zero complex64 gradient sign changes" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json b/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json deleted file mode 100644 index df2c7ab..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e02-feedback-rz-screen.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e02", - "candidate_commit": "067a1d365e8ef4a9e3f81d6dd62939c0b3af6b39", - "candidate_sha256": "b3dcbaa35a233d8dde4576de7257c79a1a81034eee49f1f0bef6489116dcafcd", - "candidate_diff_sha256": "759b7139a8463d53c80f2d48148eca189235a872fac5402ae9f64be4100bac45", - "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "cpus": 6, - "memory": "7 GiB", - "identity_audit": { - "dtype": "complex64", - "tolerance": 1e-07, - "cases": [ - {"bit": 0, "theta": -0.37, "max_abs_error": 0.0}, - {"bit": 0, "theta": 1.23, "max_abs_error": 2.9802322387695312e-08}, - {"bit": 1, "theta": -0.37, "max_abs_error": 0.0}, - {"bit": 1, "theta": 1.23, "max_abs_error": 0.0} - ], - "max_abs_error": 2.9802322387695312e-08, - "passed": true - }, - "performance_screens": [ - { - "max_steps": 1, - "accepted_e01_runtime_sec": 44.91711, - "candidate_runtime_sec": 29.918828, - "accepted_e01_initial_energy": -6.8462643623, - "candidate_initial_energy": -6.8462657928, - "initial_energy_abs_error": 1.4305e-06, - "accepted_e01_post_update_trajectory_mean": -6.9686059952, - "candidate_post_update_trajectory_mean": -6.9686813354, - "post_update_mean_abs_error": 7.53402e-05, - "physical_checks_passed": true - }, - { - "max_steps": 50, - "reference_runtime_sec": 91.540316, - "accepted_e01_runtime_sec": 52.769482, - "candidate_runtime_sec": 31.299628, - "speedup_over_reference": 2.92465, - "candidate_final_history_energy": -8.7978668213, - "candidate_post_update_trajectory_mean": -8.8353881836, - "candidate_passed": true - }, - { - "max_steps": 100, - "reference_runtime_sec": 135.815605, - "accepted_e01_runtime_sec": 61.396553, - "candidate_runtime_sec": 33.54617, - "speedup_over_reference": 4.0487, - "speedup_over_e01": 1.83023, - "candidate_initial_energy": -6.846265316, - "candidate_final_history_energy": -10.0280771255, - "candidate_improvement": 3.1818118095, - "candidate_post_update_trajectory_mean": -10.0335464478, - "candidate_post_update_trajectory_std": 2.666e-07, - "candidate_passed": true - } - ], - "decision": "keep; exact branch identity and all predeclared physical/public checks pass, with a 4.0487x canonical single-screen speedup over the immutable reference" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json b/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json deleted file mode 100644 index 00cad40..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e03-training-scan-screen.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e03", - "candidate_commit": "8b977faa5a9eea4e4ead88e24f4193cbfbc66aa0", - "candidate_sha256": "767c82d6c0be9af2ee526d130afba3f6eb95d81d42efcbb7f62665a9753a3b2c", - "candidate_diff_sha256": "5bffe6df6108a72656dfd56cdc9d4a39aeaaa0037e3545e3d4bb1a754d4229d3", - "environment_image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "cpus": 6, - "memory": "7 GiB", - "screens": [ - { - "max_steps": 50, - "accepted_e02_runtime_sec": 31.299628, - "candidate_runtime_sec": 34.916768, - "candidate_over_e02_ratio": 1.11556, - "candidate_final_history_energy": -8.7939605713, - "candidate_post_update_trajectory_mean": -8.8310813904, - "candidate_passed": true - }, - { - "max_steps": 100, - "accepted_e02_runtime_sec": 33.54617, - "candidate_runtime_sec": 36.747307, - "candidate_over_e02_ratio": 1.09542, - "candidate_initial_energy": -6.8462719917, - "candidate_final_history_energy": -10.0262737274, - "candidate_improvement": 3.1800017357, - "candidate_post_update_trajectory_mean": -10.031832695, - "candidate_post_update_trajectory_std": 0.0054257438, - "candidate_passed": true - } - ], - "decision": "discard; all semantic gates pass but scan is 9.54% slower on the canonical screen because added control-flow compile cost exceeds 100 host dispatches" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json b/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json deleted file mode 100644 index 3eb3d28..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e04a-omeco-1x1-screen.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e04a", - "candidate_commit": "1eb52b206dacd848dd8efae29473415c1e37d3b0", - "candidate_sha256": "0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592", - "candidate_diff_sha256": "673f016863a7b777669c83dc399753004ebb19e8bc6f49003259699666d438d3", - "contractor": "omeco-1-1", - "screens": [ - { - "max_steps": 1, - "accepted_e02_runtime_sec": 29.918828, - "candidate_runtime_sec": 20.672377, - "candidate_initial_energy": -6.846265316, - "candidate_post_update_trajectory_mean": -6.9686279297 - }, - { - "max_steps": 50, - "reference_runtime_sec": 91.540316, - "candidate_runtime_sec": 21.473078, - "speedup_over_reference": 4.26394, - "candidate_final_history_energy": -8.7932806015, - "candidate_post_update_trajectory_mean": -8.8302116394, - "candidate_passed": true - }, - { - "max_steps": 100, - "reference_runtime_sec": 135.815605, - "accepted_e02_runtime_sec": 33.54617, - "candidate_runtime_sec": 24.362414, - "speedup_over_reference": 5.57573, - "speedup_over_e02": 1.37696, - "candidate_initial_energy": -6.846265316, - "candidate_final_history_energy": -10.0276298523, - "candidate_improvement": 3.1813645363, - "candidate_post_update_trajectory_mean": -10.0331916809, - "candidate_post_update_trajectory_std": 0.0014021704, - "candidate_passed": true - } - ], - "decision": "keep; all public checks pass and the low-budget path search cuts the canonical screen to 24.362414 seconds" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json b/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json deleted file mode 100644 index 0ce6c26..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e04b-greedy-screen.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e04b", - "candidate_commit": "834de2a4f8e06b23cc9555b7fee4c25ff843a053", - "candidate_sha256": "96e2cd89224867352de887bec17058c43deb798a2e8200df670854a8538c3eda", - "candidate_diff_sha256": "080396317aee29749b4c075b18778756af94b6621f1c52c9daaba270575eddd1", - "contractor": "greedy", - "screen": { - "max_steps": 1, - "omeco_1x1_runtime_sec": 20.672377, - "candidate_runtime_sec": 23.234316, - "candidate_over_omeco_1x1_ratio": 1.12393, - "candidate_initial_energy": -6.8462648392, - "candidate_post_update_trajectory_mean": -6.9686841965, - "physical_outputs_within_tolerance": true - }, - "decision": "discard; greedy is 12.39% slower than OMECo 1x1 at the frozen one-step screen" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json b/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json deleted file mode 100644 index a826b9e..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e05-measurement-round-screen.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e05", - "candidate_commit": "5c4f0ba61509625c4c2bf76bcb3e21adf9fc09c9", - "candidate_sha256": "5f4ec8d45e1fa91c053f3ed2027c90bdb1abf1e9e7d87add399c6c5ce883add7", - "candidate_diff_sha256": "d4a0277c7c1184b22be90dc51215a63690b39cb23871d9fcd3d6d6818aafd64b", - "screens": [ - { - "max_steps": 1, - "accepted_e04a_runtime_sec": 20.672377, - "candidate_runtime_sec": 4.606171, - "candidate_initial_energy": -6.8462643623, - "candidate_post_update_trajectory_mean": -6.9686303139, - "physical_outputs_within_tolerance": true - }, - { - "max_steps": 50, - "reference_runtime_sec": 91.540316, - "accepted_e04a_runtime_sec": 21.473078, - "candidate_runtime_sec": 14.522625, - "speedup_over_reference": 6.3033, - "candidate_final_history_energy": -8.7917070389, - "candidate_post_update_trajectory_mean": -8.8286552429, - "candidate_passed": true - }, - { - "max_steps": 100, - "reference_runtime_sec": 135.815605, - "accepted_e04a_runtime_sec": 24.362414, - "candidate_runtime_sec": 26.530668, - "candidate_over_e04a_ratio": 1.089, - "speedup_over_reference": 5.11841, - "candidate_initial_energy": -6.8462643623, - "candidate_final_history_energy": -10.0279579163, - "candidate_improvement": 3.1816935539, - "candidate_post_update_trajectory_mean": -10.033449173, - "candidate_post_update_trajectory_std": 3.3379e-06, - "candidate_passed": true - } - ], - "decision": "discard for the canonical metric; it is fastest for one and 50 steps, but dense state materialization makes 100 steps 8.90% slower than accepted e04a" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json b/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json deleted file mode 100644 index 6ad677e..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e06-vvag-screen.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "experiment": "e06", - "candidate_commit": "828e921ddf69709054d5fa52a5e3e62d9fac475e", - "candidate_sha256": "4f0a8757af372c41db677981f1551c363f82f128e0f295073228defece065c68", - "candidate_diff_sha256": "82e90bad5bb428a53d623e268808a22a1ca321a686540f8e7c8ea5b46a15d7fa", - "screen": { - "max_steps": 1, - "accepted_e04a_runtime_sec": 20.672377, - "candidate_runtime_sec": 39.419801, - "candidate_over_e04a_ratio": 1.90687, - "candidate_initial_energy": -6.8462719917, - "candidate_post_update_trajectory_mean": -6.9686336517, - "physical_outputs_within_tolerance": true - }, - "decision": "discard; vvag duplicates per-trajectory reverse-mode structure and is 90.69% slower at the frozen screen" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json b/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json deleted file mode 100644 index 67445c0..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e07-classical-ancilla-audit.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "full_ancilla_gradient_max_abs": 4.6559398469980806e-07, - "full_vs_analytic_bits_equal": true, - "gradient_max_abs_error": 1.511594746261835e-06, - "initial_energy": { - "abs_error": 4.76837158203125e-06, - "full": -6.8462653160095215, - "reduced": -6.8462700843811035 - }, - "non_ancilla_gradient_max_abs_error": 1.511594746261835e-06, - "passed": true, - "pattern_counts": [ - 63, - 1 - ], - "post_update_energy": { - "abs_error": 4.673004150390625e-05, - "full": -6.968633651733398, - "reduced": -6.968680381774902 - }, - "post_update_parameter_max_abs_error": 0.01957935094833374, - "rare_trajectory_indices": [ - 36 - ], - "reduced_ancilla_gradient_max_abs": 0.0, - "schema_version": 1, - "task_id": "07", - "trajectory_energy_max_abs_error": 4.291534423828125e-06, - "unique_pattern_count": 2 -} diff --git a/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json b/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json deleted file mode 100644 index 3840488..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e11-contractor-six-pair-screen.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "purpose": "post-reduction contractor selection screen", - "configuration": { - "repeat": 6, - "max_steps": 100, - "cpus": 6, - "memory": "7g", - "network": "none", - "image": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "fresh_container_per_cell": true, - "pair_order": "odd incumbent->plain-experimental; even plain-experimental->incumbent" - }, - "greedy_vs_plain_experimental": { - "greedy_runtime_sec": [ - 3.031118, - 2.885613, - 2.866804, - 2.928691, - 2.884610, - 3.086906 - ], - "plain_experimental_runtime_sec": [ - 2.743461, - 2.857651, - 2.813869, - 2.870540, - 2.802305, - 2.852678 - ], - "greedy_mean_sec": 2.9472903333333336, - "plain_experimental_mean_sec": 2.8234173333333334, - "mean_paired_speedup": 1.0441975726959485, - "paired_speedup_stderr": 0.016060044771815166, - "paired_speedup_ci_95": [ - 1.0029139133105376, - 1.0854812320813594 - ], - "plain_experimental_wins": 6, - "all_cells_passed": true - }, - "omeco_1x1_vs_plain_experimental": { - "omeco_1x1_runtime_sec": [ - 2.964172, - 2.917681, - 2.854544, - 3.073592, - 2.902695, - 2.981453 - ], - "plain_experimental_runtime_sec": [ - 2.790114, - 2.808054, - 2.891351, - 2.763116, - 2.825308, - 2.956301 - ], - "omeco_1x1_mean_sec": 2.9490228333333333, - "plain_experimental_mean_sec": 2.8390406666666665, - "mean_paired_speedup": 1.0394928362030935, - "paired_speedup_stderr": 0.01795200077974768, - "paired_speedup_ci_95": [ - 0.9933457490680451, - 1.085639923338142 - ], - "plain_experimental_wins": 5, - "all_cells_passed": true - }, - "discarded_warmup_attempt": { - "reason": "macOS Docker could not bind-mount a /private/tmp worktree and all greedy cells failed before evaluator execution", - "used_in_statistics": false - }, - "decision": "plain-experimental" -} diff --git a/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json b/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json deleted file mode 100644 index 3de2b93..0000000 --- a/optimized_solutions/challenge-07/research/profiles/e11-final-canonical-six-pairs.json +++ /dev/null @@ -1,630 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "started_at_utc": "2026-07-29T02:18:11.372804+00:00", - "finished_at_utc": "2026-07-29T02:32:55.247868+00:00", - "session_wall_sec": 883.8707169160189, - "configuration": { - "repeat": 6, - "max_steps": 100, - "timeout_sec": 300.0, - "cpus": 6.0, - "memory": "7g", - "pair_order": "odd reference->candidate; even candidate->reference", - "fresh_evaluator_process_per_cell": true, - "single_container": true - }, - "host": { - "uname": "Darwin QQYdeMacBook-Air.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:34 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8112 arm64", - "cpu": "Apple M2", - "physical_memory": "17179869184", - "fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" - }, - "image": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "snapshot": { - "reference": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "candidate": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "sitecustomize": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120" - }, - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "results": [ - { - "cell_id": "task07-01", - "pair": 1, - "position": 1, - "order": "reference->candidate", - "task_id": "07", - "solution": "reference", - "repeat_index": 1, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 123.28606, - "wall_sec": 124.74236662499607, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-01-reference.stdout.txt", - "stderr_path": "logs/cell-01-reference.stderr.txt", - "stdout_sha256": "2a23418ae98386e3fbb1cd9e0a6e993a976f585908b077e89259a7545cfd3938", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-02", - "pair": 1, - "position": 2, - "order": "reference->candidate", - "task_id": "07", - "solution": "candidate", - "repeat_index": 1, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 3.062554, - "wall_sec": 4.301580749975983, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-02-candidate.stdout.txt", - "stderr_path": "logs/cell-02-candidate.stderr.txt", - "stdout_sha256": "1e0b1c1ba0352bb0cf57a481d9ad516abe32eee0c8fa40b2fc614f835bcbce10", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-03", - "pair": 2, - "position": 1, - "order": "candidate->reference", - "task_id": "07", - "solution": "candidate", - "repeat_index": 2, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 3.311737, - "wall_sec": 4.367966541991336, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-03-candidate.stdout.txt", - "stderr_path": "logs/cell-03-candidate.stderr.txt", - "stdout_sha256": "4d906b12bdea17e8540e1d876df6757c08815210466bcb28824503c29a2979f4", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-04", - "pair": 2, - "position": 2, - "order": "candidate->reference", - "task_id": "07", - "solution": "reference", - "repeat_index": 2, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 126.247088, - "wall_sec": 127.39457612499245, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-04-reference.stdout.txt", - "stderr_path": "logs/cell-04-reference.stderr.txt", - "stdout_sha256": "81e3c7ab8cb79dcab888a9ba1f296362793331a8bd9d2ac2bbcb53f69f137c4d", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-05", - "pair": 3, - "position": 1, - "order": "reference->candidate", - "task_id": "07", - "solution": "reference", - "repeat_index": 3, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 150.224728, - "wall_sec": 151.55164112499915, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-05-reference.stdout.txt", - "stderr_path": "logs/cell-05-reference.stderr.txt", - "stdout_sha256": "2094ee9648970228aa20d78db4867c66653c74335b3793b3f3e873937cf5d7e9", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-06", - "pair": 3, - "position": 2, - "order": "reference->candidate", - "task_id": "07", - "solution": "candidate", - "repeat_index": 3, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 2.989908, - "wall_sec": 4.167482208984438, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-06-candidate.stdout.txt", - "stderr_path": "logs/cell-06-candidate.stderr.txt", - "stdout_sha256": "9335e2f49ddcd908fc919157badb1c9e122d7b4e57db8036e4bfc543eb9e0123", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-07", - "pair": 4, - "position": 1, - "order": "candidate->reference", - "task_id": "07", - "solution": "candidate", - "repeat_index": 4, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 3.030923, - "wall_sec": 4.051274541998282, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-07-candidate.stdout.txt", - "stderr_path": "logs/cell-07-candidate.stderr.txt", - "stdout_sha256": "64513b93683b9df3458a87abd45b94e4a7274fd1caaa28ce74eed3f70892c1a8", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-08", - "pair": 4, - "position": 2, - "order": "candidate->reference", - "task_id": "07", - "solution": "reference", - "repeat_index": 4, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 129.913867, - "wall_sec": 131.0978523750091, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-08-reference.stdout.txt", - "stderr_path": "logs/cell-08-reference.stderr.txt", - "stdout_sha256": "cda077fecbe4d0d58d3ce68ea476893bfc0fa38d2a6337e33e7e598a5f7e6ea5", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-09", - "pair": 5, - "position": 1, - "order": "reference->candidate", - "task_id": "07", - "solution": "reference", - "repeat_index": 5, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 159.579514, - "wall_sec": 161.19171666601324, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-09-reference.stdout.txt", - "stderr_path": "logs/cell-09-reference.stderr.txt", - "stdout_sha256": "fcce1a58beb2bde886a64d8b841f771a8d8ae249c25fb26bcc2d29732b642010", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-10", - "pair": 5, - "position": 2, - "order": "reference->candidate", - "task_id": "07", - "solution": "candidate", - "repeat_index": 5, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 3.06333, - "wall_sec": 4.332712417002767, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-10-candidate.stdout.txt", - "stderr_path": "logs/cell-10-candidate.stderr.txt", - "stdout_sha256": "cd6ddb2b9b2fce917d82a2b7eb9ef759f2f88d7b4d80d740687dac2e83556ea9", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-11", - "pair": 6, - "position": 1, - "order": "candidate->reference", - "task_id": "07", - "solution": "candidate", - "repeat_index": 6, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 2.966582, - "wall_sec": 4.002367916982621, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "0337bf428a7c4a820f12f7db1232620b2777677617dd4f1a657dfd5f53bbdb0e", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-11-candidate.stdout.txt", - "stderr_path": "logs/cell-11-candidate.stderr.txt", - "stdout_sha256": "2819622c79880d12faace0e820ed159aacfbc79f0c7b032940c296892efbd919", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - { - "cell_id": "task07-12", - "pair": 6, - "position": 2, - "order": "candidate->reference", - "task_id": "07", - "solution": "reference", - "repeat_index": 6, - "planned_repeats": 6, - "max_steps": 100, - "runtime_sec": 151.207388, - "wall_sec": 152.35602883298998, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "returncode": 0, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": { - "reference": "orbitbreakers-expert-benchmarks:tensorcircuit-py311", - "id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "repo_digests": [ - "challenge-benchmark-quantum-tensorcircuit@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "orbitbreakers-expert-benchmarks@sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833" - ], - "created": "2026-07-27T22:15:05.362478611+08:00", - "architecture": "arm64", - "os": "linux" - }, - "container_id": "1f4c20045377d26bd2f9023cb1c93b09a8aeee6dedb79e3853b8c832565bc622", - "container_name": "orbit-task07-matrix-ef51965c7b", - "cpu_limit": "6.0", - "memory_limit": "7g", - "timeout_sec": 300.0, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "d46912b2aba5e201c56754f98a21065be1009fe3c90d105a4a2b29b95aeaab0f", - "stdout_path": "logs/cell-12-reference.stdout.txt", - "stderr_path": "logs/cell-12-reference.stderr.txt", - "stdout_sha256": "e529b0ab17d651cd0c88c9c96bbd130e03d3fc0c9de22cfb81e4a82ccb3e9d1b", - "stderr_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - } - ], - "pairs": [ - { - "pair": 1, - "reference_runtime_sec": 123.28606, - "candidate_runtime_sec": 3.062554, - "speedup": 40.25596283363493, - "candidate_won": true - }, - { - "pair": 2, - "reference_runtime_sec": 126.247088, - "candidate_runtime_sec": 3.311737, - "speedup": 38.12110925475061, - "candidate_won": true - }, - { - "pair": 3, - "reference_runtime_sec": 150.224728, - "candidate_runtime_sec": 2.989908, - "speedup": 50.24392991356256, - "candidate_won": true - }, - { - "pair": 4, - "reference_runtime_sec": 129.913867, - "candidate_runtime_sec": 3.030923, - "speedup": 42.86280680835508, - "candidate_won": true - }, - { - "pair": 5, - "reference_runtime_sec": 159.579514, - "candidate_runtime_sec": 3.06333, - "speedup": 52.09347801248967, - "candidate_won": true - }, - { - "pair": 6, - "reference_runtime_sec": 151.207388, - "candidate_runtime_sec": 2.966582, - "speedup": 50.9702371281158, - "candidate_won": true - } - ], - "summary": { - "all_cells_passed": true, - "reference": { - "n": 6, - "mean": 140.07644083333332, - "median": 140.0692975, - "sample_stdev": 15.38636653290017, - "stderr": 6.281457833506891, - "min": 123.28606, - "max": 159.579514 - }, - "candidate": { - "n": 6, - "mean": 3.070839, - "median": 3.0467385, - "sample_stdev": 0.1242332552708815, - "stderr": 0.050718014083098076, - "min": 2.966582, - "max": 3.311737 - }, - "ratio_of_means_speedup": 45.615039027879135, - "ratio_of_means_improvement_pct": 97.80774055813299, - "paired_speedup": { - "n": 6, - "mean": 45.75792065848478, - "median": 46.55336836095882, - "sample_stdev": 6.072988087094512, - "stderr": 2.4792870045637403, - "min": 38.12110925475061, - "max": 52.09347801248967 - }, - "paired_speedup_ci_95": { - "method": "two-sided Student-t interval on mean pairwise speedup", - "low": 39.38471051683481, - "high": 52.13113080013475 - }, - "candidate_wins": 6, - "promotion_rule_passed": true - } -} diff --git a/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json b/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json deleted file mode 100644 index ca4751c..0000000 --- a/optimized_solutions/challenge-07/research/profiles/final-canonical-six-pairs.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "classification": "final counterbalanced canonical paired benchmark", - "measurement_window_utc": { - "first_cell_finished": "2026-07-29T00:57:01Z", - "last_cell_finished": "2026-07-29T01:09:42Z" - }, - "recovery_note": "All 12 raw stdout/stderr logs were written before a final report-serialization NameError (Python true instead of True). No cell was rerun, omitted, or altered; this sanitized report was reconstructed directly from those logs.", - "environment": { - "image_id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833", - "container_id_prefix": "b8199b0e1e6a", - "container_name": "orbit-task07-matrix-34ea5ae79e", - "cpus": 6, - "memory": "7 GiB", - "network": "none", - "timeout_sec": 300, - "host_fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44" - }, - "source": { - "reference_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "candidate_sha256": "0cd9676dc904660597a2f7dd6981fdac596295e4eae99510a3f4f21671859592", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "sitecustomize_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120" - }, - "pairs": [ - { - "pair": 1, - "order": "reference->candidate", - "reference_runtime_sec": 106.038165, - "candidate_runtime_sec": 24.481295, - "speedup": 4.331395255030422, - "both_passed": true - }, - { - "pair": 2, - "order": "candidate->reference", - "reference_runtime_sec": 119.427967, - "candidate_runtime_sec": 24.221592, - "speedup": 4.930640686210881, - "both_passed": true - }, - { - "pair": 3, - "order": "reference->candidate", - "reference_runtime_sec": 123.188182, - "candidate_runtime_sec": 24.716431, - "speedup": 4.984060279576772, - "both_passed": true - }, - { - "pair": 4, - "order": "candidate->reference", - "reference_runtime_sec": 107.532991, - "candidate_runtime_sec": 24.421997, - "speedup": 4.403120309940255, - "both_passed": true - }, - { - "pair": 5, - "order": "reference->candidate", - "reference_runtime_sec": 110.084619, - "candidate_runtime_sec": 31.684172, - "speedup": 3.4744357214068904, - "both_passed": true - }, - { - "pair": 6, - "order": "candidate->reference", - "reference_runtime_sec": 131.316223, - "candidate_runtime_sec": 27.652166, - "speedup": 4.74885848001925, - "both_passed": true - } - ], - "summary": { - "passing_cells": 12, - "passing_pairs": 6, - "candidate_wins": 6, - "reference": { - "mean_runtime_sec": 116.26469116666667, - "median_runtime_sec": 114.756293, - "sample_stdev_sec": 10.035012377372944, - "stderr_sec": 4.096776647846211, - "min_sec": 106.038165, - "max_sec": 131.316223 - }, - "candidate": { - "mean_runtime_sec": 26.1962755, - "median_runtime_sec": 24.598863, - "sample_stdev_sec": 2.9804416492525903, - "stderr_sec": 1.2167602081346665, - "min_sec": 24.221592, - "max_sec": 31.684172 - }, - "ratio_of_means_speedup": 4.43821455331185, - "ratio_of_means_improvement_pct": 77.4684169053119, - "paired_speedup": { - "mean": 4.478751788697412, - "median": 4.575989394979753, - "sample_stdev": 0.5601040444343872, - "stderr": 0.22866151862223416, - "ci_95_student_t_low": 3.8909586421977242, - "ci_95_student_t_high": 5.0665449351971 - }, - "promotion_rule_passed": true - }, - "raw_stdout_sha256": [ - "07dce676f856d902098311f2a36eff06d5ccbe5bbf477a10107c6fcd4aa305fd", - "d6acf849d92b638521b558ffb23edff7eb3b923ae19be278c6e6fa829dc9e46e", - "ca3748a9698e68ade3ae1955e9d383b155b33787b4bdf9c7f0e5a18cd97f322b", - "e5fb653e281481644b90fa0f1cd6b9900a2db80b86548bae14f4d43c57232acd", - "1075dc014a7b6d99e6edc82f868fdd7fdef976ac246b6abee8056d9646a0f66a", - "e9f0ee39e311c167fe43065aa7d3ad35d2f6542e56ae215046ffa87441ed4288", - "6e9556f4206792fb29024c72349f0218f7d6276b7968be24b66397bd92e9a411", - "8c17ca159dd7a39cfd95e2f4cdb4dee416b2dfb7d322c30ecdea5f66e039086a", - "492bf197a17a8dfb1597d826418014a6f0911424a65afddcbf15fcffe906b4bf", - "9fd2be1ab0f4f41c1d162c727ef0bb41830258bb821fd0bbe0142d57aae93595", - "a961e92e87c90a05c2291196ff73f3c59c6eb9422e279ce2557aae3b3ae70b9c", - "02768532f47b20565ee382d7be8d6fed8b02b23b36a2c82dc11f69867be169c2" - ] -} diff --git a/optimized_solutions/challenge-07/research/profiles/final-reference-six.json b/optimized_solutions/challenge-07/research/profiles/final-reference-six.json deleted file mode 100644 index 7c1022e..0000000 --- a/optimized_solutions/challenge-07/research/profiles/final-reference-six.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "schema_version": 1, - "task_id": "07", - "host": { - "fingerprint_sha256": "8188765e4acb94ead1ba5de9e79cb6cb2be366ecfa06948a06df2ef871880aab" - }, - "results": [ - { - "task_id": "07", - "solution": "reference", - "repeat": 1, - "planned_repeats": 6, - "runtime_sec": 106.038165, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - }, - { - "task_id": "07", - "solution": "reference", - "repeat": 2, - "planned_repeats": 6, - "runtime_sec": 119.427967, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - }, - { - "task_id": "07", - "solution": "reference", - "repeat": 3, - "planned_repeats": 6, - "runtime_sec": 123.188182, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - }, - { - "task_id": "07", - "solution": "reference", - "repeat": 4, - "planned_repeats": 6, - "runtime_sec": 107.532991, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - }, - { - "task_id": "07", - "solution": "reference", - "repeat": 5, - "planned_repeats": 6, - "runtime_sec": 110.084619, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - }, - { - "task_id": "07", - "solution": "reference", - "repeat": 6, - "planned_repeats": 6, - "runtime_sec": 131.316223, - "passed": true, - "timed_out": false, - "terminal_status": "SUCCESS", - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": {"id": "sha256:b059c5fa7f75702f9afbf94ec7866e102ac32afd59d25634ec0aca0fd56e2833"}, - "timeout_sec": 300, - "source_sha256": "ac483319363f3c386a7646eaa867670ae3d3cd687f8517e6d4201e69240ff0a3", - "evaluator_sha256": "69717d98a90a7e53c31686128b3ef3e7cea3c96685ec538662a12163fe324b31", - "staging_snapshot_sha256": "e5faae4102a95cde78ecefe41be5d9532832e9f82df89c25bab3b308d0460b44", - "compatibility_sha256": "02800060761f2b15abe9055aded49d2af3877ab93d7b0fae8af94b30bac30120", - "shared_container_id": "b8199b0e1e6a", - "shared_container_name": "orbit-task07-matrix-34ea5ae79e", - "command": ["docker", "exec", "--workdir", "/session", "orbit-task07-matrix-34ea5ae79e", "python", "/session/evaluate_7.py", "--solution", "solution_7_reference"], - "shared_container_start_command": ["docker", "run", "--detach", "--rm", "--name", "orbit-task07-matrix-34ea5ae79e", "--network", "none", "--mount", "type=bind,src=,dst=/session,readonly", "--cpus", "6.0", "--memory", "7g"] - } - ] -} diff --git a/optimized_solutions/challenge-07/research/run_docker_matrix.py b/optimized_solutions/challenge-07/research/run_docker_matrix.py deleted file mode 100644 index 35d94df..0000000 --- a/optimized_solutions/challenge-07/research/run_docker_matrix.py +++ /dev/null @@ -1,418 +0,0 @@ -#!/usr/bin/env python3 -"""Run counterbalanced Task 07 reference/candidate pairs in one container.""" - -from __future__ import annotations - -import argparse -import hashlib -import json -import math -import re -import shutil -import statistics -import subprocess -import tempfile -import time -import uuid -from datetime import datetime, timezone -from pathlib import Path - - -ROOT = Path(__file__).resolve().parents[2] -RUNTIME_RE = re.compile(r"End-to-end solution time:\s*([0-9.]+)s") -T_CRITICAL_95 = {5: 2.5705818366} - - -def sha256(path: Path) -> str: - return hashlib.sha256(path.read_bytes()).hexdigest() - - -def utc_now() -> str: - return datetime.now(timezone.utc).isoformat() - - -def run(command: list[str], timeout: float = 30) -> subprocess.CompletedProcess[str]: - return subprocess.run( - command, - check=False, - text=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - timeout=timeout, - ) - - -def stats(values: list[float]) -> dict[str, float | int | None]: - stdev = statistics.stdev(values) if len(values) > 1 else None - return { - "n": len(values), - "mean": statistics.mean(values) if values else None, - "median": statistics.median(values) if values else None, - "sample_stdev": stdev, - "stderr": stdev / math.sqrt(len(values)) if stdev is not None else None, - "min": min(values) if values else None, - "max": max(values) if values else None, - } - - -def host_record() -> dict[str, object]: - commands = { - "uname": ["uname", "-a"], - "cpu": ["sysctl", "-n", "machdep.cpu.brand_string"], - "physical_memory": ["sysctl", "-n", "hw.memsize"], - } - record: dict[str, object] = {} - for key, command in commands.items(): - try: - result = run(command) - record[key] = result.stdout.strip() if result.returncode == 0 else None - except (OSError, subprocess.TimeoutExpired): - record[key] = None - record["fingerprint_sha256"] = hashlib.sha256( - json.dumps(record, sort_keys=True).encode() - ).hexdigest() - return record - - -def image_record(reference: str) -> dict[str, object]: - result = run(["docker", "image", "inspect", reference]) - if result.returncode: - raise RuntimeError(result.stderr.strip() or f"cannot inspect {reference}") - raw = json.loads(result.stdout)[0] - return { - "reference": reference, - "id": raw.get("Id"), - "repo_digests": raw.get("RepoDigests") or [], - "created": raw.get("Created"), - "architecture": raw.get("Architecture"), - "os": raw.get("Os"), - } - - -def parse_args() -> argparse.Namespace: - parser = argparse.ArgumentParser() - parser.add_argument("--repeat", type=int, default=6) - parser.add_argument("--max-steps", type=int, default=100) - parser.add_argument("--timeout", type=float, default=300.0) - parser.add_argument("--cpus", type=float, default=6.0) - parser.add_argument("--memory", default="7g") - parser.add_argument( - "--image", - default="orbitbreakers-expert-benchmarks:tensorcircuit-py311", - ) - parser.add_argument("--output", type=Path, required=True) - return parser.parse_args() - - -def main() -> None: - args = parse_args() - if args.repeat <= 0 or args.max_steps <= 0: - raise SystemExit("repeat and max-steps must be positive") - timeout = min(args.timeout, 300.0) - output = args.output.expanduser().resolve() - logs = output / "logs" - logs.mkdir(parents=True, exist_ok=True) - - sources = { - "reference": ROOT / "references/task-07/solution_7.py", - "candidate": ROOT / "src/solutions/task-07/solution_7.py", - } - evaluator = ROOT / "tasks/task-07/evaluator/evaluate_7.py" - sitecustomize = ROOT / "envs/tensorcircuit-py311/sitecustomize.py" - for path in [*sources.values(), evaluator, sitecustomize]: - if not path.is_file(): - raise SystemExit(f"missing required file: {path}") - - image = image_record(args.image) - host = host_record() - container_name = f"orbit-task07-matrix-{uuid.uuid4().hex[:10]}" - started_at = utc_now() - session_started = time.perf_counter() - rows: list[dict[str, object]] = [] - - staging_root = ROOT / ".tmp" - staging_root.mkdir(exist_ok=True) - with tempfile.TemporaryDirectory(prefix="task07-matrix-", dir=staging_root) as tmp: - staging = Path(tmp) - shutil.copy2(evaluator, staging / "evaluate_7.py") - environment = staging / "environment" - environment.mkdir() - shutil.copy2(sitecustomize, environment / "sitecustomize.py") - modules: dict[str, str] = {} - snapshot: dict[str, str] = {} - for role, source in sources.items(): - module = f"solution_7_{role}" - modules[role] = module - target = staging / f"{module}.py" - shutil.copy2(source, target) - snapshot[role] = sha256(target) - snapshot["evaluator"] = sha256(staging / "evaluate_7.py") - snapshot["sitecustomize"] = sha256(environment / "sitecustomize.py") - snapshot_sha256 = hashlib.sha256( - json.dumps(snapshot, sort_keys=True).encode() - ).hexdigest() - - start_command = [ - "docker", - "run", - "--detach", - "--rm", - "--name", - container_name, - "--network", - "none", - "--tmpfs", - "/tmp:rw,noexec,nosuid,size=1g", - "--mount", - f"type=bind,src={staging.resolve()},dst=/session,readonly", - "--workdir", - "/session", - "--env", - "NUMBA_DISABLE_JIT=1", - "--env", - "PYTHONPATH=/session:/session/environment", - "--cpus", - str(args.cpus), - "--memory", - args.memory, - args.image, - "tail", - "-f", - "/dev/null", - ] - started = run(start_command, timeout=60) - if started.returncode: - raise SystemExit(started.stderr.strip() or "container start failed") - container_id = started.stdout.strip() - - plan: list[tuple[int, int, str, str]] = [] - for pair in range(1, args.repeat + 1): - roles = ( - ("reference", "candidate") - if pair % 2 - else ("candidate", "reference") - ) - order = "->".join(roles) - for position, role in enumerate(roles, start=1): - plan.append((pair, position, role, order)) - - try: - for cell, (pair, position, role, order) in enumerate(plan, start=1): - command = [ - "docker", - "exec", - "--workdir", - "/session", - "--env", - "NUMBA_DISABLE_JIT=1", - "--env", - "PYTHONPATH=/session:/session/environment", - container_name, - "python", - "/session/evaluate_7.py", - "--solution", - modules[role], - "--max-steps", - str(args.max_steps), - ] - wall_started = time.perf_counter() - timed_out = False - try: - result = run(command, timeout=timeout) - stdout, stderr, returncode = ( - result.stdout, - result.stderr, - result.returncode, - ) - except subprocess.TimeoutExpired as exc: - timed_out = True - stdout = exc.stdout or "" - stderr = exc.stderr or "" - returncode = None - wall_sec = time.perf_counter() - wall_started - stdout_path = logs / f"cell-{cell:02d}-{role}.stdout.txt" - stderr_path = logs / f"cell-{cell:02d}-{role}.stderr.txt" - stdout_path.write_text(stdout, encoding="utf-8") - stderr_path.write_text(stderr, encoding="utf-8") - match = RUNTIME_RE.search(stdout) - runtime = float(match.group(1)) if match else None - passed = ( - not timed_out - and returncode == 0 - and runtime is not None - and "Overall: PASS" in stdout - ) - row = { - "cell_id": f"task07-{cell:02d}", - "pair": pair, - "position": position, - "order": order, - "task_id": "07", - "solution": role, - "repeat_index": pair, - "planned_repeats": args.repeat, - "max_steps": args.max_steps, - "runtime_sec": runtime, - "wall_sec": wall_sec, - "passed": passed, - "timed_out": timed_out, - "terminal_status": "SUCCESS" if passed else "FAILED", - "returncode": returncode, - "engine": "docker", - "environment": "tensorcircuit-py311", - "environment_image_provenance": image, - "container_id": container_id, - "container_name": container_name, - "cpu_limit": str(args.cpus), - "memory_limit": args.memory, - "timeout_sec": timeout, - "source_sha256": snapshot[role], - "evaluator_sha256": snapshot["evaluator"], - "staging_snapshot_sha256": snapshot_sha256, - "stdout_path": str(stdout_path.relative_to(output)), - "stderr_path": str(stderr_path.relative_to(output)), - "stdout_sha256": sha256(stdout_path), - "stderr_sha256": sha256(stderr_path), - } - rows.append(row) - (output / "checkpoint.json").write_text( - json.dumps( - { - "schema_version": 1, - "task_id": "07", - "configuration": { - "repeat": args.repeat, - "max_steps": args.max_steps, - "cpus": args.cpus, - "memory": args.memory, - }, - "host": host, - "image": image, - "snapshot": snapshot, - "staging_snapshot_sha256": snapshot_sha256, - "results": rows, - }, - indent=2, - ) - + "\n", - encoding="utf-8", - ) - print( - f"cell {cell:02d}/{len(plan)} pair={pair} role={role} " - f"runtime={runtime} passed={passed}", - flush=True, - ) - finally: - run(["docker", "stop", container_name], timeout=60) - - reference = [ - float(row["runtime_sec"]) - for row in rows - if row["solution"] == "reference" and row["passed"] - ] - candidate = [ - float(row["runtime_sec"]) - for row in rows - if row["solution"] == "candidate" and row["passed"] - ] - by_pair: dict[int, dict[str, float]] = {} - for row in rows: - if row["passed"]: - by_pair.setdefault(int(row["pair"]), {})[str(row["solution"])] = float( - row["runtime_sec"] - ) - pair_rows = [] - speedups = [] - for pair in sorted(by_pair): - values = by_pair[pair] - if set(values) == {"reference", "candidate"}: - speedup = values["reference"] / values["candidate"] - speedups.append(speedup) - pair_rows.append( - { - "pair": pair, - "reference_runtime_sec": values["reference"], - "candidate_runtime_sec": values["candidate"], - "speedup": speedup, - "candidate_won": values["candidate"] < values["reference"], - } - ) - - speedup_stats = stats(speedups) - ci_low = ci_high = None - if len(speedups) > 1: - critical = T_CRITICAL_95.get(len(speedups) - 1) - if critical is not None: - radius = critical * float(speedup_stats["stderr"]) - ci_low = float(speedup_stats["mean"]) - radius - ci_high = float(speedup_stats["mean"]) + radius - ref_stats, cand_stats = stats(reference), stats(candidate) - all_passed = len(rows) == 2 * args.repeat and all(row["passed"] for row in rows) - promotion = ( - all_passed - and len(speedups) == args.repeat - and float(cand_stats["mean"]) < float(ref_stats["mean"]) - and float(cand_stats["median"]) < float(ref_stats["median"]) - and sum(row["candidate_won"] for row in pair_rows) - >= math.ceil(0.8 * args.repeat) - and ci_low is not None - and ci_low > 1.0 - ) - report = { - "schema_version": 1, - "task_id": "07", - "started_at_utc": started_at, - "finished_at_utc": utc_now(), - "session_wall_sec": time.perf_counter() - session_started, - "configuration": { - "repeat": args.repeat, - "max_steps": args.max_steps, - "timeout_sec": timeout, - "cpus": args.cpus, - "memory": args.memory, - "pair_order": "odd reference->candidate; even candidate->reference", - "fresh_evaluator_process_per_cell": True, - "single_container": True, - }, - "host": host, - "image": image, - "snapshot": snapshot, - "staging_snapshot_sha256": snapshot_sha256, - "results": rows, - "pairs": pair_rows, - "summary": { - "all_cells_passed": all_passed, - "reference": ref_stats, - "candidate": cand_stats, - "ratio_of_means_speedup": ( - float(ref_stats["mean"]) / float(cand_stats["mean"]) - if reference and candidate - else None - ), - "ratio_of_means_improvement_pct": ( - 100 - * (float(ref_stats["mean"]) - float(cand_stats["mean"])) - / float(ref_stats["mean"]) - if reference and candidate - else None - ), - "paired_speedup": speedup_stats, - "paired_speedup_ci_95": { - "method": "two-sided Student-t interval on mean pairwise speedup", - "low": ci_low, - "high": ci_high, - }, - "candidate_wins": sum(row["candidate_won"] for row in pair_rows), - "promotion_rule_passed": promotion, - }, - } - (output / "results.json").write_text( - json.dumps(report, indent=2) + "\n", encoding="utf-8" - ) - print(json.dumps(report["summary"], indent=2), flush=True) - if not promotion: - raise SystemExit(1) - - -if __name__ == "__main__": - main() diff --git a/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py b/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py deleted file mode 100644 index c1f9464..0000000 --- a/optimized_solutions/challenge-07/research/validate_classical_ancilla_reduction.py +++ /dev/null @@ -1,320 +0,0 @@ -#!/usr/bin/env python3 -"""Audit the exact classical-ancilla reduction proposed for Task 07.""" - -from __future__ import annotations - -import argparse -import importlib.util -import json -from pathlib import Path -from typing import Any - -import jax -import numpy as np -import optax -import tensorcircuit as tc - - -CONFIG = { - "n_data_qubits": 8, - "n_ancilla_qubits": 8, - "n_qubits": 16, - "n_layers": 2, - "n_trajectories": 64, - "initial_parameter_scale": 0.1, - "max_steps": 100, - "learning_rate": 0.02, - "seed": 2047, - "transverse_field": 1.05, - "minimum_improvement": 0.3, - "target_final_energy": -8.3, -} - -K = tc.set_backend("jax") -tc.set_dtype("complex64") -tc.set_contractor("omeco-1-1") - - -def load_solution(path: Path) -> Any: - spec = importlib.util.spec_from_file_location("task07_current_candidate", path) - if spec is None or spec.loader is None: - raise RuntimeError(f"cannot import candidate: {path}") - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - return module - - -def ready(value: Any) -> Any: - return jax.tree.map( - lambda leaf: leaf.block_until_ready() - if hasattr(leaf, "block_until_ready") - else leaf, - value, - ) - - -def exact_full_bits(params: Any, status: Any) -> Any: - c = tc.Circuit(CONFIG["n_qubits"]) - pidx = 0 - sidx = 0 - layers = [] - for _ in range(CONFIG["n_layers"]): - for q in range(CONFIG["n_data_qubits"]): - c.ry(q, theta=params[pidx + q]) - pidx += CONFIG["n_data_qubits"] - for a in range(CONFIG["n_ancilla_qubits"]): - c.ry(CONFIG["n_data_qubits"] + a, theta=params[pidx + a]) - pidx += CONFIG["n_ancilla_qubits"] - for a in range(CONFIG["n_ancilla_qubits"]): - c.rzz( - CONFIG["n_data_qubits"] + a, - a, - theta=params[pidx + a], - ) - pidx += CONFIG["n_ancilla_qubits"] - for a in range(CONFIG["n_ancilla_qubits"] - 1): - c.cnot( - CONFIG["n_data_qubits"] + a, - CONFIG["n_data_qubits"] + a + 1, - ) - theta0 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] - pidx += CONFIG["n_ancilla_qubits"] - theta1 = params[pidx : pidx + CONFIG["n_ancilla_qubits"]] - pidx += CONFIG["n_ancilla_qubits"] - bits = [] - for a in range(CONFIG["n_ancilla_qubits"]): - bit = c.cond_measure( - CONFIG["n_data_qubits"] + a, status=status[sidx] - ) - bitf = K.cast(bit, "float32") - feedback = theta0[a] + bitf * (theta1[a] - theta0[a]) - c.rz(a, theta=(1.0 - 2.0 * bitf) * feedback) - bits.append(bit) - sidx += 1 - for q in range(CONFIG["n_data_qubits"] - 1): - c.cnot(q, q + 1) - for q in range(CONFIG["n_data_qubits"]): - c.rz(q, theta=params[pidx + q]) - pidx += CONFIG["n_data_qubits"] - layers.append(K.stack(bits)) - return K.stack(layers) - - -def analytic_bits(params: Any, status: Any) -> tuple[Any, Any]: - previous_measured = K.zeros([CONFIG["n_ancilla_qubits"]], dtype="int32") - measured_layers = [] - pre_ladder_layers = [] - sidx = 0 - for layer in range(CONFIG["n_layers"]): - offset = layer * 48 - ancilla_angles = params[offset + 8 : offset + 16] - base_probability_one = K.sin(ancilla_angles / 2.0) ** 2 - previous_float = K.cast(previous_measured, "float32") - probability_one = base_probability_one + previous_float * ( - 1.0 - 2.0 * base_probability_one - ) - measured = [] - pre_ladder = [] - previous_output = K.convert_to_tensor(0, dtype="int32") - for a in range(CONFIG["n_ancilla_qubits"]): - previous_output_float = K.cast(previous_output, "float32") - measured_probability_one = probability_one[a] + previous_output_float * ( - 1.0 - 2.0 * probability_one[a] - ) - bit = K.cast( - status[sidx] > (1.0 - measured_probability_one), "int32" - ) - source_bit = bit + previous_output - 2 * bit * previous_output - measured.append(bit) - pre_ladder.append(source_bit) - previous_output = bit - sidx += 1 - previous_measured = K.stack(measured) - measured_layers.append(previous_measured) - pre_ladder_layers.append(K.stack(pre_ladder)) - return K.stack(measured_layers), K.stack(pre_ladder_layers) - - -def make_reduced_energy() -> Any: - strings = [] - weights = [] - for i in range(CONFIG["n_data_qubits"] - 1): - term = [0] * CONFIG["n_data_qubits"] - term[i] = 3 - term[i + 1] = 3 - strings.append(term) - weights.append(-1.0) - for i in range(CONFIG["n_data_qubits"]): - term = [0] * CONFIG["n_data_qubits"] - term[i] = 1 - strings.append(term) - weights.append(-CONFIG["transverse_field"]) - hamiltonian = tc.quantum.PauliStringSum2COO(strings, weights) - - def reduced_energy(params: Any, pattern: Any) -> Any: - measured, pre_ladder = pattern - c = tc.Circuit(CONFIG["n_data_qubits"]) - for layer in range(CONFIG["n_layers"]): - offset = layer * 48 - for q in range(CONFIG["n_data_qubits"]): - c.ry(q, theta=params[offset + q]) - theta0 = params[offset + 24 : offset + 32] - theta1 = params[offset + 32 : offset + 40] - for q in range(CONFIG["n_data_qubits"]): - measured_float = K.cast(measured[layer, q], "float32") - source_float = K.cast(pre_ladder[layer, q], "float32") - feedback = theta0[q] + measured_float * ( - theta1[q] - theta0[q] - ) - angle = ( - (1.0 - 2.0 * source_float) * params[offset + 16 + q] - + (1.0 - 2.0 * measured_float) * feedback - ) - c.rz(q, theta=angle) - for q in range(CONFIG["n_data_qubits"] - 1): - c.cnot(q, q + 1) - for q in range(CONFIG["n_data_qubits"]): - c.rz(q, theta=params[offset + 40 + q]) - return tc.templates.measurements.operator_expectation(c, hamiltonian) - - return reduced_energy - - -def main() -> None: - parser = argparse.ArgumentParser() - parser.add_argument( - "--solution", - type=Path, - default=Path("/workspace/src/solutions/task-07/solution_7.py"), - ) - parser.add_argument("--output", type=Path) - args = parser.parse_args() - - solution = load_solution(args.solution) - params = solution.initial_parameters(CONFIG) - statuses = solution.trajectory_status(CONFIG) - - full_bits = ready( - K.jit(K.vmap(exact_full_bits, vectorized_argnums=1))(params, statuses) - ) - analytic = K.jit(K.vmap(analytic_bits, vectorized_argnums=1)) - analytic_measured, analytic_pre_ladder = ready(analytic(params, statuses)) - patterns = K.stack([analytic_measured, analytic_pre_ladder], axis=1) - - pattern_array = np.asarray(patterns, dtype=np.int32) - flat_patterns = pattern_array.reshape(CONFIG["n_trajectories"], -1) - unique_flat, inverse, counts = np.unique( - flat_patterns, axis=0, return_inverse=True, return_counts=True - ) - unique_patterns = K.convert_to_tensor( - unique_flat.reshape(-1, 2, CONFIG["n_layers"], 8) - ) - inverse_tensor = K.convert_to_tensor(inverse, dtype="int32") - counts_tensor = K.convert_to_tensor(counts, dtype="float32") - - full_one = solution.make_one_trajectory(CONFIG) - full_batch = K.jit(K.vmap(full_one, vectorized_argnums=1)) - reduced_one = make_reduced_energy() - reduced_batch = K.jit(K.vmap(reduced_one, vectorized_argnums=1)) - - def full_loss(p: Any) -> Any: - return K.mean(full_batch(p, statuses)) - - def reduced_loss(p: Any) -> Any: - values = reduced_batch(p, unique_patterns) - return K.sum(values * counts_tensor) / CONFIG["n_trajectories"] - - full_energy, full_grad = ready( - K.jit(K.value_and_grad(full_loss))(params) - ) - reduced_energy, reduced_grad = ready( - K.jit(K.value_and_grad(reduced_loss))(params) - ) - full_values = ready(full_batch(params, statuses)) - unique_values = ready(reduced_batch(params, unique_patterns)) - reduced_values = unique_values[inverse_tensor] - - ancilla_indices = np.array( - [*range(8, 16), *range(56, 64)], dtype=np.int32 - ) - non_ancilla_mask = np.ones(96, dtype=bool) - non_ancilla_mask[ancilla_indices] = False - full_grad_np = np.asarray(full_grad) - reduced_grad_np = np.asarray(reduced_grad) - - optimizer = optax.adam(CONFIG["learning_rate"]) - full_state = optimizer.init(params) - reduced_state = optimizer.init(params) - full_updates, full_state = optimizer.update(full_grad, full_state, params) - reduced_updates, reduced_state = optimizer.update( - reduced_grad, reduced_state, params - ) - full_post = optax.apply_updates(params, full_updates) - reduced_post = optax.apply_updates(params, reduced_updates) - full_post_energy = ready(K.jit(full_loss)(full_post)) - reduced_post_energy = ready(K.jit(reduced_loss)(reduced_post)) - - report = { - "schema_version": 1, - "task_id": "07", - "full_vs_analytic_bits_equal": bool( - np.array_equal(np.asarray(full_bits), np.asarray(analytic_measured)) - ), - "unique_pattern_count": int(len(unique_flat)), - "pattern_counts": [int(value) for value in counts], - "rare_trajectory_indices": [ - int(index) for index in np.where(inverse != inverse[0])[0] - ], - "initial_energy": { - "full": float(full_energy), - "reduced": float(reduced_energy), - "abs_error": abs(float(full_energy) - float(reduced_energy)), - }, - "trajectory_energy_max_abs_error": float( - np.max(np.abs(np.asarray(full_values) - np.asarray(reduced_values))) - ), - "gradient_max_abs_error": float( - np.max(np.abs(full_grad_np - reduced_grad_np)) - ), - "non_ancilla_gradient_max_abs_error": float( - np.max( - np.abs( - full_grad_np[non_ancilla_mask] - - reduced_grad_np[non_ancilla_mask] - ) - ) - ), - "full_ancilla_gradient_max_abs": float( - np.max(np.abs(full_grad_np[ancilla_indices])) - ), - "reduced_ancilla_gradient_max_abs": float( - np.max(np.abs(reduced_grad_np[ancilla_indices])) - ), - "post_update_parameter_max_abs_error": float( - np.max(np.abs(np.asarray(full_post) - np.asarray(reduced_post))) - ), - "post_update_energy": { - "full": float(full_post_energy), - "reduced": float(reduced_post_energy), - "abs_error": abs( - float(full_post_energy) - float(reduced_post_energy) - ), - }, - } - report["passed"] = bool( - report["full_vs_analytic_bits_equal"] - and report["unique_pattern_count"] == 2 - and report["initial_energy"]["abs_error"] <= 5e-5 - and report["non_ancilla_gradient_max_abs_error"] <= 5e-4 - and report["post_update_energy"]["abs_error"] <= 2e-3 - ) - rendered = json.dumps(report, indent=2, sort_keys=True) + "\n" - if args.output is not None: - args.output.write_text(rendered, encoding="utf-8") - print(rendered, end="") - if not report["passed"]: - raise SystemExit(1) - - -if __name__ == "__main__": - main() diff --git a/optimized_solutions/challenge-07/research/validate_e01_equivalence.py b/optimized_solutions/challenge-07/research/validate_e01_equivalence.py deleted file mode 100644 index 87567aa..0000000 --- a/optimized_solutions/challenge-07/research/validate_e01_equivalence.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python3 -"""Compare one Task 07 trajectory through value, gradient, and one Adam update.""" - -from __future__ import annotations - -import importlib.util -import json -import sys -import time -from pathlib import Path - -import numpy as np -import optax -import tensorcircuit as tc - - -ROOT = Path(__file__).resolve().parents[2] -CONFIG = { - "n_data_qubits": 8, - "n_ancilla_qubits": 8, - "n_qubits": 16, - "n_layers": 2, - "n_trajectories": 64, - "initial_parameter_scale": 0.1, - "max_steps": 100, - "learning_rate": 0.02, - "seed": 2047, - "transverse_field": 1.05, -} -TOLERANCES = { - "energy_abs": 5e-5, - "gradient_max_abs": 5e-4, - "adam_parameter_max_abs": 2e-5, -} - - -def load(path: Path, name: str): - spec = importlib.util.spec_from_file_location(name, path) - if spec is None or spec.loader is None: - raise RuntimeError(f"cannot load {path}") - module = importlib.util.module_from_spec(spec) - sys.modules[name] = module - spec.loader.exec_module(module) - return module - - -def evaluate(module, params, status): - one_trajectory = module.make_one_trajectory(CONFIG) - value_and_grad = tc.backend.jit( - tc.backend.value_and_grad(lambda p: one_trajectory(p, status)) - ) - started = time.perf_counter() - value, gradient = value_and_grad(params) - value_np = np.asarray(tc.backend.numpy(value)) - gradient_np = np.asarray(tc.backend.numpy(gradient)) - elapsed = time.perf_counter() - started - - optimizer = optax.adam(CONFIG["learning_rate"]) - state = optimizer.init(params) - updates, _ = optimizer.update(gradient, state, params) - next_params = optax.apply_updates(params, updates) - next_params_np = np.asarray(tc.backend.numpy(next_params)) - return value_np, gradient_np, next_params_np, elapsed - - -def main(): - reference = load( - ROOT / "references/task-07/solution_7.py", "task07_reference_equivalence" - ) - candidate = load( - ROOT / "src/solutions/task-07/solution_7.py", "task07_candidate_equivalence" - ) - params = reference.initial_parameters(CONFIG) - status = reference.trajectory_status(CONFIG)[0] - - rv, rg, rp, rt = evaluate(reference, params, status) - cv, cg, cp, ct = evaluate(candidate, params, status) - metrics = { - "reference_energy": float(rv), - "candidate_energy": float(cv), - "energy_abs_error": float(np.abs(rv - cv)), - "gradient_max_abs_error": float(np.max(np.abs(rg - cg))), - "gradient_mean_abs_error": float(np.mean(np.abs(rg - cg))), - "adam_parameter_max_abs_error": float(np.max(np.abs(rp - cp))), - "adam_parameter_mean_abs_error": float(np.mean(np.abs(rp - cp))), - "reference_elapsed_sec": rt, - "candidate_elapsed_sec": ct, - } - checks = { - "energy": metrics["energy_abs_error"] <= TOLERANCES["energy_abs"], - "gradient": metrics["gradient_max_abs_error"] - <= TOLERANCES["gradient_max_abs"], - "one_adam_update": metrics["adam_parameter_max_abs_error"] - <= TOLERANCES["adam_parameter_max_abs"], - } - print( - json.dumps( - { - "schema_version": 1, - "task_id": "07", - "experiment": "e01", - "trajectory_index": 0, - "tolerances": TOLERANCES, - "metrics": metrics, - "checks": checks, - "passed": all(checks.values()), - }, - indent=2, - ) - ) - if not all(checks.values()): - raise SystemExit(1) - - -if __name__ == "__main__": - main() diff --git a/optimized_solutions/challenge-07/research/validate_feedback_identity.py b/optimized_solutions/challenge-07/research/validate_feedback_identity.py deleted file mode 100644 index 3f277da..0000000 --- a/optimized_solutions/challenge-07/research/validate_feedback_identity.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -"""Validate the measured-ancilla RZZ to data-RZ identity for both branches.""" - -from __future__ import annotations - -import json - -import numpy as np -import tensorcircuit as tc - - -K = tc.set_backend("jax") -tc.set_dtype("complex64") -TOLERANCE = 1e-7 - - -def main(): - data = np.asarray([0.6 + 0.2j, -0.3 + 0.7j], dtype=np.complex64) - data /= np.linalg.norm(data) - cases = [] - for bit, theta in ((0, -0.37), (0, 1.23), (1, -0.37), (1, 1.23)): - ancilla = np.eye(2, dtype=np.complex64)[bit] - input_state = np.kron(ancilla, data) - rzz = np.asarray(K.numpy(tc.gates.rzz(theta=theta).tensor)).reshape(4, 4) - rz = np.asarray( - K.numpy(tc.gates.rz(theta=(1 - 2 * bit) * theta).tensor) - ).reshape(2, 2) - lhs = rzz @ input_state - rhs = np.kron(ancilla, rz @ data) - error = float(np.max(np.abs(lhs - rhs))) - cases.append({"bit": bit, "theta": theta, "max_abs_error": error}) - - maximum = max(case["max_abs_error"] for case in cases) - report = { - "schema_version": 1, - "task_id": "07", - "experiment": "e02", - "identity": "RZZ(theta_b)|b,psi> = |b> RZ((1-2b)theta_b)|psi>", - "dtype": "complex64", - "tolerance": TOLERANCE, - "cases": cases, - "max_abs_error": maximum, - "passed": maximum <= TOLERANCE, - } - print(json.dumps(report, indent=2)) - if not report["passed"]: - raise SystemExit(1) - - -if __name__ == "__main__": - main() diff --git a/optimized_solutions/challenge-07/solution_7_conservative.py b/optimized_solutions/challenge-07/solution_7_conservative.py deleted file mode 100644 index c6c5db7..0000000 --- a/optimized_solutions/challenge-07/solution_7_conservative.py +++ /dev/null @@ -1,151 +0,0 @@ -""" -Task Suite Problem 7: 16-qubit measurement-feedback VQE. - -The TensorCircuit-NG baseline uses cond_measure for ancilla measurements and -batches fixed trajectories with vmap for deterministic trajectory-averaged -energy optimization. -""" - -import numpy as np -import optax - -import tensorcircuit as tc - -K = tc.set_backend("jax") -tc.set_dtype("complex64") -tc.set_contractor("omeco-1-1") - -PARAMS_PER_LAYER = 48 - - -def initial_parameters(config): - rng = np.random.default_rng(config["seed"]) - return K.convert_to_tensor( - rng.normal( - scale=config["initial_parameter_scale"], - size=(config["n_layers"] * PARAMS_PER_LAYER,), - ).astype(np.float32) - ) - - -def trajectory_status(config): - rng = np.random.default_rng(config["seed"] + 1) - return K.convert_to_tensor( - rng.random( - (config["n_trajectories"], config["n_layers"] * config["n_ancilla_qubits"]), - dtype=np.float32, - ) - ) - - -def make_one_trajectory(config): - n_data = config["n_data_qubits"] - n_anc = config["n_ancilla_qubits"] - n_qubits = config["n_qubits"] - n_layers = config["n_layers"] - transverse_field = config["transverse_field"] - - pauli_strings = [] - weights = [] - for i in range(n_data - 1): - term = [0] * n_data - term[i] = 3 - term[i + 1] = 3 - pauli_strings.append(term) - weights.append(-1.0) - for i in range(n_data): - term = [0] * n_data - term[i] = 1 - pauli_strings.append(term) - weights.append(-transverse_field) - hamiltonian = tc.quantum.PauliStringSum2COO(pauli_strings, weights) - - def energy_of_data(c): - # The final Z-measured ancillas remain computational-basis states - # under diagonal RZZ feedback, so exactly one ancilla column is - # nonzero. Contract the adaptive circuit once, recover the data state, - # and evaluate all TFIM terms with one TensorCircuit-native operator. - full_state = K.reshape(c.state(), [2**n_data, 2**n_anc]) - data_state = K.sum(full_state, axis=1) - data_circuit = tc.Circuit(n_data, inputs=data_state) - return tc.templates.measurements.operator_expectation( - data_circuit, hamiltonian - ) - - def one_trajectory(params, status): - c = tc.Circuit(n_qubits) - pidx = 0 - sidx = 0 - - for _ in range(n_layers): - for q in range(n_data): - c.ry(q, theta=params[pidx + q]) - pidx += n_data - - for a in range(n_anc): - c.ry(n_data + a, theta=params[pidx + a]) - pidx += n_anc - - for a in range(n_anc): - c.rzz(n_data + a, a, theta=params[pidx + a]) - pidx += n_anc - - for a in range(n_anc - 1): - c.cnot(n_data + a, n_data + a + 1) - - theta0 = params[pidx : pidx + n_anc] - pidx += n_anc - theta1 = params[pidx : pidx + n_anc] - pidx += n_anc - - for a in range(n_anc): - anc = n_data + a - bit = c.cond_measure(anc, status=status[sidx]) - bitf = K.cast(bit, "float32") - feedback_theta = theta0[a] + bitf * (theta1[a] - theta0[a]) - c.rz( - a, - theta=(1.0 - 2.0 * bitf) * feedback_theta, - ) - sidx += 1 - - for q in range(n_data - 1): - c.cnot(q, q + 1) - - for q in range(n_data): - c.rz(q, theta=params[pidx + q]) - pidx += n_data - - return energy_of_data(c) - - return one_trajectory - - -def run_solution(config): - params = initial_parameters(config) - status = trajectory_status(config) - one_trajectory = make_one_trajectory(config) - batched_trajectories = K.jit(K.vmap(one_trajectory, vectorized_argnums=1)) - optimizer = optax.adam(config["learning_rate"]) - - def loss_fn(p): - return K.mean(batched_trajectories(p, status)) - - def train_step(p, state): - value, grads = K.value_and_grad(loss_fn)(p) - updates, state = optimizer.update(grads, state, p) - p = optax.apply_updates(p, updates) - return p, state, value - - train_step = K.jit(train_step) - opt_state = optimizer.init(params) - energy_history = [] - for _ in range(config["max_steps"]): - params, opt_state, value = train_step(params, opt_state) - energy_history.append(value) - - final_trajectory_energies = batched_trajectories(params, status) - return { - "energy_history": K.numpy(K.stack(energy_history)), - "final_trajectory_energies": K.numpy(final_trajectory_energies), - } From bdb4441b8bea495e336168756f55709bfb001823 Mon Sep 17 00:00:00 2001 From: qingyunqian Date: Thu, 30 Jul 2026 13:34:05 +0800 Subject: [PATCH 5/5] Clarify Task 07 factor attribution --- optimized_solutions/challenge-07/README.md | 7 +- .../challenge-07/factor-ablation.svg | 555 +++++++++++++----- 2 files changed, 423 insertions(+), 139 deletions(-) diff --git a/optimized_solutions/challenge-07/README.md b/optimized_solutions/challenge-07/README.md index f32eec3..86660c3 100644 --- a/optimized_solutions/challenge-07/README.md +++ b/optimized_solutions/challenge-07/README.md @@ -15,7 +15,12 @@ | Default local contractor over greedy | 1.044x | Keep default — minor | | Default local contractor over OMECo 1x1 | 1.040x, CI crosses 1x | Do not switch | -![Task 07 expert and reduced runtimes](factor-ablation.svg) +![Task 07 exact-reduction and post-reduction factor comparisons](factor-ablation.svg) + +*Figure — Panel a shows the complete effect of removing the exact +classical-ancilla/trajectory reduction. Panels b–c test scan and dense local +fusion only after the graph is already reduced; both regress. The secondary +contractor results remain in the table.* ## What the factors mean diff --git a/optimized_solutions/challenge-07/factor-ablation.svg b/optimized_solutions/challenge-07/factor-ablation.svg index 5bf64e1..7670022 100644 --- a/optimized_solutions/challenge-07/factor-ablation.svg +++ b/optimized_solutions/challenge-07/factor-ablation.svg @@ -1,12 +1,11 @@ - + - 2026-07-30T11:46:21.127397 image/svg+xml @@ -21,259 +20,539 @@ - - - - - - +" style="stroke: #222222; stroke-width: 0.8"/> - + - - - - 1 - 0 - 1 - - + Reduced + 3.07 s - - - - + - + - - - - 1 - 0 - 2 - - + Public expert + 140.08 s - - + + + + + + + - + - + + + 1 + - + + + + - + + + 3 + - + + + + - + + + 10 + - - + + + + + - + + + 30 + - - + + Runtime normalized to recommended + + + + + + + + + + + + + + + + 6 matched pairs; paired mean + + + a + + + 1.000× + + + 45.758× + + + Exact controller reduction → full 16q × 64 + + + + + + + + + + + + - + + + Recommended + - - + + - + + + Rejected scan + - - + + + + + + + - + + + 0.0 + - - + + + + + - + + + 0.2 + - - + + + + + - + + + 0.4 + - - + + + + + - + + + 0.6 + - - + + + + + - + + + 0.8 + - - + + + + + - + + + 1.0 + - - + + + + + + + + + + + + + + + post-reduction screen + + + b + + + 1.000× + + + 1.070× + + + Python loop → training scan + + + + + + + + + + + + - + + + Recommended + - - + + - + + + Rejected fusion + - - + + + + + + + - + + + 0.0 + - - Mean evaluator runtime (s, log scale) + + + + + + + + + + + 0.2 + - - - - - - - + + + + + - + - - Immutable expert - 64 × 16-qubit + + 0.4 - - + + + + + - + - - Exact reduction - 2 × 8-qubit + + 0.6 + + + + + + + + + + + + + 0.8 + + + + + + + + + + + + + 1.0 + + + + + + + + + + + + + 1.2 - - + + + + + + + +" clip-path="url(#p1918f6d2fb)" style="fill: #4472c4; stroke: #333333; stroke-width: 0.55; stroke-linejoin: miter"/> - - + +" clip-path="url(#p1918f6d2fb)" style="fill: #c44e52; stroke: #333333; stroke-width: 0.55; stroke-linejoin: miter"/> - - + + post-reduction screen - - + + c - - 140.076 s + + 1.000× - - 3.071 s + + 1.178× - - 45.758× mean paired speedup - 6 matched pairs; all runs passed + + Native gates → dense local fusion - - Exact classical-ancilla reduction removes the dominant work + + + + Task 07 factor ablations — exact classical reduction removes nearly all work + + + Panel a is the exact challenge-design reduction. Panels b–c test secondary changes after the graph is already reduced. + - - + + + + + + + +