SynthesisConfig
- class SynthesisConfig(tolerance_error=1e-08, layout_method='trivial', optimizer='bfgs2', global_search='basin_hopping', n_trials_warm=1, n_trials_cold=1, warm_start_from_level=1, refine_best_trial=False, parallel_mode='openmp', use_float=False, round_single_qubit_rotations=None, seed=None, verbosity='silent', barrier=False)
Represent the parameters every
quasarcppsynthesis strategy reads.This dataclass carries only the options that reach all of the synthesis strategies. Anything a single strategy consumes is declared on that strategy’s own config, so a field is never offered where the backend would ignore it.
- Variables:
tolerance_error – Target compilation error: an average gate infidelity against a unitary target, a state infidelity against a state, the numbers
compilation_error()andstate_preparation_error()report. Synthesis is considered successful once the compilation error falls below this value, so a small enoughtolerance_errormakes the compilation numerically exact.layout_method – How logical qubits map to physical qubits at the circuit’s input and at its output. The mappings are fixed, or searched by synthesizing candidates and ranking them: by the overall error under an error-aware strategy, by what
layout_objectivechooses under the other two. Values:"trivial"(the default) keeps logical qubit \(i\) on physical qubit \(i\) at both ends;"full_search"tries every(initial, final)pair, \((n!)^2\) syntheses on \(n\) qubits;"greedy_search"picks the input mapping, then the output mapping, \(2\,n!\) syntheses;"symmetric_search"covers the same pairs as"full_search"in fewer syntheses, \(n \cdot n!\) on a star;"diagonal_search"tries only pairs where the output mapping equals the input mapping, \(n\) syntheses on a star; or an explicit(initial_permutation, final_permutation)tuple. Synonyms:none/off-> trivial;full/exhaustive-> full_search;greedy/sequential-> greedy_search;diagonal-> diagonal_search. With a readout target (a trailingPauliProductMeasurement), a search also covers the readout transformation. The chosen mappings are recorded on the compiled circuit’s.layout. Same purpose asQiskitConfig’slayout_method, but a different mechanism and value set.optimizer – Name of the backend numerical optimizer used to fit the ansatz parameters, case-insensitive:
"bfgs2"(the default),"bfgs","grad_descend","agents","agents_combined"or"adam". Any other name raisesConfigErrorwhen the config is built. The three fastest and most accurate arebfgs2,bfgsandgrad_descend;agentsandadamstop well short of the target error, andadamis two orders of magnitude slower.global_search – Name of the global search that wraps the local optimizer, read only by the
BFGS2optimizer; any otheroptimizerignores it."basin_hopping"(the default) selects a basin-hopping restart loop,"dual_annealing"a dual-annealing one, and"differential_evolution"a differential-evolution one.n_trials_warm – Number of optimizations the backend runs on each candidate gate structure starting from the previous level’s result. The first level has no previous result, and its warm trials start from a random point.
n_trials_cold – Number of optimizations the backend runs on each candidate gate structure from a random starting point. The best of all trials, warm and cold, decides the structure’s result, and at least one trial must run. More trials take longer, and can reach
tolerance_erroron targets that fewer trials miss.warm_start_from_level – First level whose warm trials start from the previous level’s result. Below it every trial starts from a random point, whatever
n_trials_warmsays.1(the default) lets every level start from its predecessor.refine_best_trial – Whether one further optimization refines the best trial, for one more than the trial counts in total. It is off by default: it adds compile time and seldom changes the gate count.
parallel_mode – Name of the backend parallelization mode:
"sequential"runs on one thread,"openmp"(the default) and"tbb"run on several threads.use_float – Whether to run the
quasarcppsynthesis backend in single-precision (float32) instead of the default double-precision (float64). In single precision atolerance_errorbelow about1e-6is not reached reliably.round_single_qubit_rotations – The angles that single-qubit rotation angles are rounded onto once the search has converged, such as
(),(0,)or(0, np.pi / 2). Each angle is read modulo \(2\pi\) and stands for its negative too.None(the default) leaves it to the gate set:FixedCROTGateSetrounds onto(0, np.pi / 2)and every other gate set of this package onto(0,). A rotation within 0.5 rad of a target is rounded onto the nearest one: a zero rotation is no gate, a \(\pi\) rotation is an \(X\), and a rotation onto any other target turns by exactly that angle. A rounding is kept while the compilation error stays withintolerance_error, so the compilation error can rise up to it; an error-aware strategy keeps a rounding while the overall error does not rise.()turns rounding off where compile time matters more than the pulse count. Applies to both unitary and state compilation.seed – Seed for the backend’s random number generator: a non-negative Python or NumPy integer, or
Noneto draw one from the OS. Unseeded, repeated compiles of the same circuit return different (though all tolerance-respecting) results. A fixedseedpins the compiled circuit down to its gate structure and every rotation angle, on every strategy and at every other setting, including eachparallel_mode.verbosity – How much the compiler prints:
"silent"(the default) prints nothing, then"summary","detailed"and"debug"each add the backend messages of the next level up.barrier – Whether to insert a
barrier()after every native entangler in the compiled circuit, for readability when drawing. A barrier separates each layer (single-qubit rotations plus an entangler) from the next, and the last layer from the closing single-qubit layer. It has no effect on synthesis, the native gate count or.metadata.
- Raises:
ConfigError – If a named choice is unknown, a trial count or
tolerance_erroris negative,seedis not a non-negative integer, orround_single_qubit_rotationsholds something other than a finite angle, or one angle twice.