Types API¶
Public data types for the FastQSim SDK.
All classes are pure data containers populated from FastQubit API responses. No backend libraries (qiskit, cirq, pennylane) are imported here.
- class fastqsim.qtypes.Job(data, client=None)[source]¶
Bases:
objectRepresents a quantum simulation job submitted to the FastQSim platform.
Returned by FastQSimClient.run() and FastQSimClient.run_batch(). Call result() to block until completion and retrieve results, or use wait_for_completion() to poll and then inspect properties manually.
- Parameters:
data (Dict[str, Any])
client (Any)
- property billing_avg_memory_mb: float | None¶
average RSS memory usage in MB over execution.
- Type:
Billing telemetry
- property billing_cpu_millicore_seconds: float | None¶
integrated CPU usage in millicore-seconds.
- Type:
Billing telemetry
- property billing_memory_gb_seconds: float | None¶
integrated memory usage in GB-seconds.
- Type:
Billing telemetry
- property billing_memory_headroom_mb: float | None¶
memory headroom to pod limit in MB at completion.
- Type:
Billing telemetry
- property billing_psutil_available: bool | None¶
Whether psutil-based billing telemetry was available in the worker runtime.
- cancel()[source]¶
Request cancellation of a QUEUED or RUNNING job.
- Return type:
- Returns:
True if the cancellation was accepted.
- Raises:
JobCouldNotCancelError – Server rejected the cancellation request.
- property completed_at: datetime | None¶
When the worker finalized the terminal state in persistent storage.
- property cpu_seconds_total: float | None¶
Worker-reported process CPU time (user + system) consumed during execution.
- property error_message: str | None¶
Worker error message if the job failed. Contains the raw exception text from the Q-Pod (e.g. ParseError details).
- property execution_finished_at: datetime | None¶
Timestamp emitted by the q-worker after simulation and artifact upload.
- property execution_started_at: datetime | None¶
Timestamp emitted by the q-worker when simulation begins inside the pod.
- property execution_time_seconds: float | None¶
Worker-reported wall-clock execution duration in seconds.
- get_counts()[source]¶
Return measurement counts for a completed job.
- Raises:
JobNotCompleteError – Job has not finished yet.
JobDoesNotContainCountsError – Job was run without measurement shots.
- Return type:
- get_statevector()[source]¶
Retrieve the statevector for a completed job.
- Raises:
JobNotCompleteError – Job has not finished yet.
JobStatevectorTooLargeError – Statevector exceeds retrieval limit.
- Return type:
- property has_external_artifact: bool¶
True when the result was too large for inline storage and is persisted to S3. Use GET /jobs/{job_id}/result-url (client._fetch_external_artifact) to retrieve it.
- property num_qubits: int | None¶
Number of qubits in the circuit (from circuit profile). None until analyzer is wired.
- property options: Dict[str, Any]¶
Backend/device-specific execution options supplied at submission time.
- property peak_memory_mb: float | None¶
Worker-reported peak RSS memory usage in MB sampled during execution.
- property profile: Dict[str, Any]¶
Circuit complexity metrics extracted by the AST analyzer. Fields: qubit_count, depth, gate_count, two_qubit_gate_count. All None until the analyzer is implemented.
- property queue_dequeued_at: datetime | None¶
When the scheduler claimed the job and a worker pod was created.
- property queue_enqueued_at: datetime | None¶
When the job was accepted and published to the RabbitMQ queue.
- property resource_estimate: Dict[str, Any]¶
Predicted Kubernetes resource allocation for the worker pod. Fields: cpu_request, memory_request, cpu_limit, memory_limit. All None until adaptive sizing is implemented.
- result(timeout=None)[source]¶
Block until the job completes, then return the Result.
- Parameters:
timeout (
Optional[int]) – Maximum seconds to wait. Raises JobTimeoutError if exceeded.- Raises:
JobTimeoutError – Job did not complete within timeout.
JobFailedError – Job reached a failed terminal state.
- Return type:
- property result_counts: Dict[str, int] | None¶
Inline measurement counts (bit-string → count). Populated when job completes.
- property result_metadata: Dict[str, Any]¶
Additional result metadata emitted by the worker (backend name, simulation_type, engine version, etc.).
- property result_url_expires_at: datetime | None¶
Expiry of the last issued presigned result download URL.
- class fastqsim.qtypes.JobStatus(value)[source]¶
-
All possible states a FastQSim job can be in.
Terminal states: completed, failed, cancelled Non-terminal: created, queued, running
- CANCELLED = 'cancelled'¶
- COMPLETED = 'completed'¶
- CREATED = 'created'¶
- FAILED = 'failed'¶
- QUEUED = 'queued'¶
- RUNNING = 'running'¶
- class fastqsim.qtypes.Result(data)[source]¶
Bases:
objectSimulation results returned after a job reaches COMPLETED status.
Returned by Job.result() and Job.get_counts().
- Parameters:
data (Dict[str, Any])
- property counts: Dict[str, int]¶
512}.
- Type:
Measurement counts dictionary, e.g. {‘00’
- Type:
512, ‘11’
- property memory: List[str] | None¶
Individual shot results as bit-strings, e.g. [‘00’, ‘11’, ‘00’, …]. Only populated when the job was submitted with memory=True.
- class fastqsim.qtypes.RunArgs(circuit, backend='qiskit', device='cpu', shots=1024, simulation_type=None, seed=None, metadata=None, job_name=None, options=None, tags=None)[source]¶
Bases:
objectOptional helper to construct job submission arguments.
Can be passed to FastQSimClient.run() instead of keyword arguments. All fields mirror the run() parameters exactly.
- Parameters:
- class fastqsim.qtypes.Session(data, client=None)[source]¶
Bases:
objectRepresents a FastQubit session payload.
In pod-token SDK mode, session lifecycle operations are handled by the integrator control plane, so helper methods like refresh_token() and close() may raise ValidationError.
- Parameters:
data (Dict[str, Any])
client (Any)
- property already_active: bool | None¶
Present on POST /sessions/start responses only. True when an existing active session was returned because the per-user limit was already reached. False when a new session was provisioned.
- close()[source]¶
Terminate the session and release server-side resources.
Raises ValidationError in pod-token SDK mode.
- Return type:
- property execution_engine: str¶
Runtime engine used inside the user pod (e.g. ‘jupyter-kernel-gateway’).
- property expires_at: datetime | None¶
Hard TTL for this session. The pod is terminated after this time.
- property kernel_id: str | None¶
Jupyter kernel ID. Populated after the pod is ready. None for terminal sessions.
- property message: str | None¶
Human-readable note, e.g. instructions to terminate before starting a new session.
- refresh_token()[source]¶
Request a refreshed WebSocket authentication token from the server.
Raises ValidationError in pod-token SDK mode.
- Return type:
- class fastqsim.qtypes.SimulationType(value)[source]¶
-
The simulation method used by the Q-Pod backend.
Determines both the physics model and the resource footprint:
STATEVECTOR: Full state-vector sim. Memory ∝ 2^N. Supports all gates.
DENSITY_MATRIX: Open-system sim with noise. Memory ∝ 4^N. Supports all gates.
MPS: Matrix Product State. Memory ∝ N·χ². Best for low-entanglement circuits.
CHP: Stabilizer / Clifford. Memory ∝ N². Clifford gates only (H, CNOT, S, measure).
- CHP = 'chp'¶
- DENSITY_MATRIX = 'density_matrix'¶
- MPS = 'mps'¶
- STATEVECTOR = 'statevector'¶