Before executing a quantum program, you can estimate the cost using estimate_sample_cost and estimate_sample_batch_cost. These functions return a CostEstimateResult with cost (in USD) and currency fields.Cost estimation is supported for all quantum providers that Classiq integrates with. Each provider uses its own pricing model.
Basic Usage
Single Sample Cost
Use estimate_sample_cost to estimate the cost of sampling a quantum program with given execution preferences:
Cost estimation works with the same backend preferences you use for execution. Configure the backend for your target provider and pass it to the estimation functions.
Classiq Simulators
Classiq simulators support cost estimation without provider credentials.
from classiq import ( ClassiqBackendPreferences, ClassiqSimulatorBackendNames, ExecutionPreferences, estimate_sample_cost,)# All Classiq simulators are supportedbackends = [ ClassiqSimulatorBackendNames.SIMULATOR, ClassiqSimulatorBackendNames.SIMULATOR_STATEVECTOR, ClassiqSimulatorBackendNames.SIMULATOR_DENSITY_MATRIX, ClassiqSimulatorBackendNames.SIMULATOR_MATRIX_PRODUCT_STATE,]for backend_name in backends: prefs = ExecutionPreferences( num_shots=100, backend_preferences=ClassiqBackendPreferences(backend_name=backend_name), ) result = estimate_sample_cost(qprog, prefs) print(f"{backend_name}: {result.cost} {result.currency}")
Amazon Braket
Cost estimation supports both Braket simulators (SV1, TN1, dm1) and QPUs (e.g., Aspen-11, Lucy).