Skip to content

Commit ccaeea4

Browse files
update problem 7
1 parent d62a28c commit ccaeea4

4 files changed

Lines changed: 39 additions & 15 deletions

File tree

examples/challenge_suite/evaluate_7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"n_ancilla_qubits": 8,
1414
"n_qubits": 16,
1515
"n_layers": 2,
16-
"n_trajectories": 128,
16+
"n_trajectories": 64,
1717
"initial_parameter_scale": 0.1,
1818
"max_steps": 100,
1919
"learning_rate": 0.02,

examples/challenge_suite/problem_7.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The evaluator defines and passes the following configuration dictionary into `ru
2121
"n_ancilla_qubits": 8,
2222
"n_qubits": 16,
2323
"n_layers": 2,
24-
"n_trajectories": 128,
24+
"n_trajectories": 64,
2525
"initial_parameter_scale": 0.1,
2626
"max_steps": 100,
2727
"learning_rate": 0.02,
@@ -68,6 +68,14 @@ For each pair `(data_i, ancilla_i)`, apply a trainable two-qubit entangler
6868
RZZ(theta_ent[layer, i]) on qubits (8 + i, i).
6969
```
7070

71+
Then apply a fixed nearest-neighbor ancilla ladder of CNOT gates
72+
73+
```text
74+
CNOT(8, 9), CNOT(9, 10), ..., CNOT(14, 15).
75+
```
76+
77+
This ancilla ladder is part of every layer and is not trainable.
78+
7179
### 4. Mid-Circuit Ancilla Measurement
7280

7381
Measure each ancilla qubit `8 + i` in the computational basis, obtaining trajectory bit
@@ -76,7 +84,7 @@ Measure each ancilla qubit `8 + i` in the computational basis, obtaining traject
7684
m[layer, i] in {0, 1}.
7785
```
7886

79-
Use exactly `n_trajectories = 128` trajectories per objective evaluation, and keep the per-trajectory measurement randomness fixed across optimizer updates so the objective is a reproducible trajectory average rather than an optimizer-side resampling procedure.
87+
Use exactly `n_trajectories = 64` trajectories per objective evaluation, and keep the per-trajectory measurement randomness fixed across optimizer updates so the objective is a reproducible trajectory average rather than an optimizer-side resampling procedure.
8088

8189
### 5. Conditional Feedback Layer
8290

@@ -89,6 +97,16 @@ These two feedback angles are independent trainable parameters.
8997

9098
### 6. Data Post-Processing Layer
9199

100+
After all conditional feedback gates in the layer, apply a fixed nearest-neighbor data ladder of CNOT gates
101+
102+
```text
103+
CNOT(0, 1), CNOT(1, 2), ..., CNOT(6, 7).
104+
```
105+
106+
This data ladder is part of every layer and is not trainable.
107+
108+
### 7. Data Post-Processing Layer
109+
92110
Apply trainable `RZ` rotations on all data qubits:
93111

94112
```text
@@ -97,7 +115,7 @@ RZ(theta_post[layer, i]) on data qubit i, i = 0,...,7.
97115

98116
## Objective Function
99117

100-
For a fixed parameter vector and a fixed batch of `128` trajectory uniforms, the protocol produces `128` measurement-conditioned trajectories. Let `E_t` be the data-Hamiltonian expectation value on trajectory `t`. The objective is the trajectory-averaged energy
118+
For a fixed parameter vector and a fixed batch of `64` trajectory uniforms, the protocol produces `64` measurement-conditioned trajectories. Let `E_t` be the data-Hamiltonian expectation value on trajectory `t`. The objective is the trajectory-averaged energy
101119

102120
$$
103121
E_{\mathrm{avg}} = \frac{1}{128} \sum_{t=1}^{128} E_t.
@@ -126,7 +144,7 @@ Required result keys:
126144

127145
`energy_history[t]` records the trajectory-averaged energy evaluated immediately before optimizer update `t`.
128146

129-
`final_trajectory_energies[k]` records the final per-trajectory data-Hamiltonian energy for the same fixed batch of `128` trajectory uniforms used by the objective.
147+
`final_trajectory_energies[k]` records the final per-trajectory data-Hamiltonian energy for the same fixed batch of `64` trajectory uniforms used by the objective.
130148

131149
## Evaluation Interface
132150

@@ -154,7 +172,7 @@ It does not save files or create plots by default.
154172
A run is considered functionally successful when all of the following hold for the default configuration:
155173

156174
- `len(energy_history) == 100`
157-
- `final_trajectory_energies.shape == (128,)`
175+
- `final_trajectory_energies.shape == (64,)`
158176
- the final trajectory-averaged energy is lower than the initial trajectory-averaged energy
159177
- the total energy improvement is at least `minimum_improvement = 0.3`
160178
- the final trajectory-averaged energy is at most `target_final_energy = -8.3`
@@ -172,16 +190,16 @@ python evaluate_7.py --solution solution_7
172190

173191
Observed TensorCircuit-NG/JAX baseline in the current validation environment with the default 100-step configuration:
174192

175-
- End-to-end solution time: `46.62s`.
176-
- Initial trajectory-averaged energy: `-6.9331135750`.
177-
- Final trajectory-averaged energy: `-9.6408786774`.
178-
- Energy improvement: `2.7077651024`.
179-
- Final trajectory energy mean/std: `-9.6408815384 / 0.0000018564`.
193+
- End-to-end solution time: `63.84s`.
194+
- Initial trajectory-averaged energy: `-6.8462667465`.
195+
- Final trajectory-averaged energy: `-10.0266914368`.
196+
- Energy improvement: `3.1804246902`.
197+
- Final trajectory energy mean/std: `-10.0323581696 / 0.0036470860`.
180198
- Energy history length: `100`.
181199
- Overall: `PASS`.
182200

183201
This time is a reference measurement only and is not a passing criterion.
184202

185203
## Implementation Hint
186204

187-
For a TensorCircuit-NG/JAX baseline, use `cond_measure` for ancilla measurements, batch the `128` fixed trajectories with `vmap`, and JIT-compile the full optimizer step rather than only `value_and_grad`, so each update reuses one compiled trajectory-averaged objective-and-update path.
205+
For a TensorCircuit-NG/JAX baseline, use `cond_measure` for ancilla measurements, batch the fixed trajectories with `vmap`, and JIT-compile the full optimizer step rather than only `value_and_grad`, so each update reuses one compiled trajectory-averaged objective-and-update path.

examples/challenge_suite/runtime_summary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Challenge Suite Runtime Summary
22

3-
Evaluator-reported `End-to-end solution time` for the current 12 problems.
3+
Evaluator-reported `End-to-end solution time` for the current 12 problems on MacBook Pro with Apple M4 Pro CPU.
44

55
| Problem | Runtime |
66
| --- | ---: |
@@ -10,7 +10,7 @@ Evaluator-reported `End-to-end solution time` for the current 12 problems.
1010
| 4 | 47.45s |
1111
| 5 | 45.50s |
1212
| 6 | 26.83s |
13-
| 7 | 46.62s |
13+
| 7 | 63.84s |
1414
| 8 | 119.10s |
1515
| 9 | 13.74s |
1616
| 10 | 66.30s |

examples/challenge_suite/solution_7.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Challenge Suite Problem 7: 16-qubit measurement-feedback VQE.
33
44
The TensorCircuit-NG baseline uses cond_measure for ancilla measurements and
5-
batches 128 fixed trajectories with vmap for deterministic trajectory-averaged
5+
batches fixed trajectories with vmap for deterministic trajectory-averaged
66
energy optimization.
77
"""
88

@@ -71,6 +71,9 @@ def one_trajectory(params, status):
7171
c.rzz(n_data + a, a, theta=params[pidx + a])
7272
pidx += n_anc
7373

74+
for a in range(n_anc - 1):
75+
c.cnot(n_data + a, n_data + a + 1)
76+
7477
theta0 = params[pidx : pidx + n_anc]
7578
pidx += n_anc
7679
theta1 = params[pidx : pidx + n_anc]
@@ -87,6 +90,9 @@ def one_trajectory(params, status):
8790
)
8891
sidx += 1
8992

93+
for q in range(n_data - 1):
94+
c.cnot(q, q + 1)
95+
9096
for q in range(n_data):
9197
c.rz(q, theta=params[pidx + q])
9298
pidx += n_data

0 commit comments

Comments
 (0)