Skip to content

Device Options

This page documents all parameters available when creating an openquantum.device.

Basic Usage

import pennylane as qml

dev = qml.device(
    "openquantum.device",
    wires=4,
    shots=1024,
    backend="ionq:forte-1",
)

Required Parameters

Parameter Type Description
wires int Number of qubits in the circuit.
shots int Number of measurement shots per circuit execution. Must be a positive integer.
backend str Backend short code identifying the target QPU (e.g., "ionq:forte-1").

Warning

shots=None (analytic mode) is not supported. Always specify a positive integer.

Authentication Parameters

Authentication can be provided via constructor parameters or environment variables. Constructor parameters take precedence.

Parameter Type Default Description
client_id str None SDK key Client ID. Falls back to OPENQUANTUM_CLIENT_ID environment variable.
client_secret str None SDK key Client Secret. Falls back to OPENQUANTUM_CLIENT_SECRET environment variable.

Cost Control and Cancellation

Before executing circuits, the device:

  1. Checks backend status — shows whether the target QPU is online, its queue depth, and lists alternatives if it is offline.
  2. Shows credit cost — prepares the first circuit to get a real quote, then displays the per-circuit and total cost.
  3. Prompts for confirmation (terminal only) — asks Proceed? [y/N]. In Jupyter notebooks, execution proceeds immediately after showing the cost.
  4. Live status updates — shows a spinner with job status. While the job is pending, you can interrupt (Ctrl+C or Jupyter stop button) to cancel it on the platform. Once queued, it can no longer be cancelled.
Parameter Type Default Description
auto_confirm bool False If True, skip the confirmation prompt (terminal) and backend-unavailable warnings. Cost and status are still printed to stdout.
# Default: shows cost, prompts in terminal
dev = qml.device("openquantum.device", wires=2, shots=1024, backend="ionq:forte-1")
# Output:
#   [Open Quantum] ● IonQ Forte-1 (ionq:forte-1): Online | queue: 0 job(s)
#   [Open Quantum] Batch: 1 circuit(s) × 2 credit(s) each = 2 credit(s) total
#   [Open Quantum] Proceed? [y/N]

# Skip prompts (recommended for iterative algorithms)
dev = qml.device("openquantum.device", wires=2, shots=1024, backend="ionq:forte-1",
                  auto_confirm=True)
# Output (no prompt):
#   [Open Quantum] ● IonQ Forte-1 (ionq:forte-1): Online | queue: 0 job(s)
#   [Open Quantum] Batch: 1 circuit(s) × 2 credit(s) each = 2 credit(s) total
#   [Open Quantum] Batch complete: 2 credits used in 15s (session total: 2)

You can check cumulative credits spent at any time:

print(dev.total_credits_used)  # e.g., 160

Cancelling in Jupyter

In Jupyter notebooks, the confirmation prompt is skipped (since input() can hang). Instead, you can cancel a pending job by pressing the stop button (⬜) or using Kernel > Interrupt. The device will attempt to cancel the job on the platform. Once the job moves to "Queued", it can no longer be cancelled.

Optional Parameters

Parameter Type Default Description
organization_id str None Organization UUID. Falls back to OPENQUANTUM_ORGANIZATION_ID environment variable. If not set, auto-detected from JWT claims.
execution_plan str "auto" Execution plan: "auto" selects the cheapest available plan.
queue_priority str "auto" Queue priority: "auto" selects standard priority.
job_subcategory_id str "oth:oth" Job subcategory short code.
job_timeout_seconds int 86400 Maximum time in seconds to wait for a job to complete.

Environment Variable Reference

Environment Variable Corresponding Parameter Description
OPENQUANTUM_CLIENT_ID client_id SDK key Client ID
OPENQUANTUM_CLIENT_SECRET client_secret SDK key Client Secret
OPENQUANTUM_ORGANIZATION_ID organization_id Organization UUID

Configuration Examples

Minimal (credentials from environment)

dev = qml.device(
    "openquantum.device",
    wires=2,
    shots=1024,
    backend="ionq:forte-1",
)

Explicit credentials

dev = qml.device(
    "openquantum.device",
    wires=4,
    shots=2048,
    backend="ionq:forte-1",
    client_id="s_abc123def456",
    client_secret="your_secret_here",
    organization_id="550e8400-e29b-41d4-a716-446655440000",
)

Auto-confirm for iterative algorithms

dev = qml.device(
    "openquantum.device",
    wires=2,
    shots=4096,
    backend="ionq:forte-1",
    auto_confirm=True,  # skip prompt on every VQE step
)