Skip to main content
POST
/
variational
Variational
curl --request POST \
  --url 'https://api.example.com/variational?HAIQU_API_KEY=' \
  --header 'Content-Type: application/json' \
  --data '
{
  "experiment_id": "<string>",
  "circuit_id": "<string>",
  "observable": [
    [
      "<string>"
    ],
    [
      123
    ]
  ],
  "device_id": "<string>",
  "shots": 1000,
  "options": {},
  "initial_parameters": [
    123
  ],
  "optimizer_options": {
    "randomized_order": false,
    "reset_interval": 32,
    "maxfev": 1024,
    "maxiter": 500,
    "eps": 1e-32
  },
  "use_mitigation": false,
  "name": "",
  "description": ""
}
'
{
  "id": "<string>",
  "user_id": 123,
  "experiment_id": "<string>",
  "status": "Submitted",
  "job_type": "User local job",
  "device_id": "<string>",
  "creation_date": "2023-11-07T05:31:56Z",
  "circuit_id": "<string>",
  "observable": [
    [
      "<string>"
    ],
    [
      123
    ]
  ],
  "shots": 123,
  "name": "<string>",
  "description": "<string>",
  "run_date": "2023-11-07T05:31:56Z",
  "finish_date": "2023-11-07T05:31:56Z",
  "logs": "<string>",
  "quality": 123,
  "info": {},
  "time": 123,
  "options": {},
  "optimizer_options": {},
  "use_mitigation": false,
  "optimal_parameters": [
    123
  ],
  "min_loss": 123,
  "loss_history": [
    123
  ]
}

Authorizations

HAIQU_API_KEY
string
query
required

Body

application/json

Submit model for variational problem execution.

experiment_id
string
required
circuit_id
string
required
observable
Observable · tuple
required
device_id
string
required
shots
integer
default:1000
options
Options · object
initial_parameters
number[] | null
optimizer_options
NFTOptimizerOptions · object

Configuration options for the NFT (Nakanishi-Fujii-Todo) optimizer.

The NFT algorithm is a gradient-free optimizer designed for variational quantum algorithms. For detailed information about the algorithm, see the paper: https://arxiv.org/abs/1903.12166

Preconditions: NFT requires the following conditions on the parameterized quantum circuit:

1. Parameters must be independent: each parameter must appear in exactly one
   gate (no reusing the same parameter across multiple gates).

2. Parameterized gates must be rotations of the form ``R_j(θ_j) = exp(-i*θ_j*A_j/2)``
   where ``A_j² = I`` (e.g., RX, RY, RZ gates satisfy this).

3. The cost function must be a sum of expectation values of Hermitian operators:
   ``L(θ) = Σ_k w_k ⟨ψ_k|U†(θ) H_k U(θ)|ψ_k⟩``.

Scaling: NFT updates one parameter at a time. Each full sweep through N parameters requires ≥2N function evaluations (depending on reset_interval).

Args: randomized_order: If True, shuffles the order of parameters to update each lap (full sweep through all parameters). Default: False. reset_interval: How often to reset the recycled loss value. Set to 0 to disable resets. Default: 32. maxfev: Maximum number of function evaluations (circuit executions). Optimization stops when this limit is reached. Default: 1024. maxiter: Maximum number of iterations (parameter updates). Default: 500. eps: Small epsilon value to avoid division by zero in the analytic solution. Default: 1e-32.

Notes: Stopping criterion: Optimization stops when either maxfev or maxiter is reached, whichever comes first.

Function evaluations per iteration: Each iteration uses 2-3 function
evaluations. The very first iteration and the first iteration of each
reset interval use 3 evaluations. Subsequent iterations reuse the
previous optimal value, requiring only 2 evaluations.

Example: >>> from haiqu.sdk.qml import NFTOptimizerOptions >>> optimizer = NFTOptimizerOptions(maxfev=2048, maxiter=100)

use_mitigation
boolean
default:false
name
string | null
default:""
description
string | null
default:""

Response

Successful Response

Job returned for variational problem execution.

id
string
required
user_id
integer
required
experiment_id
string
required
status
enum<string>
required

Class for job status.

Available options:
Submitted,
Initializing,
Queued,
Validating,
Running,
Cancelled,
Done,
Error
job_type
enum<string>
required

Class for job types.

Available options:
User local job,
Analytics,
Device specific analytics,
Data Loading,
Run,
State Compression,
Transpilation,
Variational,
Pretraining,
SKQD
device_id
string
required
creation_date
string<date-time>
required
circuit_id
string
required
observable
Observable · tuple
required
shots
integer
required
name
string | null
description
string | null
run_date
string<date-time> | null
finish_date
string<date-time> | null
logs
string | null
quality
number | null
info
Info · object
time
number | null
options
Options · object
optimizer_options
Optimizer Options · object
use_mitigation
boolean
default:false
optimal_parameters
number[] | null
min_loss
number | null
loss_history
number[] | null