Postprocess Skqd Samples
Diagonalize a molecular Hamiltonian in the subspace spanned by measured samples.
Use this tool to turn sampled bitstrings from a chemistry circuit into an energy estimate. Haiqu builds a configuration subspace from the samples and diagonalizes the Hamiltonian within it, which recovers accuracy that raw sampling loses to noise.
When to Use:
- Call this after a sampling run of a chemistry ansatz when the user wants a ground-state energy rather than a measurement distribution.
- Call this with
run_job_idpointing at the run job that produced the samples, so the counts never pass through the tool call.
Constraints:
- Provide exactly one of
resultsorrun_job_id. h1emust benorbxnorbandh2emust be a rank-4norbarray; mismatched shapes are rejected with422.norbabove 12 is rejected becauseh2egrows asnorb**4. Use the Haiqu SDK for larger active spaces.- The job is asynchronous and billable. Poll with
get_job_results_and_status.
Notes:
- Integrals must come from the same orbital basis and ordering as the circuit that produced the samples, otherwise the energy is meaningless.
num_shotsis inferred from the referenced run job when omitted.
Args: user: Authenticated user resolved from the API key. data: Integrals, active-space sizes, and inline results or a job reference. db: Active database session.
Returns: The created job identifier with the next polling step.
Raises:
HTTPException: Raised with 400 when neither or both result inputs are
given, 402 when the caller cannot submit billable jobs, 404 when
the experiment or referenced job is unavailable, 409 when the
referenced job has no results, or 422 on shape or size violations.
Authorizations
Body
Define payload for a sample-based quantum diagonalization job.
Attributes:
experiment_id: Parent experiment identifier.
h1e: One-body integrals, shape (norb, norb).
h2e: Two-body integrals, shape (norb, norb, norb, norb).
norb: Number of spatial orbitals.
nelec: Alpha and beta electron counts.
results: Measured bitstring counts per batch.
run_job_id: Run job whose stored results supply results.
num_shots: Shots behind the supplied results.
name: Optional job name.
params: Optional diagonalization parameter overrides.
One-body integrals as a norb x norb matrix.
Two-body integrals as a rank-4 norb array. This grows as norb**4, so prefer small active spaces when calling through a tool; use the SDK for large ones.
Number of spatial orbitals.
x >= 1Alpha and beta electron counts as [n_alpha, n_beta].
Measured bitstring counts per batch. Provide this or run_job_id, not both.
Run job whose stored measurement results are used as results, so large count dictionaries never have to be passed inline. Provide this or results.
Shots behind the supplied results. Derived from the run job when run_job_id is used.
Optional overrides: samples_per_batch, num_batches, max_iterations, symmetrize_spin, configuration_recovery, seed.
Response
Successful Response
Represent the outcome of a job lifecycle action such as cancel or restart.
Attributes: job_id: Identifier of the affected job. status: Job status after the action was applied. context: Summary of what changed and the recommended next step.