Qx.Remote (Qx - Quantum Computing Simulator v0.5.0)

View Source

HTTP client for submitting quantum circuits to a QxServer instance.

Converts circuits to OpenQASM, submits them to the server, and returns results as Qx.SimulationResult structs.

Examples

config = Qx.Remote.Config.new!(
  url: "http://localhost:4040",
  api_key: "my-key"
)

circuit = Qx.create_circuit(2, 2)
  |> Qx.h(0)
  |> Qx.cx(0, 1)
  |> Qx.measure(0, 0)
  |> Qx.measure(1, 1)

# All-in-one: submit, wait, return result
{:ok, result} = Qx.Remote.run(circuit, config,
  backend: "ibm_fez",
  shots: 4096
)

# Or step-by-step
{:ok, job} = Qx.Remote.submit(circuit, config, backend: "ibm_fez")
{:ok, result} = Qx.Remote.await(job["job_id"], config)

Summary

Functions

Waits for a job to complete and returns the result as Qx.SimulationResult.

Cancels a running job.

Lists available backends.

Submits a circuit, polls until complete, and returns the result.

Gets the current status of a job.

Submits a circuit to the server (non-blocking).

Functions

await(job_id, config, opts \\ [])

@spec await(String.t(), Qx.Remote.Config.t(), keyword()) ::
  {:ok, Qx.SimulationResult.t()} | {:error, term()}

Waits for a job to complete and returns the result as Qx.SimulationResult.

Options

  • :on_status - Callback (status_map -> any) called on each poll
  • :poll_interval - Polling interval in ms (default: 2000)
  • :timeout - Max wait time in ms (default: config.timeout)
  • :req_options - Additional Req options

cancel(job_id, config, opts \\ [])

@spec cancel(String.t(), Qx.Remote.Config.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Cancels a running job.

Returns {:ok, map} with the cancellation response, or {:error, :not_found} if the job does not exist.

Examples

{:ok, _} = Qx.Remote.cancel(job_id, config)

list_backends(config, opts \\ [])

@spec list_backends(
  Qx.Remote.Config.t(),
  keyword()
) :: {:ok, [map()]} | {:error, term()}

Lists available backends.

Options

  • :provider - Filter by provider name
  • :req_options - Additional Req options

run(circuit, config, opts \\ [])

@spec run(Qx.QuantumCircuit.t(), Qx.Remote.Config.t(), keyword()) ::
  {:ok, Qx.SimulationResult.t()} | {:error, term()}

Submits a circuit, polls until complete, and returns the result.

Options

  • :backend - Backend name (required)
  • :shots - Number of shots (default: 4096)
  • :provider - Provider name (default: "ibm")
  • :options - Provider-specific options map
  • :on_status - Callback function (status_map -> any) called on each poll
  • :poll_interval - Polling interval in ms (default: 2000)
  • :req_options - Additional Req options (for testing)

status(job_id, config, opts \\ [])

@spec status(String.t(), Qx.Remote.Config.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Gets the current status of a job.

submit(circuit, config, opts \\ [])

@spec submit(Qx.QuantumCircuit.t(), Qx.Remote.Config.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Submits a circuit to the server (non-blocking).

Returns {:ok, map} where the map includes "job_id" and "status" fields.

Options

  • :backend - Backend name (required), e.g. "ibm_fez"
  • :shots - Number of shots (default: 4096)
  • :provider - Provider name (default: "ibm")
  • :options - Provider-specific options map
  • :req_options - Additional Req options (for testing)