Complete reference for the QBOM Python API.
The main module provides convenience functions for common operations.
Display the current trace in the terminal.
import qbom
# After running your quantum experiment...
qbom.show()Get the current or most recent trace.
trace = qbom.current()
print(trace.id)
print(trace.summary)Returns: Trace object
Export the current trace to a file.
# Export as JSON (default)
path = qbom.export("experiment.qbom.json")
# Export as CycloneDX
path = qbom.export("experiment.cdx.json", format="cyclonedx")
# Export as SPDX
path = qbom.export("experiment.spdx.json", format="spdx")Parameters:
path(str | Path): Output file pathformat(str): Export format - "json", "cyclonedx", "spdx", "yaml"
Returns: Path to the exported file
Context manager for scoped experiments.
with qbom.experiment("My Experiment", tags=["test"]) as exp:
# Your quantum code here
pass
# Trace is automatically savedParameters:
name(str, optional): Experiment namedescription(str, optional): Experiment descriptiontags(list[str], optional): Tags for categorization
Returns: TraceBuilder context
Represents a complete QBOM trace.
| Property | Type | Description |
|---|---|---|
id |
str | Unique trace identifier (e.g., "qbom_abc123") |
qbom_version |
str | QBOM format version |
created_at |
datetime | Trace creation timestamp |
environment |
Environment | Software environment |
circuits |
list[Circuit] | Captured circuits |
transpilation |
Transpilation | Transpilation details |
hardware |
Hardware | Hardware information |
execution |
Execution | Execution parameters |
result |
Result | Measurement results |
metadata |
Metadata | User-provided metadata |
summary |
str | Human-readable summary |
content_hash |
str | Content verification hash |
Export trace to file.
trace.export("output.json")
trace.export("output.cdx.json", format="cyclonedx")Display trace in terminal.
trace.show()Convert trace to dictionary.
data = trace.to_dict()Software environment information.
| Property | Type | Description |
|---|---|---|
python |
str | Python version |
platform |
str | Platform string |
packages |
list[Package] | Installed packages |
timestamp |
datetime | Capture timestamp |
quantum_sdk |
str | Primary quantum SDK |
Package information.
| Property | Type | Description |
|---|---|---|
name |
str | Package name |
version |
str | Package version |
purl |
str | Package URL (PURL format) |
Quantum circuit information.
| Property | Type | Description |
|---|---|---|
name |
str | Circuit name |
num_qubits |
int | Number of qubits |
num_clbits |
int | Number of classical bits |
depth |
int | Circuit depth |
gates |
GateCounts | Gate statistics |
hash |
str | Content hash |
qasm |
str | OpenQASM representation |
summary |
str | Human-readable summary |
Gate count statistics.
| Property | Type | Description |
|---|---|---|
single_qubit |
int | Single-qubit gate count |
two_qubit |
int | Two-qubit gate count |
total |
int | Total gate count |
by_name |
dict[str, int] | Counts by gate name |
Transpilation details.
| Property | Type | Description |
|---|---|---|
optimization_level |
int | Optimization level (0-3) |
basis_gates |
list[str] | Target basis gates |
seed |
int | Transpiler seed |
layout_method |
str | Layout method |
routing_method |
str | Routing method |
initial_layout |
QubitMapping | Initial qubit mapping |
final_layout |
QubitMapping | Final qubit mapping |
input_circuit |
Circuit | Pre-transpilation circuit |
output_circuit |
Circuit | Post-transpilation circuit |
depth_increase |
float | Depth ratio (output/input) |
Hardware information.
| Property | Type | Description |
|---|---|---|
provider |
str | Provider name |
backend |
str | Backend name |
num_qubits |
int | Total qubit count |
qubits_used |
list[int] | Physical qubits used |
is_simulator |
bool | Whether backend is simulator |
calibration |
Calibration | Calibration data |
summary |
str | Human-readable summary |
Hardware calibration snapshot.
| Property | Type | Description |
|---|---|---|
timestamp |
datetime | Calibration timestamp |
qubits |
list[QubitProperties] | Per-qubit properties |
gates |
list[GateProperties] | Per-gate properties |
Per-qubit calibration data.
| Property | Type | Description |
|---|---|---|
index |
int | Qubit index |
t1_us |
float | T1 time in microseconds |
t2_us |
float | T2 time in microseconds |
readout_error |
float | Readout error rate |
frequency_ghz |
float | Qubit frequency in GHz |
Per-gate calibration data.
| Property | Type | Description |
|---|---|---|
gate |
str | Gate name |
qubits |
tuple[int, ...] | Qubits involved |
error |
float | Gate error rate |
duration_ns |
float | Gate duration in nanoseconds |
Execution parameters.
| Property | Type | Description |
|---|---|---|
job_id |
str | Job identifier |
shots |
int | Number of shots |
submitted_at |
datetime | Submission time |
completed_at |
datetime | Completion time |
Measurement results.
| Property | Type | Description |
|---|---|---|
counts |
Counts | Measurement counts |
metadata |
dict | Additional metadata |
hash |
str | Result verification hash |
Measurement count statistics.
| Property | Type | Description |
|---|---|---|
raw |
dict[str, int] | Raw count dictionary |
shots |
int | Total shots |
probabilities |
dict[str, float] | Probability distribution |
top_results |
list[tuple] | Top results by probability |
Analysis tools for traces.
Calculate reproducibility score.
from qbom.analysis import calculate_score
result = calculate_score(trace)
print(f"Score: {result.total_score}/100")
print(f"Grade: {result.grade}")Returns: ScoreResult
Validate trace completeness.
from qbom.analysis import validate_trace
result = validate_trace(trace)
result = validate_trace(trace, publication=True) # StricterReturns: ValidationResult
Analyze calibration drift.
from qbom.analysis import analyze_drift
result = analyze_drift(trace)
print(f"Drift: {result.drift_score}")Returns: DriftResult
Session management.
Get the global session instance.
from qbom.core.session import Session
session = Session.get()List recent traces.
traces = session.list_traces(limit=10)- Usage Guide - Usage examples
- CLI Reference - Command-line interface