API Reference¶
QuartumSE - Quantum Measurement Optimization & Observability Platform
A vendor-neutral framework for running quantum experiments with: - Classical shadows for shot-efficient observable estimation - Rigorous error mitigation and confidence intervals - Full provenance tracking and reproducibility - Cross-platform backend support (IBM, AWS, and more) - Publication-grade benchmarking per Measurements Bible
License: Apache 2.0
BenchmarkMode
¶
Bases: Enum
Benchmark execution modes.
Source code in src/quartumse/benchmark_suite.py
23 24 25 26 27 28 | |
BenchmarkSuiteConfig
dataclass
¶
Configuration for benchmark suite execution.
Attributes:
| Name | Type | Description |
|---|---|---|
mode |
BenchmarkMode
|
Execution mode (basic, complete, analysis) |
n_shots_grid |
list[int]
|
Shot budgets to evaluate |
n_replicates |
int
|
Number of replicates per configuration |
seed |
int
|
Base random seed |
epsilon |
float
|
Target precision for tasks |
delta |
float
|
Failure probability |
compute_truth |
bool
|
Whether to compute ground truth |
shadows_protocol_id |
str
|
Protocol ID for shadows (for comparison) |
baseline_protocol_id |
str
|
Protocol ID for baseline (for comparison) |
output_base_dir |
str
|
Base directory for outputs (timestamped subdir created) |
noise_profile |
str | None
|
Noise profile ID (e.g., "readout_1e-2", "depol_medium"). If None or "ideal", runs noiseless simulation. |
Source code in src/quartumse/benchmark_suite.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
BenchmarkSuiteResult
dataclass
¶
Complete result from benchmark suite execution.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Unique run identifier |
timestamp |
datetime
|
Execution timestamp |
mode |
BenchmarkMode
|
Benchmark mode used |
output_dir |
Path
|
Directory containing all outputs |
ground_truth |
Any | None
|
Ground truth result (if computed) |
long_form_results |
list
|
List of LongFormRow |
task_results |
dict[str, Any]
|
Dict of task outputs (basic tasks) |
all_task_results |
dict[str, Any] | None
|
Dict of all 8 task outputs (complete mode) |
analysis |
Any | None
|
ComprehensiveBenchmarkAnalysis (analysis mode) |
reports |
dict[str, Path]
|
Dict of report paths |
summary |
dict[str, Any]
|
Summary statistics |
Source code in src/quartumse/benchmark_suite.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
ClassicalShadows
¶
Bases: ABC
Abstract base class for classical shadows implementations.
Different versions (v0-v4) subclass this to provide specific algorithms.
Source code in src/quartumse/shadows/core.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
compute_confidence_interval(mean, variance, n_samples, confidence=0.95)
¶
Compute confidence interval using normal approximation.
Source code in src/quartumse/shadows/core.py
150 151 152 153 154 155 156 157 158 159 160 161 162 | |
compute_variance_bound(observable, shadow_size)
¶
Theoretical variance bound for the shadow estimator.
Useful for shot allocation and adaptive strategies.
Source code in src/quartumse/shadows/core.py
139 140 141 142 143 144 145 146 147 148 | |
estimate_multiple_observables(observables)
¶
Estimate multiple observables from the same shadow data.
This is the key advantage: one shadow dataset, many observables.
Source code in src/quartumse/shadows/core.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
estimate_observable(observable, shadow_data=None)
abstractmethod
¶
Estimate expectation value of an observable using shadow data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable
|
Observable
|
The observable to estimate |
required |
shadow_data
|
ndarray | None
|
Pre-computed shadow snapshots (or use self.shadow_data) |
None
|
Returns:
| Type | Description |
|---|---|
ShadowEstimate
|
Estimate with confidence interval |
Source code in src/quartumse/shadows/core.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
estimate_shadow_size_needed(observable, target_precision)
abstractmethod
¶
Estimate the number of shadows required for a desired precision.
Source code in src/quartumse/shadows/core.py
115 116 117 118 119 | |
generate_measurement_circuits(base_circuit, num_shadows)
abstractmethod
¶
Generate randomized measurement circuits for shadows protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_circuit
|
QuantumCircuit
|
The state preparation circuit |
required |
num_shadows
|
int
|
Number of random measurements |
required |
Returns:
| Type | Description |
|---|---|
list[QuantumCircuit]
|
List of circuits with randomized measurements appended |
Source code in src/quartumse/shadows/core.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
reconstruct_classical_shadow(measurement_outcomes, measurement_bases)
abstractmethod
¶
Reconstruct classical shadow snapshots from measurement data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
measurement_outcomes
|
ndarray
|
Binary outcomes (0/1) for each measurement |
required |
measurement_bases
|
ndarray
|
Which basis was measured for each qubit |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shadow snapshots (density matrix representations) |
Source code in src/quartumse/shadows/core.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
ComprehensiveBenchmarkAnalysis
dataclass
¶
Complete benchmark analysis with all improvements.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Benchmark run identifier |
protocols |
list[str]
|
List of protocol IDs analyzed |
n_observables |
int
|
Number of observables |
n_shots_grid |
list[int]
|
Shot budgets evaluated |
task_analyses |
dict[str, TaskAnalysis]
|
Per-task analysis results |
crossover_analysis |
CrossoverAnalysis | None
|
Per-observable crossover analysis |
locality_analysis |
dict[str, Any]
|
Performance by observable locality |
statistical_comparison |
dict[int, StatisticalComparison]
|
Statistical significance tests |
cost_analysis |
dict[str, Any]
|
Cost-normalized comparisons |
pilot_analysis |
MultiPilotAnalysis | None
|
Multi-pilot fraction analysis |
interpolated_n_star |
dict[str, dict[str, Any]]
|
N* estimates via power-law interpolation |
summary |
dict[str, Any]
|
Executive summary |
Source code in src/quartumse/analysis/comprehensive.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
generate_report()
¶
Generate markdown report.
Source code in src/quartumse/analysis/comprehensive.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
save(path)
¶
Save analysis to JSON file.
Source code in src/quartumse/analysis/comprehensive.py
122 123 124 125 126 | |
CostModel
dataclass
¶
Model for computing effective cost of measurements.
Cost factors: - shots: Base cost (number of circuit executions) - depth_penalty: Multiplier per unit circuit depth - gate_penalty: Multiplier per 2-qubit gate - noise_factor: Additional noise-based multiplier
Effective cost = shots * (1 + depth_penalty * depth) * (1 + gate_penalty * gates) * noise_factor
Source code in src/quartumse/analysis/cost_normalized.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
compute_cost(n_shots, circuit_depth=0, twoq_gates=0, classical_time_s=0.0)
¶
Compute effective cost for a measurement configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_shots
|
int
|
Number of shots |
required |
circuit_depth
|
int
|
Circuit depth |
0
|
twoq_gates
|
int
|
Number of 2-qubit gates |
0
|
classical_time_s
|
float
|
Classical processing time in seconds |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Effective cost value |
Source code in src/quartumse/analysis/cost_normalized.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
DirectGroupedProtocol
¶
Bases: StaticProtocol
Direct measurement with commuting grouping (§4.1B).
Observables are partitioned into qubit-wise commuting groups. Each group is measured in a shared basis.
This is the REQUIRED baseline for defensible benchmarks.
Attributes:
| Name | Type | Description |
|---|---|---|
protocol_id |
str
|
"direct_grouped" |
protocol_version |
str
|
"1.0.0" |
grouping_method |
str
|
Method for partitioning ("greedy" or "sorted_insertion") |
Source code in src/quartumse/protocols/baselines/direct_grouped.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
__init__(grouping_method='greedy')
¶
Initialize protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grouping_method
|
str
|
"greedy" or "sorted_insertion" |
'greedy'
|
Source code in src/quartumse/protocols/baselines/direct_grouped.py
73 74 75 76 77 78 79 80 | |
finalize(state, observable_set)
¶
Compute final estimates from collected data.
For grouped measurements, each observable's estimate is computed from the same bitstrings as other observables in its group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Final protocol state. |
required |
observable_set
|
ObservableSet
|
Set of observables (for reference). |
required |
Returns:
| Type | Description |
|---|---|
Estimates
|
Estimates for all observables. |
Source code in src/quartumse/protocols/baselines/direct_grouped.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
initialize(observable_set, total_budget, seed)
¶
Initialize protocol state with commuting groups.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable_set
|
ObservableSet
|
Set of observables to estimate. |
required |
total_budget
|
int
|
Total number of shots available. |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
Returns:
| Type | Description |
|---|---|
DirectGroupedState
|
Initialized DirectGroupedState. |
Source code in src/quartumse/protocols/baselines/direct_grouped.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
plan(state)
¶
Generate measurement plan with one setting per group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
Returns:
| Type | Description |
|---|---|
MeasurementPlan
|
MeasurementPlan with G settings, one per commuting group. |
Source code in src/quartumse/protocols/baselines/direct_grouped.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
update(state, data_chunk)
¶
Update state with new measurement data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
data_chunk
|
RawDatasetChunk
|
New measurement data. |
required |
Returns:
| Type | Description |
|---|---|
ProtocolState
|
Updated protocol state. |
Source code in src/quartumse/protocols/baselines/direct_grouped.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
DirectNaiveProtocol
¶
Bases: StaticProtocol
Direct measurement without grouping (§4.1A).
Each observable is measured independently in its native basis. This is the simplest possible approach and serves as a baseline.
Attributes:
| Name | Type | Description |
|---|---|---|
protocol_id |
str
|
"direct_naive" |
protocol_version |
str
|
"1.0.0" |
Source code in src/quartumse/protocols/baselines/direct_naive.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
finalize(state, observable_set)
¶
Compute final estimates from collected data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Final protocol state. |
required |
observable_set
|
ObservableSet
|
Set of observables (for reference). |
required |
Returns:
| Type | Description |
|---|---|
Estimates
|
Estimates for all observables. |
Source code in src/quartumse/protocols/baselines/direct_naive.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
initialize(observable_set, total_budget, seed)
¶
Initialize protocol state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable_set
|
ObservableSet
|
Set of observables to estimate. |
required |
total_budget
|
int
|
Total number of shots available. |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
Returns:
| Type | Description |
|---|---|
DirectNaiveState
|
Initialized DirectNaiveState. |
Source code in src/quartumse/protocols/baselines/direct_naive.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
plan(state)
¶
Generate measurement plan for all observables.
Each observable gets its own measurement setting in its native basis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
Returns:
| Type | Description |
|---|---|
MeasurementPlan
|
MeasurementPlan with M settings, one per observable. |
Source code in src/quartumse/protocols/baselines/direct_naive.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
update(state, data_chunk)
¶
Update state with new measurement data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
data_chunk
|
RawDatasetChunk
|
New measurement data. |
required |
Returns:
| Type | Description |
|---|---|
ProtocolState
|
Updated protocol state. |
Source code in src/quartumse/protocols/baselines/direct_naive.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
DirectOptimizedProtocol
¶
Bases: StaticProtocol
Direct measurement with optimal shot allocation (§4.1C).
This protocol: 1. Groups observables into qubit-wise commuting families 2. Allocates shots optimally based on group importance/size 3. Uses a simple heuristic: more shots to larger groups
The optimal allocation aims to minimize the worst-case SE across all observables, subject to the total shot budget constraint.
Attributes:
| Name | Type | Description |
|---|---|---|
protocol_id |
str
|
"direct_optimized" |
protocol_version |
str
|
"1.0.0" |
allocation_strategy |
str
|
Strategy for shot allocation |
Source code in src/quartumse/protocols/baselines/direct_optimized.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
__init__(allocation_strategy='proportional')
¶
Initialize protocol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allocation_strategy
|
str
|
Strategy for allocating shots to groups. - "proportional": Proportional to sqrt(group_size) - "equal_se": Aim for equal SE across observables - "max_min": Maximize minimum shots per observable |
'proportional'
|
Source code in src/quartumse/protocols/baselines/direct_optimized.py
77 78 79 80 81 82 83 84 85 86 87 | |
finalize(state, observable_set)
¶
Compute final estimates from collected data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Final protocol state. |
required |
observable_set
|
ObservableSet
|
Set of observables (for reference). |
required |
Returns:
| Type | Description |
|---|---|
Estimates
|
Estimates for all observables. |
Source code in src/quartumse/protocols/baselines/direct_optimized.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
initialize(observable_set, total_budget, seed)
¶
Initialize protocol state with optimal allocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable_set
|
ObservableSet
|
Set of observables to estimate. |
required |
total_budget
|
int
|
Total number of shots available. |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
Returns:
| Type | Description |
|---|---|
DirectOptimizedState
|
Initialized DirectOptimizedState. |
Source code in src/quartumse/protocols/baselines/direct_optimized.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
plan(state)
¶
Generate measurement plan with optimal allocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
Returns:
| Type | Description |
|---|---|
MeasurementPlan
|
MeasurementPlan with G settings and optimal shot distribution. |
Source code in src/quartumse/protocols/baselines/direct_optimized.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
update(state, data_chunk)
¶
Update state with new measurement data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
data_chunk
|
RawDatasetChunk
|
New measurement data. |
required |
Returns:
| Type | Description |
|---|---|
ProtocolState
|
Updated protocol state. |
Source code in src/quartumse/protocols/baselines/direct_optimized.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
Estimates
dataclass
¶
Complete estimation results for all observables (§5.3).
Supports both list-based and dict-based storage of estimates.
Attributes:
| Name | Type | Description |
|---|---|---|
estimates |
list[ObservableEstimate]
|
List of ObservableEstimate objects. |
observable_estimates |
dict[str, ObservableEstimate]
|
Dict mapping observable_id to ObservableEstimate (computed). |
total_shots |
int
|
Total shots used for estimation. |
n_settings |
int
|
Number of distinct measurement settings used. |
time_quantum_s |
float | None
|
Quantum execution time in seconds. |
time_classical_s |
float | None
|
Classical processing time in seconds. |
protocol_id |
str | None
|
ID of the protocol that produced these estimates. |
protocol_version |
str | None
|
Version of the protocol. |
ci_method_id |
str | None
|
CI method used (if uniform across observables). |
metadata |
dict[str, Any]
|
Additional metadata. |
Source code in src/quartumse/protocols/state.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
n_observables
property
¶
Number of observables estimated.
observable_estimates
property
¶
Dict view mapping observable_id to ObservableEstimate.
all_within_target(epsilon, use_ci=True)
¶
Check if all observables meet precision target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epsilon
|
float
|
Target precision (SE or CI half-width). |
required |
use_ci
|
bool
|
If True, check CI half-width; otherwise check SE. |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if all observables meet the target. |
Source code in src/quartumse/protocols/state.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
get_estimate(observable_id)
¶
Get estimate for a specific observable.
Source code in src/quartumse/protocols/state.py
386 387 388 389 390 391 | |
max_ci_half_width()
¶
Maximum CI half-width across all observables.
Source code in src/quartumse/protocols/state.py
404 405 406 407 408 409 | |
max_se()
¶
Maximum standard error across all observables.
Source code in src/quartumse/protocols/state.py
393 394 395 396 397 | |
mean_se()
¶
Mean standard error across all observables.
Source code in src/quartumse/protocols/state.py
399 400 401 402 | |
to_dict()
¶
Convert to dictionary for serialization.
Source code in src/quartumse/protocols/state.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
Estimator
¶
Bases: ABC
Abstract base class for quantum observable estimators.
Provides unified interface for different estimation strategies: - Classical shadows (various versions) - Direct measurement - Grouped Pauli measurement
Source code in src/quartumse/estimator/base.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
estimate(circuit, observables, target_precision=None)
abstractmethod
¶
Estimate expectation values of observables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit
|
QuantumCircuit
|
State preparation circuit |
required |
observables
|
list[Observable]
|
List of observables to estimate |
required |
target_precision
|
float | None
|
Desired precision (optional) |
None
|
Returns:
| Type | Description |
|---|---|
EstimationResult
|
Estimation results with confidence intervals |
Source code in src/quartumse/estimator/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
estimate_shots_needed(observables, target_precision)
abstractmethod
¶
Estimate number of shots needed for target precision.
Used for cost estimation and shot allocation.
Source code in src/quartumse/estimator/base.py
68 69 70 71 72 73 74 75 | |
FWERMethod
¶
Bases: str, Enum
Method for controlling family-wise error rate.
Source code in src/quartumse/stats/fwer.py
28 29 30 31 32 33 34 | |
LongFormRow
¶
Bases: BaseModel
A single row in the long-form results table (§10.1).
This schema defines all required columns for the tidy long-form output. Each row corresponds to one observable estimate from one protocol run.
Source code in src/quartumse/io/schemas.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
Config
¶
Pydantic configuration.
Source code in src/quartumse/io/schemas.py
141 142 143 144 | |
compute_derived_metrics()
¶
Compute derived metrics from truth if available.
Source code in src/quartumse/io/schemas.py
135 136 137 138 139 | |
NoiseProfile
dataclass
¶
A noise profile specification.
Attributes:
| Name | Type | Description |
|---|---|---|
profile_id |
str
|
Unique identifier for this profile. |
noise_type |
NoiseType
|
Type of noise model. |
parameters |
dict[str, float]
|
Noise model parameters. |
description |
str
|
Human-readable description. |
metadata |
dict[str, Any]
|
Additional metadata. |
Source code in src/quartumse/noise/profiles.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
from_dict(data)
classmethod
¶
Create from dictionary.
Source code in src/quartumse/noise/profiles.py
63 64 65 66 67 68 69 70 71 72 | |
to_dict()
¶
Convert to dictionary for serialization.
Source code in src/quartumse/noise/profiles.py
53 54 55 56 57 58 59 60 61 | |
ObjectiveAnalysis
dataclass
¶
Complete objective-level analysis for a weighted suite.
Source code in src/quartumse/analysis/objective_metrics.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
ObjectiveEstimate
dataclass
¶
Result of estimating a weighted objective.
Source code in src/quartumse/analysis/objective_metrics.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
ObjectiveType
¶
Bases: Enum
Type of objective function for the suite.
Source code in src/quartumse/observables/suites.py
30 31 32 33 34 35 36 | |
Observable
dataclass
¶
A quantum observable with full metadata (§3.2).
An observable represents a Hermitian operator whose expectation value we want to estimate. The primary representation is a Pauli string (e.g., "XYZII") with an optional coefficient.
Attributes:
| Name | Type | Description |
|---|---|---|
pauli_string |
str
|
Pauli string representation (e.g., "XYZII"). |
coefficient |
float
|
Multiplicative coefficient (default 1.0). |
observable_id |
str | None
|
Unique identifier. Auto-generated if not provided. |
group_id |
str | None
|
Group identifier for commuting families (None if ungrouped). |
metadata |
dict[str, Any]
|
Additional observable-specific metadata. |
Source code in src/quartumse/observables/core.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
basis_indices
property
¶
Measurement basis indices for non-identity terms (X->1, Y->2, Z->0).
locality
property
¶
Pauli weight (number of non-identity factors). Cached for performance.
n_qubits
property
¶
Number of qubits this observable acts on.
observable_type
property
¶
Type of observable representation.
support
property
¶
Qubit indices where this observable acts non-trivially. Cached for performance.
weight
property
¶
Alias for locality (Pauli weight).
__eq__(other)
¶
Equality based on Pauli string and coefficient.
Source code in src/quartumse/observables/core.py
250 251 252 253 254 255 256 | |
__hash__()
¶
Hash based on Pauli string and coefficient.
Source code in src/quartumse/observables/core.py
246 247 248 | |
__post_init__()
¶
Validate and set defaults.
Source code in src/quartumse/observables/core.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
__repr__()
¶
Detailed representation.
Source code in src/quartumse/observables/core.py
240 241 242 243 244 | |
__str__()
¶
String representation.
Source code in src/quartumse/observables/core.py
234 235 236 237 238 | |
commutes_with(other)
¶
Check if this observable commutes with another.
Two Pauli strings commute if they differ on an even number of qubits (excluding positions where either is identity).
Source code in src/quartumse/observables/core.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
from_dict(data)
classmethod
¶
Create from dictionary.
Source code in src/quartumse/observables/core.py
223 224 225 226 227 228 229 230 231 232 | |
shared_basis(other)
¶
Get shared measurement basis if observables commute qubit-wise.
Returns None if no shared basis exists (observables don't commute qubit-wise, though they may still commute globally).
Source code in src/quartumse/observables/core.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
to_dict()
¶
Convert to dictionary for serialization.
Source code in src/quartumse/observables/core.py
210 211 212 213 214 215 216 217 218 219 220 221 | |
to_matrix()
¶
Convert to dense matrix representation.
Source code in src/quartumse/observables/core.py
148 149 150 151 152 153 154 155 | |
to_sparse_matrix()
¶
Convert to sparse matrix representation (opt-in for large systems).
Source code in src/quartumse/observables/core.py
157 158 159 160 161 162 163 164 165 166 167 | |
ObservableSet
dataclass
¶
A set of observables with generation metadata (§3.3).
This class represents a collection of observables to be estimated, along with metadata about how they were generated for reproducibility.
Attributes:
| Name | Type | Description |
|---|---|---|
observables |
list[Observable]
|
List of Observable objects. |
observable_set_id |
str | None
|
Unique identifier for this set. |
generator_id |
str | None
|
ID of the generator that created this set. |
generator_version |
str | None
|
Version of the generator. |
generator_seed |
int | None
|
Random seed used for generation. |
generator_params |
dict[str, Any]
|
Parameters passed to the generator. |
n_qubits |
int
|
Number of qubits (all observables must match). |
metadata |
dict[str, Any]
|
Additional set-level metadata. |
Source code in src/quartumse/observables/core.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
M
property
¶
Alias for n_observables (common notation).
n_observables
property
¶
Number of observables in this set.
n_qubits
property
¶
Number of qubits for observables in this set.
__getitem__(index)
¶
Get observable by index.
Source code in src/quartumse/observables/core.py
348 349 350 | |
__iter__()
¶
Iterate over observables.
Source code in src/quartumse/observables/core.py
340 341 342 | |
__len__()
¶
Number of observables.
Source code in src/quartumse/observables/core.py
344 345 346 | |
__post_init__()
¶
Validate and set defaults.
Source code in src/quartumse/observables/core.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
from_dict(data)
classmethod
¶
Create from dictionary.
Source code in src/quartumse/observables/core.py
367 368 369 370 371 372 373 374 375 376 377 378 379 | |
from_pauli_strings(pauli_strings, coefficients=None, **kwargs)
classmethod
¶
Create from a list of Pauli strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pauli_strings
|
list[str]
|
List of Pauli string representations. |
required |
coefficients
|
list[float] | None
|
Optional list of coefficients (default all 1.0). |
None
|
**kwargs
|
Any
|
Additional arguments passed to ObservableSet. |
{}
|
Returns:
| Type | Description |
|---|---|
ObservableSet
|
ObservableSet containing the specified observables. |
Source code in src/quartumse/observables/core.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
get_by_id(observable_id)
¶
Get an observable by its ID. O(1) lookup using index.
Source code in src/quartumse/observables/core.py
319 320 321 322 323 | |
locality_distribution()
¶
Get distribution of Pauli weights.
Source code in src/quartumse/observables/core.py
325 326 327 328 329 330 | |
max_locality()
¶
Maximum Pauli weight in the set.
Source code in src/quartumse/observables/core.py
332 333 334 | |
mean_locality()
¶
Mean Pauli weight in the set.
Source code in src/quartumse/observables/core.py
336 337 338 | |
to_dict()
¶
Convert to dictionary for serialization.
Source code in src/quartumse/observables/core.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
ObservableSuite
dataclass
¶
A named collection of observables for benchmarking.
This class extends ObservableSet with: - Suite name and type for clear scenario identification - Optional weights for weighted-sum objectives (energy, cost) - Objective type specification - Commutation analysis metadata
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable suite name (e.g., "workload_qaoa_cost") |
suite_type |
SuiteType
|
Category (workload, stress, posthoc, commuting) |
observable_set |
ObservableSet
|
The underlying ObservableSet |
weights |
dict[str, float] | None
|
Optional dict mapping observable_id -> coefficient |
objective |
ObjectiveType
|
Type of objective function |
description |
str
|
Human-readable description |
metadata |
dict[str, Any]
|
Additional suite-specific metadata |
Source code in src/quartumse/observables/suites.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
n_observables
property
¶
Number of observables in the suite.
n_qubits
property
¶
Number of qubits.
observables
property
¶
List of observables.
__post_init__()
¶
Validate suite configuration.
Source code in src/quartumse/observables/suites.py
77 78 79 80 81 82 83 84 85 86 87 88 89 | |
commutation_analysis()
¶
Analyze commutation structure of the suite.
Returns dict with
- n_commuting_groups: Number of groups after greedy partitioning
- max_group_size: Largest commuting group
- fully_commuting: Whether all observables commute
- grouping_efficiency: n_observables / n_groups (higher = better for direct)
Source code in src/quartumse/observables/suites.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
compute_objective(estimates)
¶
Compute the objective value from observable estimates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimates
|
dict[str, float]
|
Dict mapping observable_id -> estimated expectation value |
required |
Returns:
| Type | Description |
|---|---|
float
|
Objective value (interpretation depends on objective type) |
Source code in src/quartumse/observables/suites.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
from_pauli_strings(name, suite_type, pauli_strings, weights=None, **kwargs)
classmethod
¶
Create suite from Pauli strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Suite name |
required |
suite_type
|
SuiteType
|
Suite category |
required |
pauli_strings
|
list[str]
|
List of Pauli string representations |
required |
weights
|
dict[str, float] | None
|
Optional dict mapping Pauli string -> coefficient |
None
|
**kwargs
|
Any
|
Additional arguments (objective, description, metadata) |
{}
|
Source code in src/quartumse/observables/suites.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
locality_distribution()
¶
Distribution of Pauli weights.
Source code in src/quartumse/observables/suites.py
106 107 108 | |
to_dict()
¶
Convert to dictionary for serialization.
Source code in src/quartumse/observables/suites.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
ParquetReader
¶
Reader for partitioned Parquet results.
Example
reader = ParquetReader("results/run_001") result_set = reader.read_long_form() summary = reader.read_summary() manifest = reader.read_manifest()
Source code in src/quartumse/io/parquet_io.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
__init__(input_dir)
¶
Initialize reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dir
|
str | Path
|
Root directory for this run's results. |
required |
Source code in src/quartumse/io/parquet_io.py
250 251 252 253 254 255 256 257 | |
list_circuits(protocol_id=None)
¶
List available circuits in the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
protocol_id
|
str | None
|
Optional filter by protocol. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of circuit IDs. |
Source code in src/quartumse/io/parquet_io.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |
list_protocols()
¶
List available protocols in the dataset.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of protocol IDs. |
Source code in src/quartumse/io/parquet_io.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
read_long_form(filters=None)
¶
Read long-form results from Parquet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[tuple[str, str, Any]] | None
|
Optional pyarrow filters, e.g., [("protocol_id", "=", "direct_naive")] |
None
|
Returns:
| Type | Description |
|---|---|
LongFormResultSet
|
LongFormResultSet containing the results. |
Source code in src/quartumse/io/parquet_io.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
read_long_form_df(filters=None)
¶
Read long-form results as DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
list[tuple[str, str, Any]] | None
|
Optional pyarrow filters. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas DataFrame with results. |
Source code in src/quartumse/io/parquet_io.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
read_manifest()
¶
Read run manifest from JSON.
Returns:
| Type | Description |
|---|---|
RunManifest
|
RunManifest object. |
Source code in src/quartumse/io/parquet_io.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
read_summary()
¶
Read summary table from Parquet.
Returns:
| Type | Description |
|---|---|
list[SummaryRow]
|
List of SummaryRow objects. |
Source code in src/quartumse/io/parquet_io.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
read_summary_df()
¶
Read summary table as DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas DataFrame with summary. |
Source code in src/quartumse/io/parquet_io.py
329 330 331 332 333 334 335 336 337 338 339 340 | |
read_task_results()
¶
Read task results from Parquet.
Returns:
| Type | Description |
|---|---|
list[TaskResult]
|
List of TaskResult objects. |
Source code in src/quartumse/io/parquet_io.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
ParquetWriter
¶
Writer for partitioned Parquet output.
Example
writer = ParquetWriter("results/run_001") writer.write_long_form(result_set) writer.write_summary(summary_rows) writer.write_manifest(manifest)
Source code in src/quartumse/io/parquet_io.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
__init__(output_dir)
¶
Initialize writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str | Path
|
Root output directory for this run. |
required |
Source code in src/quartumse/io/parquet_io.py
57 58 59 60 61 62 63 64 65 | |
write_long_form(result_set, partitioned=None)
¶
Write long-form results to Parquet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result_set
|
LongFormResultSet
|
Collection of LongFormRow objects. |
required |
partitioned
|
bool | None
|
If True, partition by protocol/circuit/N_total. If None, auto-detect (disabled on Windows due to path length limits). |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written file or directory. |
Source code in src/quartumse/io/parquet_io.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
write_manifest(manifest)
¶
Write run manifest to JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
RunManifest
|
RunManifest object. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written file. |
Source code in src/quartumse/io/parquet_io.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
write_raw_shots(raw_records)
¶
Write raw shot-level data to a separate parquet file.
Each record should contain: - protocol_id, circuit_id, N_total, replicate_id, noise_profile: identifiers - setting_id: which measurement setting - bitstrings: JSON-serialized list of bitstring outcomes - measurement_bases: JSON-serialized basis choices (null for direct protocols)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_records
|
list[dict]
|
List of dicts, one per (config, setting) combination. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written parquet file. |
Source code in src/quartumse/io/parquet_io.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
write_summary(summary_rows)
¶
Write summary table to Parquet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary_rows
|
list[SummaryRow]
|
List of SummaryRow objects. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written file. |
Source code in src/quartumse/io/parquet_io.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
write_task_results(task_results)
¶
Write task results to Parquet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_results
|
list[TaskResult]
|
List of TaskResult objects. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written file. |
Source code in src/quartumse/io/parquet_io.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
PosthocBenchmarkResult
dataclass
¶
Complete results from a post-hoc benchmark.
Source code in src/quartumse/analysis/posthoc_benchmark.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
Protocol
¶
Bases: ABC
Abstract base class for measurement protocols (§5.1).
All protocols must implement this interface. The five-method contract supports both static and adaptive protocols:
Static protocols: - next_plan() returns a single plan consuming the full budget - update() only accumulates data - finalize() performs one-shot estimation
Adaptive protocols: - next_plan() may be called multiple times - update() may adjust internal state based on accumulated data - Can implement early stopping via state.converged
Subclasses must implement: - protocol_id (class attribute): Unique identifier - protocol_version (class attribute): Semantic version - initialize(): Set up initial state - next_plan(): Generate measurement plan - acquire(): Execute measurements - update(): Update state with new data - finalize(): Produce final estimates
Source code in src/quartumse/protocols/base.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
__init__(config=None)
¶
Initialize protocol with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ProtocolConfig | None
|
Protocol configuration. Uses defaults if None. |
None
|
Source code in src/quartumse/protocols/base.py
116 117 118 119 120 121 122 | |
acquire(circuit, plan, backend, seed, deadline=None)
abstractmethod
¶
Execute measurements according to the plan (§5.1).
This method generates measurement circuits, executes them on the backend, and returns raw measurement outcomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit
|
QuantumCircuit
|
The state preparation circuit. |
required |
plan
|
MeasurementPlan
|
Measurement plan to execute. |
required |
backend
|
AerSimulator | Any
|
Quantum backend for execution. |
required |
seed
|
int
|
Random seed for measurement randomness. |
required |
deadline
|
float | None
|
Absolute time (time.time()) by which to stop. If None, no timeout. |
None
|
Returns:
| Type | Description |
|---|---|
RawDatasetChunk
|
RawDatasetChunk containing measurement outcomes. |
Source code in src/quartumse/protocols/base.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
finalize(state, observable_set)
abstractmethod
¶
Produce final estimates from accumulated data (§5.1).
This method processes all accumulated measurement data to produce final expectation value estimates with uncertainty quantification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Final protocol state with all accumulated data. |
required |
observable_set
|
ObservableSet
|
The observables to estimate. |
required |
Returns:
| Type | Description |
|---|---|
Estimates
|
Estimates containing per-observable results. |
Source code in src/quartumse/protocols/base.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
get_info()
¶
Get protocol information for manifest/logging.
Source code in src/quartumse/protocols/base.py
394 395 396 397 398 399 400 | |
initialize(observable_set, total_budget, seed)
abstractmethod
¶
Initialize protocol state for a new estimation task (§5.1).
This method is called once at the start of estimation to set up the protocol's internal state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable_set
|
ObservableSet
|
The set of observables to estimate. |
required |
total_budget
|
int
|
Total shot budget for the estimation. |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
Returns:
| Type | Description |
|---|---|
ProtocolState
|
Initialized ProtocolState. |
Source code in src/quartumse/protocols/base.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
next_plan(state, remaining_budget)
abstractmethod
¶
Generate the next measurement plan (§5.1).
For static protocols, this returns a single plan consuming the full budget. For adaptive protocols, this may return partial plans to be executed iteratively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
remaining_budget
|
int
|
Remaining shot budget. |
required |
Returns:
| Type | Description |
|---|---|
MeasurementPlan
|
MeasurementPlan specifying settings and shot allocation. |
Source code in src/quartumse/protocols/base.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
run(circuit, observable_set, total_budget, backend, seed=None, timeout_s=None, hw_timing_profile=None)
¶
Execute the full protocol pipeline.
This is a convenience method that runs the full initialize -> (next_plan -> acquire -> update)* -> finalize loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit
|
QuantumCircuit
|
State preparation circuit. |
required |
observable_set
|
ObservableSet
|
Observables to estimate. |
required |
total_budget
|
int
|
Total shot budget. |
required |
backend
|
AerSimulator | Any
|
Quantum backend. |
required |
seed
|
int | None
|
Random seed (uses config.random_seed if None). |
None
|
timeout_s
|
float | None
|
Optional per-run timeout in seconds. If the deadline is exceeded, the run stops early, finalizes with partial data, and sets timed_out=True on the returned Estimates. |
None
|
hw_timing_profile
|
Any | None
|
Optional HardwareTimingProfile for estimating real-device execution time. |
None
|
Returns:
| Type | Description |
|---|---|
Estimates
|
Final Estimates. |
Source code in src/quartumse/protocols/base.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
update(state, data_chunk)
abstractmethod
¶
Update protocol state with new measurement data (§5.1).
For static protocols, this simply accumulates data. For adaptive protocols, this may update variance estimates, convergence checks, or other internal state used for planning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ProtocolState
|
Current protocol state. |
required |
data_chunk
|
RawDatasetChunk
|
New measurement data. |
required |
Returns:
| Type | Description |
|---|---|
ProtocolState
|
Updated ProtocolState. |
Source code in src/quartumse/protocols/base.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
ProvenanceManifest
¶
High-level interface for creating and managing provenance manifests.
Source code in src/quartumse/reporting/manifest.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
add_tag(tag)
¶
Add a searchable tag.
Source code in src/quartumse/reporting/manifest.py
250 251 252 253 | |
create(experiment_id, circuit_fingerprint, backend_snapshot, **kwargs)
classmethod
¶
Create a new manifest with required fields.
Source code in src/quartumse/reporting/manifest.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
from_json(path)
classmethod
¶
Load manifest from JSON file.
Source code in src/quartumse/reporting/manifest.py
243 244 245 246 247 248 | |
to_json(path=None)
¶
Export manifest as JSON.
Source code in src/quartumse/reporting/manifest.py
234 235 236 237 238 239 240 241 | |
update_results(results)
¶
Update the results summary.
Source code in src/quartumse/reporting/manifest.py
255 256 257 | |
validate(*, require_shot_file=True)
¶
Validate the manifest schema and ensure referenced artifacts exist.
Source code in src/quartumse/reporting/manifest.py
259 260 261 262 263 264 265 266 267 | |
Report
¶
Container for experiment report data.
Source code in src/quartumse/reporting/report.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
to_html(output_path=None)
¶
Generate HTML report.
Source code in src/quartumse/reporting/report.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
to_pdf(output_path)
¶
Generate PDF report (requires weasyprint).
Source code in src/quartumse/reporting/report.py
392 393 394 395 396 397 398 399 400 401 402 | |
ReportBuilder
¶
Builder for constructing benchmark reports.
Source code in src/quartumse/viz/reports.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
__init__(run_id, title=None)
¶
Initialize report builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
Benchmark run identifier. |
required |
title
|
str | None
|
Report title. |
None
|
Source code in src/quartumse/viz/reports.py
248 249 250 251 252 253 254 255 256 257 258 | |
add_conclusions_section(conclusions)
¶
Add conclusions section.
Source code in src/quartumse/viz/reports.py
369 370 371 372 373 374 375 376 377 378 379 | |
add_figures_section(figure_paths, title='Figures')
¶
Add figures section.
Source code in src/quartumse/viz/reports.py
356 357 358 359 360 361 362 363 364 365 366 367 | |
add_overview_section(n_protocols, n_circuits, n_observables, n_replicates, n_grid)
¶
Add overview section.
Source code in src/quartumse/viz/reports.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
add_summary_section(summaries)
¶
Add summary statistics section.
Source code in src/quartumse/viz/reports.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
add_task_results_section(task_results)
¶
Add task results section.
Source code in src/quartumse/viz/reports.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
build()
¶
Build and return the report.
Source code in src/quartumse/viz/reports.py
381 382 383 | |
with_manifest(manifest)
¶
Add run manifest.
Source code in src/quartumse/viz/reports.py
260 261 262 263 264 | |
ShadowConfig
¶
Bases: BaseModel
Configuration for classical shadows estimation.
Source code in src/quartumse/shadows/config.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
validate_version_compatibility()
¶
Validate that enabled features match the selected version.
Source code in src/quartumse/shadows/config.py
88 89 90 91 92 93 | |
ShadowEstimator
¶
Bases: Estimator
Observable estimator using classical shadows.
Automatically selects shadow version based on config and orchestrates: 1. Shadow measurement generation 2. Circuit execution 3. Shadow reconstruction 4. Observable estimation 5. Provenance tracking
Source code in src/quartumse/estimator/shadow_estimator.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__init__(backend, shadow_config=None, mitigation_config=None, data_dir=None)
¶
Initialize shadow estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
Backend | str
|
Qiskit backend or backend name (e.g., "aer_simulator") |
required |
shadow_config
|
ShadowConfig | None
|
Classical shadows configuration |
None
|
mitigation_config
|
MitigationConfig | None
|
Error mitigation configuration |
None
|
data_dir
|
str | Path | None
|
Directory for storing shot data and manifests |
None
|
Source code in src/quartumse/estimator/shadow_estimator.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
estimate(circuit, observables, target_precision=None, save_manifest=True)
¶
Estimate observables using classical shadows.
Workflow: 1. Generate shadow measurement circuits 2. Transpile and execute on backend 3. Reconstruct shadow snapshots 4. Estimate all observables 5. Generate provenance manifest
Source code in src/quartumse/estimator/shadow_estimator.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
estimate_shots_needed(observables, target_precision)
¶
Estimate shadow size needed for target precision.
Source code in src/quartumse/estimator/shadow_estimator.py
368 369 370 371 372 373 374 375 376 | |
replay_from_manifest(manifest_path, observables=None)
¶
Replay an experiment from a saved manifest and shot data.
This allows re-estimation of observables from previously collected shot data without re-executing circuits on the backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest_path
|
str | Path
|
Path to the provenance manifest JSON file |
required |
observables
|
list[Observable] | None
|
Optional new list of observables to estimate. If None, uses observables from the original manifest. |
None
|
Returns:
| Type | Description |
|---|---|
EstimationResult
|
EstimationResult with re-estimated observables |
Source code in src/quartumse/estimator/shadow_estimator.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 | |
SuiteType
¶
Bases: Enum
Category of observable suite.
Source code in src/quartumse/observables/suites.py
39 40 41 42 43 44 45 46 | |
SummaryRow
¶
Bases: BaseModel
Summary statistics for (protocol, circuit, N) combination (§10.3).
This schema defines aggregated metrics across observables and replicates.
Source code in src/quartumse/io/schemas.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
SweepConfig
dataclass
¶
Configuration for a benchmark sweep.
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Unique identifier for this run. |
methodology_version |
str
|
Version of the methodology. |
protocols |
list[Protocol]
|
List of protocol instances to evaluate. |
circuits |
list[tuple[str, Any]]
|
List of (circuit_id, circuit) tuples. |
observable_sets |
list[tuple[str, ObservableSet]]
|
List of (obs_set_id, ObservableSet) tuples. |
n_grid |
list[int]
|
Shot budget grid. |
n_replicates |
int
|
Number of replicates per configuration. |
noise_profiles |
list[str]
|
List of noise profile IDs. |
seeds |
dict[str, int]
|
Seed configuration. |
tasks |
list[str]
|
List of task IDs to run. |
Source code in src/quartumse/tasks/sweep.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
SweepOrchestrator
¶
Orchestrator for running benchmark sweeps.
Manages the execution of protocols across the sweep grid and collects results.
Source code in src/quartumse/tasks/sweep.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
__init__(config, executor=None)
¶
Initialize sweep orchestrator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
SweepConfig
|
Sweep configuration. |
required |
executor
|
Callable | None
|
Optional custom executor for running protocols. |
None
|
Source code in src/quartumse/tasks/sweep.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
compute_total_configs()
¶
Compute total number of configurations.
Source code in src/quartumse/tasks/sweep.py
177 178 179 180 181 182 183 184 185 186 | |
create_manifest()
¶
Create run manifest for this sweep.
Source code in src/quartumse/tasks/sweep.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
generate_seeds(replicate_id, config_id)
¶
Generate reproducible seeds for a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
replicate_id
|
int
|
Replicate number. |
required |
config_id
|
int
|
Configuration index. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
Dict with seed_policy, seed_protocol, seed_acquire, seed_bootstrap. |
Source code in src/quartumse/tasks/sweep.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
run(progress_callback=None)
¶
Run the benchmark sweep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
progress_callback
|
Callable[[SweepProgress], None] | None
|
Optional callback for progress updates. |
None
|
Returns:
| Type | Description |
|---|---|
LongFormResultSet
|
LongFormResultSet with all results. |
Source code in src/quartumse/tasks/sweep.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
TaskConfig
dataclass
¶
Configuration for a benchmark task.
Attributes:
| Name | Type | Description |
|---|---|---|
task_id |
str
|
Unique identifier for the task. |
task_type |
TaskType
|
Type of task. |
epsilon |
float
|
Target precision (for precision-based tasks). |
delta |
float
|
Global failure probability. |
criterion_type |
CriterionType
|
Type of criterion to use. |
fwer_method |
str
|
FWER control method. |
n_grid |
list[int]
|
Shot budget grid to evaluate. |
n_replicates |
int
|
Number of repetitions per configuration. |
baseline_protocol_id |
str
|
Baseline protocol for SSF computation. |
additional_params |
dict[str, Any]
|
Task-specific additional parameters. |
Source code in src/quartumse/tasks/base.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
TaskType
¶
Bases: str, Enum
Types of benchmark tasks.
Source code in src/quartumse/tasks/base.py
21 22 23 24 25 26 27 28 29 30 31 | |
analyze_by_locality(long_form_results, n_total=None, locality_map=None)
¶
Analyze protocol performance grouped by observable locality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
long_form_results
|
list[LongFormRow]
|
Long-form benchmark results |
required |
n_total
|
int | None
|
Specific shot budget to analyze (None = use max) |
None
|
locality_map
|
dict[str, int] | None
|
Map observable_id -> locality (auto-extracted if None) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, PropertyAnalysis]
|
Dict mapping protocol_id to PropertyAnalysis |
Source code in src/quartumse/analysis/observable_properties.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
bootstrap_ci(data, statistic=np.mean, confidence=0.95, n_bootstrap=10000, seed=42)
¶
Compute bootstrap confidence interval.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray | list[float]
|
Sample data |
required |
statistic
|
Callable[[ndarray], float]
|
Function to compute statistic (default: mean) |
mean
|
confidence
|
float
|
Confidence level |
0.95
|
n_bootstrap
|
int
|
Number of bootstrap resamples |
10000
|
seed
|
int | None
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
BootstrapCI
|
BootstrapCI with estimate and bounds |
Source code in src/quartumse/analysis/statistical_tests.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
bootstrap_hypothesis_test(data_a, data_b, statistic=np.mean, alternative='two-sided', n_bootstrap=10000, alpha=0.05, seed=42)
¶
Bootstrap hypothesis test for difference between groups.
Tests H0: statistic(A) = statistic(B)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_a
|
ndarray | list[float]
|
Sample from group A |
required |
data_b
|
ndarray | list[float]
|
Sample from group B |
required |
statistic
|
Callable[[ndarray], float]
|
Function to compute statistic |
mean
|
alternative
|
str
|
"two-sided", "less", or "greater" |
'two-sided'
|
n_bootstrap
|
int
|
Number of bootstrap resamples |
10000
|
alpha
|
float
|
Significance level |
0.05
|
seed
|
int | None
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
HypothesisTestResult
|
HypothesisTestResult |
Source code in src/quartumse/analysis/statistical_tests.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
compare_protocols_statistically(results_a, results_b, n_total, epsilon=0.01, alpha=0.05, n_bootstrap=10000, seed=42)
¶
Complete statistical comparison between two protocols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_a
|
list
|
Long-form results from protocol A |
required |
results_b
|
list
|
Long-form results from protocol B |
required |
n_total
|
int
|
Shot budget to compare at |
required |
epsilon
|
float
|
Target precision for SSF |
0.01
|
alpha
|
float
|
Significance level |
0.05
|
n_bootstrap
|
int
|
Number of bootstrap samples |
10000
|
seed
|
int
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
StatisticalComparison
|
StatisticalComparison with all tests |
Source code in src/quartumse/analysis/statistical_tests.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |
compute_cost_normalized_metrics(long_form_results, cost_model=None, truth_values=None)
¶
Compute cost-normalized metrics for all protocols.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
long_form_results
|
list[LongFormRow]
|
Long-form benchmark results |
required |
cost_model
|
CostModel | None
|
Cost model to use (default: CostModel()) |
None
|
truth_values
|
dict[str, float] | None
|
Ground truth for error computation |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
dict[str, dict[int, CostNormalizedResult]]
|
protocol_id -> {N -> CostNormalizedResult} |
Source code in src/quartumse/analysis/cost_normalized.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
compute_objective_metrics(long_form_results, weights, objective_type='weighted_sum', true_objective=None, target_epsilon=0.01, n_bootstrap=1000, seed=42)
¶
Compute objective-level metrics from benchmark results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
long_form_results
|
list
|
List of LongFormRow from benchmark |
required |
weights
|
dict[str, float]
|
Dict mapping observable_id -> coefficient |
required |
objective_type
|
str
|
"weighted_sum" or "qaoa_cost" |
'weighted_sum'
|
true_objective
|
float | None
|
Ground truth objective value (if known) |
None
|
target_epsilon
|
float
|
Target error for N* computation |
0.01
|
n_bootstrap
|
int
|
Bootstrap samples for CI |
1000
|
seed
|
int
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
ObjectiveAnalysis
|
ObjectiveAnalysis with per-protocol metrics |
Source code in src/quartumse/analysis/objective_metrics.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
construct_ci(data=None, estimate=None, se=None, method=CIMethodType.NORMAL, confidence_level=0.95, n_bootstrap=1000, seed=None)
¶
Construct confidence interval using specified method.
For NORMAL method, provide estimate and se. For BOOTSTRAP methods, provide data array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
NDArray[floating] | None
|
Array of observations (for bootstrap methods). |
None
|
estimate
|
float | None
|
Point estimate (for normal method). |
None
|
se
|
float | None
|
Standard error (for normal method). |
None
|
method
|
CIMethodType | str
|
CI construction method. |
NORMAL
|
confidence_level
|
float
|
Confidence level (default 0.95). |
0.95
|
n_bootstrap
|
int
|
Number of bootstrap samples. |
1000
|
seed
|
int | None
|
Random seed for reproducibility. |
None
|
Returns:
| Type | Description |
|---|---|
ConfidenceInterval
|
ConfidenceInterval result. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required parameters are missing. |
Source code in src/quartumse/stats/confidence.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
construct_simultaneous_cis(estimates, standard_errors, alpha=0.05, fwer_method=FWERMethod.BONFERRONI, ci_method=CIMethodType.NORMAL)
¶
Construct simultaneous CIs with FWER control.
Each CI is constructed at the FWER-adjusted confidence level to ensure family-wise coverage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimates
|
list[float]
|
List of point estimates. |
required |
standard_errors
|
list[float]
|
List of standard errors. |
required |
alpha
|
float
|
Global significance level. |
0.05
|
fwer_method
|
FWERMethod | str
|
Method for FWER control. |
BONFERRONI
|
ci_method
|
CIMethodType | str
|
Method for individual CI construction. |
NORMAL
|
Returns:
| Type | Description |
|---|---|
SimultaneousCIs
|
SimultaneousCIs with family-wise coverage guarantee. |
Source code in src/quartumse/stats/fwer.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
fit_power_law(ns, se_values, initial_exponent=-0.5)
¶
Fit power law SE = a * N^b to data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ns
|
list[int]
|
Shot budgets |
required |
se_values
|
list[float]
|
Corresponding SE values |
required |
initial_exponent
|
float
|
Initial guess for exponent (default -0.5) |
-0.5
|
Returns:
| Type | Description |
|---|---|
PowerLawFit
|
PowerLawFit with fitted parameters |
Source code in src/quartumse/analysis/interpolation.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
format_objective_analysis(analysis)
¶
Format objective analysis for display.
Source code in src/quartumse/analysis/objective_metrics.py
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
format_posthoc_result(result)
¶
Format post-hoc benchmark result for display.
Source code in src/quartumse/analysis/posthoc_benchmark.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
generate_all_k_local(n_qubits, k)
¶
Generate ALL k-local Pauli strings on n qubits.
Total count: C(n,k) * 3^k
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
k
|
int
|
Locality (Pauli weight) |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of Pauli strings |
Source code in src/quartumse/observables/suites.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
generate_observable_set(generator_id, n_qubits, n_observables, seed, **kwargs)
¶
Convenience function to generate an ObservableSet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generator_id
|
str
|
ID of the generator to use. |
required |
n_qubits
|
int
|
Number of qubits. |
required |
n_observables
|
int
|
Number of observables to generate. |
required |
seed
|
int
|
Random seed for reproducibility. |
required |
**kwargs
|
Any
|
Additional generator-specific parameters. |
{}
|
Returns:
| Type | Description |
|---|---|
ObservableSet
|
Generated ObservableSet. |
Source code in src/quartumse/observables/generators.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
get_profile(profile_id)
¶
Get a noise profile by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_id
|
str
|
Profile identifier. |
required |
Returns:
| Type | Description |
|---|---|
NoiseProfile
|
NoiseProfile object. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If profile not found. |
Source code in src/quartumse/noise/profiles.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
get_protocol(protocol_id)
¶
Get a protocol class by ID from the global registry.
Source code in src/quartumse/protocols/registry.py
135 136 137 | |
interpolate_n_star(ns, se_values, epsilon, method='power_law')
¶
Interpolate N* (shots-to-target) using power-law fit.
Instead of grid search, fits SE ∝ N^{-0.5} and solves for N* analytically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ns
|
list[int]
|
Shot budgets |
required |
se_values
|
list[float]
|
Corresponding SE values (mean or max) |
required |
epsilon
|
float
|
Target SE threshold |
required |
method
|
str
|
"power_law" or "linear" interpolation |
'power_law'
|
Returns:
| Type | Description |
|---|---|
tuple[float | None, PowerLawFit | None]
|
Tuple of (interpolated N*, PowerLawFit object or None) |
Source code in src/quartumse/analysis/interpolation.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
ks_test_protocols(se_a, se_b, alpha=0.05)
¶
Kolmogorov-Smirnov test for distribution difference.
Tests whether SE distributions differ significantly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
se_a
|
ndarray | list[float]
|
SE values from protocol A |
required |
se_b
|
ndarray | list[float]
|
SE values from protocol B |
required |
alpha
|
float
|
Significance level |
0.05
|
Returns:
| Type | Description |
|---|---|
HypothesisTestResult
|
HypothesisTestResult |
Source code in src/quartumse/analysis/statistical_tests.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
list_profiles()
¶
List available noise profile IDs.
Source code in src/quartumse/noise/profiles.py
168 169 170 | |
list_protocols()
¶
List all registered protocol IDs from the global registry.
Source code in src/quartumse/protocols/registry.py
140 141 142 | |
make_bell_suites(n_pairs, seed=42)
¶
Create benchmark suites for Bell pair verification.
Bell pairs: ⊗_i (|00⟩ + |11⟩)_i / √2
Suites
workload_pair_correlations: XX, YY, ZZ on each Bell pair diagnostics_single_qubit: Single-qubit Z for readout diagnostics diagnostics_cross_pair: Cross-pair correlators (crosstalk detection) stress_random_1000: Random observables
Source code in src/quartumse/observables/suites.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
make_chemistry_suites(n_qubits, hamiltonian_terms=None, hamiltonian_coeffs=None, molecule_name='generic', seed=42)
¶
Create benchmark suites for chemistry / VQE.
Energy estimation: E = Σ_k c_k ⟨P_k⟩
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
hamiltonian_terms
|
list[str] | None
|
Pauli strings for Hamiltonian (optional) |
None
|
hamiltonian_coeffs
|
list[float] | None
|
Coefficients for each term (optional) |
None
|
molecule_name
|
str
|
Name for labeling (H2, LiH, etc.) |
'generic'
|
seed
|
int
|
Random seed |
42
|
Suites
workload_energy: Hamiltonian terms with weights (if provided) stress_random_1000: Random observables
Source code in src/quartumse/observables/suites.py
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 | |
make_commuting_suite(n_qubits, basis='Z', include_global=True, name=None)
¶
Create an all-commuting suite (grouped measurement advantage).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
basis
|
Literal['Z', 'X', 'Y']
|
Which Pauli basis ('Z', 'X', or 'Y') |
'Z'
|
include_global
|
bool
|
Include global string (e.g., Z^n) |
True
|
name
|
str | None
|
Suite name |
None
|
Source code in src/quartumse/observables/suites.py
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
make_ghz_suites(n_qubits, seed=42)
¶
Create benchmark suites for GHZ state verification.
GHZ state: |00...0⟩ + |11...1⟩ / √2
Suites
workload_stabilizers: GHZ stabilizer generators (X^n, Z_i Z_j pairs) stress_random_1000: 1000 random observables, stratified by weight commuting_z_only: All-Z correlators (grouped measurement advantage) posthoc_library: 2000 observables for post-hoc querying tests
Source code in src/quartumse/observables/suites.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
make_ising_suites(n_qubits, seed=42)
¶
Create benchmark suites for Ising/Trotter physics.
Transverse-field Ising: H = -J Σ Z_i Z_{i+1} - h Σ X_i
Suites
workload_energy: Hamiltonian terms (ZZ chain + X single-qubit) workload_correlations: Z_i Z_j at multiple distances stress_random_1000: Random observables
Source code in src/quartumse/observables/suites.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |
make_phase_sensing_suites(n_qubits, seed=42)
¶
Create benchmark suites for GHZ phase sensing / metrology.
GHZ state with phase: (|00...0⟩ + e^{inφ}|11...1⟩) / √2
Key observables for phase estimation
- X^⊗n: Real part of off-diagonal coherence
- Y^⊗n: Imaginary part of off-diagonal coherence
Suites
workload_phase_signal: X^n and Y^n (ALWAYS included for n >= 2) workload_stabilizers: Full GHZ stabilizer set stress_random_500: Random observables
Source code in src/quartumse/observables/suites.py
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | |
make_posthoc_library(n_qubits, n_observables=2000, seed=42, name=None)
¶
Create a post-hoc querying library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
n_observables
|
int
|
Library size |
2000
|
seed
|
int
|
Random seed |
42
|
name
|
str | None
|
Suite name |
None
|
Source code in src/quartumse/observables/suites.py
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
make_qaoa_ring_suites(n_qubits, seed=42)
¶
Create benchmark suites for QAOA MAX-CUT on ring graph.
Ring graph: edges (i, i+1) for i=0..n-2, PLUS wrap-around (n-1, 0)
Cost function: C = Σ_e (1 - ⟨Z_i Z_j⟩) / 2
Suites
workload_cost: All edge ZZ terms (INCLUDING wrap-around!) commuting_z_only: Same as workload (all commute in Z basis) stress_random_1000: Random observables
Source code in src/quartumse/observables/suites.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
make_stress_suite(n_qubits, n_observables=1000, strategy='stratified', seed=42, name=None)
¶
Create a stress test suite with many observables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
n_observables
|
int
|
Number of observables to sample |
1000
|
strategy
|
str
|
Sampling strategy ('stratified', 'uniform', 'importance') |
'stratified'
|
seed
|
int
|
Random seed |
42
|
name
|
str | None
|
Suite name (auto-generated if None) |
None
|
Source code in src/quartumse/observables/suites.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 | |
multi_pilot_analysis(long_form_results, target_n=None, pilot_fractions=None, metric='mean_se')
¶
Analyze pilot-based selection across multiple pilot fractions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
long_form_results
|
list[LongFormRow]
|
Long-form benchmark results |
required |
target_n
|
int | None
|
Final shot budget (None = use max) |
None
|
pilot_fractions
|
list[float] | None
|
List of pilot fractions to test |
None
|
metric
|
str
|
Quality metric ("mean_se", "median_se", "max_se") |
'mean_se'
|
Returns:
| Type | Description |
|---|---|
MultiPilotAnalysis
|
MultiPilotAnalysis with results for each fraction |
Source code in src/quartumse/analysis/pilot_analysis.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
normal_ci(estimate, se, confidence_level=0.95, n_samples=0)
¶
Construct normal (Wald) confidence interval.
CI = estimate ± z_{α/2} * SE
where z_{α/2} is the (1 - α/2) quantile of the standard normal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
estimate
|
float
|
Point estimate. |
required |
se
|
float
|
Standard error. |
required |
confidence_level
|
float
|
Confidence level (default 0.95). |
0.95
|
n_samples
|
int
|
Number of samples (for metadata). |
0
|
Returns:
| Type | Description |
|---|---|
ConfidenceInterval
|
ConfidenceInterval with normal CI. |
Source code in src/quartumse/stats/confidence.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
per_observable_crossover(results_a, results_b, metric='se', interpolate=True)
¶
Compute per-observable crossover analysis.
For each observable, finds at what N protocol A beats protocol B.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results_a
|
list[LongFormRow]
|
Long-form results from protocol A |
required |
results_b
|
list[LongFormRow]
|
Long-form results from protocol B |
required |
metric
|
str
|
"se" or "error" |
'se'
|
interpolate
|
bool
|
Whether to interpolate crossover using power-law |
True
|
Returns:
| Type | Description |
|---|---|
CrossoverAnalysis
|
CrossoverAnalysis with per-observable results |
Source code in src/quartumse/analysis/crossover.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
plot_attainment_curves(attainment_data, epsilon, config=None, ax=None)
¶
Plot attainment curves for multiple protocols.
f(N;ε) = fraction of observables with SE ≤ ε
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attainment_data
|
dict[str, dict[int, float]]
|
Dict mapping protocol_id to {N: attainment}. |
required |
epsilon
|
float
|
Target precision used. |
required |
config
|
PlotConfig | None
|
Plot configuration. |
None
|
ax
|
Axes | None
|
Existing axes to plot on. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Matplotlib Figure. |
Source code in src/quartumse/viz/plots.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
plot_ssf_comparison(ssf_data, baseline_id, config=None, ax=None)
¶
Plot shot-savings factor bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ssf_data
|
dict[str, float]
|
Dict mapping protocol_id to SSF value. |
required |
baseline_id
|
str
|
Baseline protocol ID (SSF=1). |
required |
config
|
PlotConfig | None
|
Plot configuration. |
None
|
ax
|
Axes | None
|
Existing axes to plot on. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Matplotlib Figure. |
Source code in src/quartumse/viz/plots.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
run_benchmark_suite(circuit, observable_set, circuit_id='circuit', config=None, protocols=None, locality_map=None)
¶
Run unified benchmark suite.
This is the main entry point for running benchmarks. It provides three modes:
- basic: Run core protocols + Tasks 1, 3, 6 + basic report
- complete: Run all 8 tasks + complete report
- analysis: Complete + enhanced analysis (crossover, locality, bootstrap)
All results are saved to a unique timestamped directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
circuit
|
Any
|
Quantum circuit (any Qiskit QuantumCircuit) |
required |
observable_set
|
ObservableSet
|
Set of observables to estimate |
required |
circuit_id
|
str
|
Identifier for the circuit |
'circuit'
|
config
|
BenchmarkSuiteConfig | None
|
Benchmark configuration (default: BenchmarkSuiteConfig()) |
None
|
protocols
|
list | None
|
List of protocol IDs or instances (default: all baselines + shadows) |
None
|
locality_map
|
dict[str, int] | None
|
Optional mapping of observable_id -> locality (Pauli weight) |
None
|
Returns:
| Type | Description |
|---|---|
BenchmarkSuiteResult
|
BenchmarkSuiteResult with all outputs and paths to saved reports |
Example
from quartumse import run_benchmark_suite, BenchmarkMode, BenchmarkSuiteConfig
Basic benchmark¶
result = run_benchmark_suite(circuit, observables, circuit_id="ghz_4q")
Complete with all 8 tasks¶
config = BenchmarkSuiteConfig(mode=BenchmarkMode.COMPLETE) result = run_benchmark_suite(circuit, observables, config=config)
Full analysis¶
config = BenchmarkSuiteConfig(mode=BenchmarkMode.ANALYSIS) result = run_benchmark_suite(circuit, observables, config=config)
print(f"Reports saved to: {result.output_dir}")
Source code in src/quartumse/benchmark_suite.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 | |
run_comprehensive_analysis(long_form_results, truth_values=None, epsilon=0.01, delta=0.05, locality_map=None, run_id='comprehensive_analysis', shadows_protocol_id='classical_shadows_v0', baseline_protocol_id='direct_grouped')
¶
Run comprehensive benchmark analysis with all improvements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
long_form_results
|
list[LongFormRow]
|
Long-form benchmark results |
required |
truth_values
|
dict[str, float] | None
|
Ground truth values for observables |
None
|
epsilon
|
float
|
Target precision |
0.01
|
delta
|
float
|
Failure probability |
0.05
|
locality_map
|
dict[str, int] | None
|
Map observable_id -> locality |
None
|
run_id
|
str
|
Analysis identifier |
'comprehensive_analysis'
|
shadows_protocol_id
|
str
|
ID of shadows protocol for comparison |
'classical_shadows_v0'
|
baseline_protocol_id
|
str
|
ID of baseline protocol for comparison |
'direct_grouped'
|
Returns:
| Type | Description |
|---|---|
ComprehensiveBenchmarkAnalysis
|
ComprehensiveBenchmarkAnalysis with all results |
Source code in src/quartumse/analysis/comprehensive.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
run_posthoc_benchmark_from_suite(posthoc_suite, n_rounds=5, observables_per_round=None, shadows_shots=1000, direct_shots_per_basis=100, seed=42)
¶
Run post-hoc benchmark using a posthoc library suite.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posthoc_suite
|
ObservableSuite
|
ObservableSuite with POSTHOC type |
required |
n_rounds
|
int
|
Number of query rounds |
5
|
observables_per_round
|
int | None
|
Observables per round (default: library_size // n_rounds) |
None
|
shadows_shots
|
int
|
Total shots for shadows acquisition |
1000
|
direct_shots_per_basis
|
int
|
Shots per measurement basis for direct |
100
|
seed
|
int
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
PosthocBenchmarkResult
|
PosthocBenchmarkResult |
Source code in src/quartumse/analysis/posthoc_benchmark.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
sample_random_paulis(n_qubits, n_samples, strategy='stratified', max_weight=None, seed=42)
¶
Sample random Pauli observables using various strategies.
Strategies
'stratified': Equal samples per weight class (best for benchmarking) 'uniform': Each qubit i.i.d. I/X/Y/Z (biases toward middle weights) 'importance': Weight k sampled with prob ∝ 1/3^k (matches shadows variance) 'uniform_weight': Uniform over weight classes, then uniform within
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_qubits
|
int
|
Number of qubits |
required |
n_samples
|
int
|
Number of Paulis to sample |
required |
strategy
|
Literal['stratified', 'uniform', 'importance', 'uniform_weight']
|
Sampling strategy |
'stratified'
|
max_weight
|
int | None
|
Maximum Pauli weight (default: n_qubits) |
None
|
seed
|
int
|
Random seed |
42
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of sampled Pauli strings |
Source code in src/quartumse/observables/suites.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
Commands¶
See the CLI reference for command-line usage details.