Haiqu.pretrain(problem, *, max_time=60, seed=42, initial_parameters=None, name=None, description=None)
Pretrain parameters for a variational quantum circuit to minimize the expectation value of input observable. Accepts either a linearVariationalProblem (minimize a single observable’s expectation) or a
NonlinearVariationalProblem (minimize a sympy objective over several named observables, whose
terms may include the 0/1 projector symbols). A linear problem is treated internally as the
trivial objective "x" over its single observable.
- Parameters:
- problem (VariationalProblem | NonlinearVariationalProblem) — problem instance containing the ansatz circuit and either a single observable (linear) or a loss expression with named observables (nonlinear).
- max_time (float) — maximal time (in seconds) the pretraining can take. If this time exceeds (not counting initialization and other overheads), then the current best result is returned. Defaults to 1 minute. Current maximal pretraining time is 15 minutes.
- seed (int *|*None) — a seed for initial random initialization of weights. They are chosen from uniform distribution in the interval [-π,π). Defaults to 42.
- initial_parameters (list *[*float ] *|*None) — if specified, then these weights are used instead of random ones. Defaults to None.
- name (str *|*None) — optional name of the job. If not set, then automatic will be generated.
- description (str *|*None) — optional description of the job. If not set, then automatic will be generated.
- Returns:
Job handle to track pretraining progress and retrieve results.
: Call
job.result()to retrieve the pretrained ansatz parameters as alist[float](one entry per parameter in the inputVariationalProblem.ansatz), suitable for use asparametersinrun()or asinitial_parametersinvariational_optimization(). Runhelp(job.result)for the full description of result andinfocontents. - Return type: PretrainingJobModel
Examples
0/1 projectors):