classiq 0.100.0__py3-none-any.whl → 0.102.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- classiq/__init__.py +3 -0
- classiq/_internals/api_wrapper.py +29 -4
- classiq/applications/chemistry/op_utils.py +31 -1
- classiq/applications/chemistry/problems.py +18 -6
- classiq/applications/chemistry/ucc.py +2 -2
- classiq/evaluators/parameter_types.py +1 -4
- classiq/evaluators/qmod_node_evaluators/utils.py +6 -3
- classiq/execution/__init__.py +11 -1
- classiq/execution/jobs.py +122 -5
- classiq/interface/_version.py +1 -1
- classiq/interface/exceptions.py +0 -42
- classiq/interface/executor/execution_request.py +1 -0
- classiq/interface/executor/quantum_code.py +0 -6
- classiq/interface/generator/generation_request.py +9 -4
- classiq/interface/generator/quantum_program.py +8 -36
- classiq/interface/helpers/model_normalizer.py +24 -0
- classiq/interface/helpers/text_utils.py +17 -6
- classiq/interface/model/invert.py +7 -0
- classiq/interface/model/model.py +42 -3
- classiq/interface/model/quantum_function_call.py +17 -5
- classiq/model_expansions/interpreters/base_interpreter.py +3 -2
- classiq/model_expansions/visitors/uncomputation_signature_inference.py +15 -38
- classiq/open_library/functions/__init__.py +42 -27
- classiq/open_library/functions/bit_operations.py +30 -0
- classiq/open_library/functions/modular_arithmetics.py +597 -0
- classiq/open_library/functions/qft_space_arithmetics.py +81 -0
- classiq/open_library/functions/state_preparation.py +6 -3
- classiq/open_library/functions/utility_functions.py +22 -3
- classiq/qmod/builtins/functions/exponentiation.py +2 -2
- classiq/qmod/builtins/operations.py +29 -4
- classiq/qmod/native/pretty_printer.py +15 -4
- classiq/qmod/pretty_print/pretty_printer.py +14 -2
- classiq/qmod/quantum_callable.py +8 -2
- classiq/qmod/quantum_expandable.py +3 -1
- classiq/qmod/quantum_function.py +2 -1
- classiq/qmod/utilities.py +7 -4
- classiq/synthesis_action/__init__.py +20 -0
- classiq/synthesis_action/actions.py +106 -0
- {classiq-0.100.0.dist-info → classiq-0.102.0.dist-info}/METADATA +1 -1
- {classiq-0.100.0.dist-info → classiq-0.102.0.dist-info}/RECORD +42 -40
- classiq/interface/executor/register_initialization.py +0 -36
- classiq/open_library/functions/modular_exponentiation.py +0 -272
- classiq/open_library/functions/qsvt_temp.py +0 -536
- {classiq-0.100.0.dist-info → classiq-0.102.0.dist-info}/WHEEL +0 -0
- {classiq-0.100.0.dist-info → classiq-0.102.0.dist-info}/licenses/LICENSE.txt +0 -0
classiq/__init__.py
CHANGED
|
@@ -68,6 +68,8 @@ from classiq.synthesis import (
|
|
|
68
68
|
update_execution_preferences,
|
|
69
69
|
update_preferences,
|
|
70
70
|
)
|
|
71
|
+
from classiq.synthesis_action import * # noqa: F403
|
|
72
|
+
from classiq.synthesis_action import __all__ as _synthesis_all
|
|
71
73
|
|
|
72
74
|
_application_constructors_all = [
|
|
73
75
|
"construct_combinatorial_optimization_model",
|
|
@@ -124,6 +126,7 @@ __all__ = (
|
|
|
124
126
|
+ _application_constructors_all
|
|
125
127
|
+ _qmod_all
|
|
126
128
|
+ _execution_all
|
|
129
|
+
+ _synthesis_all
|
|
127
130
|
+ _open_library_all
|
|
128
131
|
+ _be_all
|
|
129
132
|
)
|
|
@@ -20,6 +20,7 @@ from classiq.interface.executor.quantum_program_params import (
|
|
|
20
20
|
)
|
|
21
21
|
from classiq.interface.executor.user_budget import UserBudget
|
|
22
22
|
from classiq.interface.generator import quantum_program as generator_result
|
|
23
|
+
from classiq.interface.generator.generation_request import SynthesisActionsQueryResults
|
|
23
24
|
from classiq.interface.generator.preferences.qasm_to_qmod_params import QasmToQmodParams
|
|
24
25
|
from classiq.interface.hardware import HardwareInformation, Provider
|
|
25
26
|
from classiq.interface.ide.visual_model import ProgramVisualModel
|
|
@@ -321,18 +322,42 @@ class ApiWrapper:
|
|
|
321
322
|
offset: int,
|
|
322
323
|
limit: int,
|
|
323
324
|
http_client: httpx.AsyncClient | None = None,
|
|
325
|
+
**extra_query_params: Any,
|
|
324
326
|
) -> execution_request.ExecutionJobsQueryResults:
|
|
327
|
+
params: dict[str, Any] = {
|
|
328
|
+
"offset": offset,
|
|
329
|
+
"limit": limit,
|
|
330
|
+
}
|
|
331
|
+
params.update(extra_query_params)
|
|
325
332
|
data = await cls._call_task(
|
|
326
333
|
http_method=HTTPMethod.GET,
|
|
327
334
|
url=f"{routes.EXECUTION_JOBS_FULL_PATH}",
|
|
328
|
-
params=
|
|
329
|
-
"offset": offset,
|
|
330
|
-
"limit": limit,
|
|
331
|
-
},
|
|
335
|
+
params=params,
|
|
332
336
|
http_client=http_client,
|
|
333
337
|
)
|
|
334
338
|
return execution_request.ExecutionJobsQueryResults.model_validate(data)
|
|
335
339
|
|
|
340
|
+
@classmethod
|
|
341
|
+
async def call_query_synthesis_actions(
|
|
342
|
+
cls,
|
|
343
|
+
offset: int,
|
|
344
|
+
limit: int,
|
|
345
|
+
http_client: httpx.AsyncClient | None = None,
|
|
346
|
+
**extra_query_params: Any | None,
|
|
347
|
+
) -> SynthesisActionsQueryResults:
|
|
348
|
+
params: dict[str, Any] = {
|
|
349
|
+
"offset": offset,
|
|
350
|
+
"limit": limit,
|
|
351
|
+
}
|
|
352
|
+
params.update(extra_query_params)
|
|
353
|
+
data = await cls._call_task(
|
|
354
|
+
http_method=HTTPMethod.GET,
|
|
355
|
+
url=f"{routes.TASKS_GENERATE_FULL_PATH}",
|
|
356
|
+
params=params,
|
|
357
|
+
http_client=http_client,
|
|
358
|
+
)
|
|
359
|
+
return SynthesisActionsQueryResults.model_validate(data)
|
|
360
|
+
|
|
336
361
|
@classmethod
|
|
337
362
|
async def call_analysis_task(
|
|
338
363
|
cls,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from typing import cast
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
4
5
|
from openfermion.ops.operators.qubit_operator import QubitOperator
|
|
5
6
|
from openfermion.utils.operator_utils import count_qubits
|
|
6
7
|
|
|
7
|
-
from classiq.interface.exceptions import ClassiqValueError
|
|
8
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqValueError
|
|
8
9
|
|
|
9
10
|
from classiq.qmod.builtins.enums import Pauli
|
|
10
11
|
from classiq.qmod.builtins.structs import IndexedPauli, SparsePauliOp, SparsePauliTerm
|
|
@@ -25,6 +26,13 @@ def _get_n_qubits(qubit_op: QubitOperator, n_qubits: int | None) -> int:
|
|
|
25
26
|
def qubit_op_to_pauli_terms(
|
|
26
27
|
qubit_op: QubitOperator, n_qubits: int | None = None
|
|
27
28
|
) -> SparsePauliOp:
|
|
29
|
+
warnings.warn(
|
|
30
|
+
"The function 'qubit_op_to_pauli_terms' is deprecated due to incorrect order "
|
|
31
|
+
"of qubits in its result. It will no longer be supported starting on 2026-01-22 "
|
|
32
|
+
"at the earliest. Please use 'qubit_op_to_qmod' instead.",
|
|
33
|
+
ClassiqDeprecationWarning,
|
|
34
|
+
stacklevel=2,
|
|
35
|
+
)
|
|
28
36
|
n_qubits = _get_n_qubits(qubit_op, n_qubits)
|
|
29
37
|
return SparsePauliOp(
|
|
30
38
|
terms=[
|
|
@@ -44,6 +52,28 @@ def qubit_op_to_pauli_terms(
|
|
|
44
52
|
)
|
|
45
53
|
|
|
46
54
|
|
|
55
|
+
def qubit_op_to_qmod(
|
|
56
|
+
qubit_op: QubitOperator, n_qubits: int | None = None
|
|
57
|
+
) -> SparsePauliOp:
|
|
58
|
+
n_qubits = _get_n_qubits(qubit_op, n_qubits)
|
|
59
|
+
return SparsePauliOp(
|
|
60
|
+
terms=[
|
|
61
|
+
SparsePauliTerm(
|
|
62
|
+
paulis=[ # type:ignore[arg-type]
|
|
63
|
+
IndexedPauli(
|
|
64
|
+
pauli=getattr(Pauli, pauli),
|
|
65
|
+
index=qubit,
|
|
66
|
+
)
|
|
67
|
+
for qubit, pauli in term
|
|
68
|
+
],
|
|
69
|
+
coefficient=coeff,
|
|
70
|
+
)
|
|
71
|
+
for term, coeff in qubit_op.terms.items()
|
|
72
|
+
],
|
|
73
|
+
num_qubits=n_qubits,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
47
77
|
_PAULIS_TO_XZ = {"I": (0, 0), "X": (1, 0), "Z": (0, 1), "Y": (1, 1)}
|
|
48
78
|
_XZ_TO_PAULIS = {(0, 0): "I", (1, 0): "X", (0, 1): "Z", (1, 1): "Y"}
|
|
49
79
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from collections.abc import Sequence
|
|
2
3
|
from typing import cast
|
|
3
4
|
|
|
@@ -9,7 +10,7 @@ from openfermion.transforms import (
|
|
|
9
10
|
)
|
|
10
11
|
from openfermion.utils import count_qubits
|
|
11
12
|
|
|
12
|
-
from classiq.interface.exceptions import ClassiqValueError
|
|
13
|
+
from classiq.interface.exceptions import ClassiqDeprecationWarning, ClassiqValueError
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class FermionHamiltonianProblem:
|
|
@@ -21,7 +22,7 @@ class FermionHamiltonianProblem:
|
|
|
21
22
|
Attributes:
|
|
22
23
|
fermion_hamiltonian (FermionOperator): The fermionic hamiltonian of the problem.
|
|
23
24
|
Assumed to be in the block-spin labeling.
|
|
24
|
-
n_orbitals (int): Number of spatial
|
|
25
|
+
n_orbitals (int): Number of spatial orbitals.
|
|
25
26
|
n_alpha (int): Number of alpha particles.
|
|
26
27
|
n_beta (int): Number of beta particles.
|
|
27
28
|
n_particles (tuple[int, int]): Number of alpha and beta particles.
|
|
@@ -116,6 +117,7 @@ class FermionHamiltonianProblem:
|
|
|
116
117
|
molecule: MolecularData,
|
|
117
118
|
first_active_index: int = 0,
|
|
118
119
|
remove_orbitlas: Sequence[int] | None = None,
|
|
120
|
+
remove_orbitals: Sequence[int] | None = None,
|
|
119
121
|
op_compression_tol: float = 1e-13,
|
|
120
122
|
) -> "FermionHamiltonianProblem":
|
|
121
123
|
"""
|
|
@@ -125,12 +127,22 @@ class FermionHamiltonianProblem:
|
|
|
125
127
|
molecule (MolecularData): The molecule data.
|
|
126
128
|
first_active_index (int): The first active index, indicates all prior
|
|
127
129
|
indices are freezed.
|
|
128
|
-
|
|
130
|
+
remove_orbitals (Sequence[int], optional): Active indices to be removed.
|
|
129
131
|
op_compression_tol (float): Tolerance for trimming the fermion operator.
|
|
130
132
|
|
|
131
133
|
Returns:
|
|
132
134
|
The fermion hamiltonian problem.
|
|
133
135
|
"""
|
|
136
|
+
if remove_orbitlas is not None:
|
|
137
|
+
warnings.warn(
|
|
138
|
+
"The `remove_orbitlas` parameter is deprecated and will not longer be "
|
|
139
|
+
"supported starting on 2026-01-15 at the earliest. Use the "
|
|
140
|
+
"'remove_orbitals' parameter instead",
|
|
141
|
+
ClassiqDeprecationWarning,
|
|
142
|
+
stacklevel=2,
|
|
143
|
+
)
|
|
144
|
+
remove_orbitals = remove_orbitlas
|
|
145
|
+
|
|
134
146
|
if molecule.n_orbitals is None:
|
|
135
147
|
raise ClassiqValueError(
|
|
136
148
|
"The molecular data is not populated. Hint: call `run_pyscf` with the molecule."
|
|
@@ -145,8 +157,8 @@ class FermionHamiltonianProblem:
|
|
|
145
157
|
|
|
146
158
|
freezed_indices = list(range(first_active_index))
|
|
147
159
|
active_indices = list(range(first_active_index, molecule.n_orbitals))
|
|
148
|
-
if
|
|
149
|
-
active_indices = list(set(active_indices) - set(
|
|
160
|
+
if remove_orbitals:
|
|
161
|
+
active_indices = list(set(active_indices) - set(remove_orbitals))
|
|
150
162
|
|
|
151
163
|
molecular_hamiltonian = molecule.get_molecular_hamiltonian(
|
|
152
164
|
occupied_indices=freezed_indices,
|
|
@@ -167,7 +179,7 @@ class FermionHamiltonianProblem:
|
|
|
167
179
|
f"and {n_particles} electrons. "
|
|
168
180
|
f"This can happen if too many orbitals were frozen."
|
|
169
181
|
f"Before freezing number of particle was ({n_alpha, n_beta})."
|
|
170
|
-
f"Consider adjusting `first_active_index` or `
|
|
182
|
+
f"Consider adjusting `first_active_index` or `remove_orbitals` "
|
|
171
183
|
f"to ensure the active space is non-empty."
|
|
172
184
|
)
|
|
173
185
|
|
|
@@ -6,7 +6,7 @@ from openfermion.ops.operators.fermion_operator import FermionOperator
|
|
|
6
6
|
from openfermion.ops.operators.qubit_operator import QubitOperator
|
|
7
7
|
|
|
8
8
|
from classiq.applications.chemistry.mapping import FermionToQubitMapper
|
|
9
|
-
from classiq.applications.chemistry.op_utils import
|
|
9
|
+
from classiq.applications.chemistry.op_utils import qubit_op_to_qmod
|
|
10
10
|
from classiq.applications.chemistry.problems import FermionHamiltonianProblem
|
|
11
11
|
from classiq.qmod.builtins.structs import (
|
|
12
12
|
SparsePauliOp,
|
|
@@ -44,7 +44,7 @@ def get_ucc_hamiltonians(
|
|
|
44
44
|
|
|
45
45
|
n_qubits = mapper.get_num_qubits(problem)
|
|
46
46
|
return [
|
|
47
|
-
|
|
47
|
+
qubit_op_to_qmod(q_op, n_qubits)
|
|
48
48
|
for f_op in f_ops
|
|
49
49
|
if (q_op := mapper.map(f_op))
|
|
50
50
|
not in (
|
|
@@ -133,9 +133,6 @@ def _evaluate_type_from_arg(
|
|
|
133
133
|
# FIXME: Remove suzuki_trotter overloading (CLS-2912)
|
|
134
134
|
if closure.name == "suzuki_trotter" and parameter.name == "pauli_operator":
|
|
135
135
|
return parameter
|
|
136
|
-
# FIXME: Remove qdrift overloading (CLS-4347)
|
|
137
|
-
if closure.name == "qdrift" and parameter.name == "pauli_operator":
|
|
138
|
-
return parameter
|
|
139
136
|
if isinstance(parameter, ClassicalParameterDeclaration):
|
|
140
137
|
return _evaluate_classical_type_from_arg(parameter, argument, closure)
|
|
141
138
|
if isinstance(parameter, PortDeclaration):
|
|
@@ -257,7 +254,7 @@ def _evaluate_op_type_from_arg(
|
|
|
257
254
|
first_lambda = arg_val[0]
|
|
258
255
|
if isinstance(first_lambda, FunctionClosure):
|
|
259
256
|
_raise_argument_type_error(
|
|
260
|
-
arg_val,
|
|
257
|
+
f"[{', '.join(['<lambda>'] * len(arg_val))}]",
|
|
261
258
|
first_lambda.as_operand_declaration(is_list=True),
|
|
262
259
|
parameter.name,
|
|
263
260
|
parameter,
|
|
@@ -2,7 +2,10 @@ from typing import Union, cast
|
|
|
2
2
|
|
|
3
3
|
import sympy
|
|
4
4
|
|
|
5
|
-
from classiq.interface.exceptions import
|
|
5
|
+
from classiq.interface.exceptions import (
|
|
6
|
+
ClassiqExpansionError,
|
|
7
|
+
ClassiqInternalExpansionError,
|
|
8
|
+
)
|
|
6
9
|
from classiq.interface.generator.functions.classical_type import (
|
|
7
10
|
Bool,
|
|
8
11
|
ClassicalArray,
|
|
@@ -108,7 +111,7 @@ def get_sympy_val(val: sympy.Basic) -> bool | int | float | complex:
|
|
|
108
111
|
hasattr(val, "is_imaginary") and val.is_imaginary
|
|
109
112
|
):
|
|
110
113
|
return complex(val)
|
|
111
|
-
raise
|
|
114
|
+
raise ClassiqExpansionError(f"{str(val)!r} is not a number")
|
|
112
115
|
|
|
113
116
|
|
|
114
117
|
def get_sympy_type(val: sympy.Basic) -> ClassicalType:
|
|
@@ -124,4 +127,4 @@ def get_sympy_type(val: sympy.Basic) -> ClassicalType:
|
|
|
124
127
|
or (hasattr(val, "is_imaginary") and val.is_imaginary)
|
|
125
128
|
):
|
|
126
129
|
return Real()
|
|
127
|
-
raise
|
|
130
|
+
raise ClassiqExpansionError(f"{str(val)!r} is not a number")
|
classiq/execution/__init__.py
CHANGED
|
@@ -8,7 +8,14 @@ from ..interface.executor.execution_preferences import __all__ as _ep_all
|
|
|
8
8
|
from ..interface.executor.result import ExecutionDetails
|
|
9
9
|
from ..interface.executor.vqe_result import VQESolverResult
|
|
10
10
|
from .execution_session import ExecutionSession
|
|
11
|
-
from .jobs import
|
|
11
|
+
from .jobs import (
|
|
12
|
+
ExecutionJob,
|
|
13
|
+
ExecutionJobFilters,
|
|
14
|
+
get_execution_actions,
|
|
15
|
+
get_execution_actions_async,
|
|
16
|
+
get_execution_jobs,
|
|
17
|
+
get_execution_jobs_async,
|
|
18
|
+
)
|
|
12
19
|
from .qnn import execute_qnn
|
|
13
20
|
from .user_budgets import (
|
|
14
21
|
clear_budget_limit,
|
|
@@ -28,6 +35,9 @@ __all__ = (
|
|
|
28
35
|
"VQESolverResult",
|
|
29
36
|
"IQAEResult",
|
|
30
37
|
"ExecutionJob",
|
|
38
|
+
"ExecutionJobFilters",
|
|
39
|
+
"get_execution_actions",
|
|
40
|
+
"get_execution_actions_async",
|
|
31
41
|
"get_execution_jobs",
|
|
32
42
|
"get_execution_jobs_async",
|
|
33
43
|
"ExecutionSession",
|
classiq/execution/jobs.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
import webbrowser
|
|
3
|
+
from dataclasses import asdict, dataclass
|
|
3
4
|
from datetime import datetime
|
|
4
|
-
from typing import Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
import pandas as pd
|
|
5
9
|
from urllib.parse import urljoin
|
|
6
10
|
|
|
7
11
|
import httpx
|
|
@@ -29,6 +33,10 @@ from classiq._internals.async_utils import syncify_function
|
|
|
29
33
|
from classiq._internals.client import client
|
|
30
34
|
from classiq._internals.jobs import JobID, JobPoller
|
|
31
35
|
|
|
36
|
+
TOTAL_COST = "total_cost"
|
|
37
|
+
CURRENCY_CODE = "currency_code"
|
|
38
|
+
COST = "cost"
|
|
39
|
+
|
|
32
40
|
|
|
33
41
|
class ClassiqExecutionResultError(ClassiqError):
|
|
34
42
|
def __init__(self, primitive: str) -> None:
|
|
@@ -37,6 +45,42 @@ class ClassiqExecutionResultError(ClassiqError):
|
|
|
37
45
|
)
|
|
38
46
|
|
|
39
47
|
|
|
48
|
+
@dataclass
|
|
49
|
+
class ExecutionJobFilters:
|
|
50
|
+
"""
|
|
51
|
+
Filter parameters for querying execution jobs.
|
|
52
|
+
|
|
53
|
+
All filters are combined using AND logic: only jobs matching all specified filters are returned.
|
|
54
|
+
Range filters (with _min/_max suffixes) are inclusive.
|
|
55
|
+
Datetime filters are compared against the job's timestamps.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
id: str | None = None # Exact match on job ID
|
|
59
|
+
session_id: str | None = None # Exact match on session ID
|
|
60
|
+
status: JobStatus | None = (
|
|
61
|
+
None # Exact match on job status (e.g., "COMPLETED", "FAILED")
|
|
62
|
+
)
|
|
63
|
+
name: str | None = None # Exact match on job name
|
|
64
|
+
provider: str | None = None # Exact match on provider name (e.g., "ibm", "aws")
|
|
65
|
+
backend: str | None = None # Exact match on backend name
|
|
66
|
+
program_id: str | None = None # Exact match on program ID
|
|
67
|
+
total_cost_min: float | None = None # Minimum total cost (inclusive)
|
|
68
|
+
total_cost_max: float | None = None # Maximum total cost (inclusive)
|
|
69
|
+
start_time_min: datetime | None = None # Earliest job start time (inclusive)
|
|
70
|
+
start_time_max: datetime | None = None # Latest job start time (inclusive)
|
|
71
|
+
end_time_min: datetime | None = None # Earliest job end time (inclusive)
|
|
72
|
+
end_time_max: datetime | None = None # Latest job end time (inclusive)
|
|
73
|
+
|
|
74
|
+
def format_filters(self) -> dict[str, Any]:
|
|
75
|
+
"""Convert filter fields to API kwargs, excluding None values and converting datetimes."""
|
|
76
|
+
filter_dict = asdict(self)
|
|
77
|
+
return {
|
|
78
|
+
k: (v.isoformat() if isinstance(v, datetime) else v)
|
|
79
|
+
for k, v in filter_dict.items()
|
|
80
|
+
if v is not None
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
40
84
|
class ExecutionJob:
|
|
41
85
|
_details: ExecutionJobDetails
|
|
42
86
|
_result: ResultsCollection | None
|
|
@@ -352,10 +396,83 @@ class ExecutionJob:
|
|
|
352
396
|
|
|
353
397
|
|
|
354
398
|
async def get_execution_jobs_async(
|
|
355
|
-
offset: int = 0,
|
|
399
|
+
offset: int = 0,
|
|
400
|
+
limit: int = 50,
|
|
356
401
|
) -> list[ExecutionJob]:
|
|
357
|
-
|
|
358
|
-
|
|
402
|
+
execution_user_jobs = await ApiWrapper.call_query_execution_jobs(
|
|
403
|
+
offset, limit, http_client=None
|
|
404
|
+
)
|
|
405
|
+
return [ExecutionJob(details) for details in execution_user_jobs.results]
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def get_execution_jobs(
|
|
409
|
+
offset: int = 0,
|
|
410
|
+
limit: int = 50,
|
|
411
|
+
) -> list[ExecutionJob]:
|
|
412
|
+
"""Query execution jobs.
|
|
413
|
+
|
|
414
|
+
Args:
|
|
415
|
+
offset: Number of results to skip (default: 0)
|
|
416
|
+
limit: Maximum number of results to return (default: 50)
|
|
417
|
+
|
|
418
|
+
Returns:
|
|
419
|
+
List of ExecutionJob objects.
|
|
420
|
+
|
|
421
|
+
Examples:
|
|
422
|
+
# Query all jobs:
|
|
423
|
+
jobs = get_execution_jobs(limit=10)
|
|
424
|
+
"""
|
|
425
|
+
return syncify_function(get_execution_jobs_async)(offset, limit)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def _flatten_cost_field(action_dict: dict[str, Any]) -> dict[str, Any]:
|
|
429
|
+
cost_obj = action_dict.pop(COST, {}) or {}
|
|
430
|
+
action_dict[TOTAL_COST] = cost_obj.get(TOTAL_COST, 0)
|
|
431
|
+
action_dict[CURRENCY_CODE] = cost_obj.get(CURRENCY_CODE)
|
|
432
|
+
return action_dict
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
async def get_execution_actions_async(
|
|
436
|
+
offset: int = 0,
|
|
437
|
+
limit: int = 50,
|
|
438
|
+
filters: ExecutionJobFilters | None = None,
|
|
439
|
+
) -> "pd.DataFrame":
|
|
440
|
+
import pandas as pd
|
|
441
|
+
|
|
442
|
+
api_kwargs = filters.format_filters() if filters is not None else {}
|
|
443
|
+
execution_user_actions = await ApiWrapper.call_query_execution_jobs(
|
|
444
|
+
offset, limit, http_client=None, **api_kwargs
|
|
445
|
+
)
|
|
446
|
+
execution_actions = execution_user_actions.results
|
|
447
|
+
|
|
448
|
+
if not execution_actions:
|
|
449
|
+
return pd.DataFrame()
|
|
450
|
+
|
|
451
|
+
data = [_flatten_cost_field(action.model_dump()) for action in execution_actions]
|
|
452
|
+
return pd.DataFrame(data)
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def get_execution_actions(
|
|
456
|
+
offset: int = 0, limit: int = 50, filters: ExecutionJobFilters | None = None
|
|
457
|
+
) -> "pd.DataFrame":
|
|
458
|
+
"""Query execution jobs with optional filters.
|
|
459
|
+
|
|
460
|
+
Args:
|
|
461
|
+
offset: Number of results to skip (default: 0)
|
|
462
|
+
limit: Maximum number of results to return (default: 50)
|
|
463
|
+
filters: Optional ExecutionJobFilters object containing filter parameters.
|
|
464
|
+
|
|
465
|
+
Returns:
|
|
466
|
+
pandas.DataFrame containing execution job information with columns:
|
|
467
|
+
id, name, start_time, end_time, provider, backend_name, status,
|
|
468
|
+
num_shots, program_id, error, cost.
|
|
359
469
|
|
|
470
|
+
Examples:
|
|
471
|
+
# Query all jobs:
|
|
472
|
+
df = get_execution_actions(limit=10)
|
|
360
473
|
|
|
361
|
-
|
|
474
|
+
# Query with filters:
|
|
475
|
+
filters = ExecutionJobFilters(status="COMPLETED", provider="ibm")
|
|
476
|
+
df = get_execution_actions(filters=filters, limit=10)
|
|
477
|
+
"""
|
|
478
|
+
return syncify_function(get_execution_actions_async)(offset, limit, filters)
|
classiq/interface/_version.py
CHANGED
classiq/interface/exceptions.py
CHANGED
|
@@ -35,14 +35,6 @@ class ClassiqMissingOutputFormatError(ClassiqError):
|
|
|
35
35
|
super().__init__(message=msg)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
class ClassiqCombinatorialOptimizationError(ClassiqError):
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class ClassiqOracleError(ClassiqError):
|
|
43
|
-
pass
|
|
44
|
-
|
|
45
|
-
|
|
46
38
|
class ClassiqAnalyzerError(ClassiqError):
|
|
47
39
|
pass
|
|
48
40
|
|
|
@@ -57,10 +49,6 @@ class ClassiqAPIError(ClassiqError):
|
|
|
57
49
|
super().__init__(message)
|
|
58
50
|
|
|
59
51
|
|
|
60
|
-
class ClassiqVersionError(ClassiqError):
|
|
61
|
-
pass
|
|
62
|
-
|
|
63
|
-
|
|
64
52
|
class ClassiqValueError(ClassiqError, ValueError):
|
|
65
53
|
pass
|
|
66
54
|
|
|
@@ -77,10 +65,6 @@ class ClassiqIndexError(ClassiqError, IndexError):
|
|
|
77
65
|
pass
|
|
78
66
|
|
|
79
67
|
|
|
80
|
-
class ClassiqWiringError(ClassiqValueError):
|
|
81
|
-
pass
|
|
82
|
-
|
|
83
|
-
|
|
84
68
|
class ClassiqControlError(ClassiqError):
|
|
85
69
|
def __init__(self) -> None:
|
|
86
70
|
message = "Repeated control names, please rename the control states"
|
|
@@ -91,10 +75,6 @@ class ClassiqQRegError(ClassiqValueError):
|
|
|
91
75
|
pass
|
|
92
76
|
|
|
93
77
|
|
|
94
|
-
class ClassiqQFuncError(ClassiqValueError):
|
|
95
|
-
pass
|
|
96
|
-
|
|
97
|
-
|
|
98
78
|
class ClassiqQNNError(ClassiqValueError):
|
|
99
79
|
pass
|
|
100
80
|
|
|
@@ -103,10 +83,6 @@ class ClassiqTorchError(ClassiqQNNError):
|
|
|
103
83
|
pass
|
|
104
84
|
|
|
105
85
|
|
|
106
|
-
class ClassiqChemistryError(ClassiqError):
|
|
107
|
-
pass
|
|
108
|
-
|
|
109
|
-
|
|
110
86
|
class ClassiqAuthenticationError(ClassiqError):
|
|
111
87
|
pass
|
|
112
88
|
|
|
@@ -115,22 +91,10 @@ class ClassiqExpiredTokenError(ClassiqAuthenticationError):
|
|
|
115
91
|
pass
|
|
116
92
|
|
|
117
93
|
|
|
118
|
-
class ClassiqFileNotFoundError(FileNotFoundError):
|
|
119
|
-
pass
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
class ClassiqStateInitializationError(ClassiqError):
|
|
123
|
-
pass
|
|
124
|
-
|
|
125
|
-
|
|
126
94
|
class ClassiqPasswordManagerSelectionError(ClassiqError):
|
|
127
95
|
pass
|
|
128
96
|
|
|
129
97
|
|
|
130
|
-
class ClassiqMismatchIOsError(ClassiqError):
|
|
131
|
-
pass
|
|
132
|
-
|
|
133
|
-
|
|
134
98
|
class ClassiqNotImplementedError(ClassiqError, NotImplementedError):
|
|
135
99
|
pass
|
|
136
100
|
|
|
@@ -171,12 +135,6 @@ class ClassiqCombOptNotSupportedProblemError(ClassiqCombOptError):
|
|
|
171
135
|
pass
|
|
172
136
|
|
|
173
137
|
|
|
174
|
-
class ClassiqExecutorInvalidHamiltonianError(ClassiqCombOptError):
|
|
175
|
-
|
|
176
|
-
def __init__(self) -> None:
|
|
177
|
-
super().__init__("Invalid hamiltonian")
|
|
178
|
-
|
|
179
|
-
|
|
180
138
|
class ClassiqDeprecationWarning(FutureWarning):
|
|
181
139
|
pass
|
|
182
140
|
|
|
@@ -11,7 +11,6 @@ from classiq.interface.backend.ionq.ionq_quantum_program import IonqQuantumCircu
|
|
|
11
11
|
from classiq.interface.backend.pydantic_backend import PydanticArgumentNameType
|
|
12
12
|
from classiq.interface.exceptions import ClassiqValueError
|
|
13
13
|
from classiq.interface.executor.quantum_instruction_set import QuantumInstructionSet
|
|
14
|
-
from classiq.interface.executor.register_initialization import RegisterInitialization
|
|
15
14
|
from classiq.interface.generator.synthesis_metadata.synthesis_execution_data import (
|
|
16
15
|
ExecutionData,
|
|
17
16
|
)
|
|
@@ -19,7 +18,6 @@ from classiq.interface.generator.synthesis_metadata.synthesis_execution_data imp
|
|
|
19
18
|
Arguments = dict[PydanticArgumentNameType, Any]
|
|
20
19
|
MultipleArguments = tuple[Arguments, ...]
|
|
21
20
|
CodeType = str
|
|
22
|
-
RegistersInitialization = dict[str, RegisterInitialization]
|
|
23
21
|
Qubits = tuple[int, ...]
|
|
24
22
|
OutputQubitsMap = dict[str, Qubits]
|
|
25
23
|
|
|
@@ -57,10 +55,6 @@ class QuantumCode(QuantumBaseCode):
|
|
|
57
55
|
default_factory=dict,
|
|
58
56
|
description="The map of outputs to their qubits in the circuit.",
|
|
59
57
|
)
|
|
60
|
-
registers_initialization: RegistersInitialization | None = pydantic.Field(
|
|
61
|
-
default=None,
|
|
62
|
-
description="Initial conditions for the different registers in the circuit.",
|
|
63
|
-
)
|
|
64
58
|
synthesis_execution_data: ExecutionData | None = pydantic.Field(default=None)
|
|
65
59
|
synthesis_execution_arguments: Arguments = pydantic.Field(default_factory=dict)
|
|
66
60
|
model_config = ConfigDict(validate_assignment=True)
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
|
|
3
|
-
from pydantic import Field
|
|
3
|
+
from pydantic import ConfigDict, Field
|
|
4
4
|
|
|
5
5
|
from classiq.interface.helpers.versioned_model import VersionedModel
|
|
6
6
|
from classiq.interface.jobs import JobStatus
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class
|
|
9
|
+
class SynthesisActionDetails(VersionedModel):
|
|
10
|
+
"""
|
|
11
|
+
Details of a synthesis user action.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
model_config = ConfigDict(frozen=True)
|
|
10
15
|
id: str
|
|
11
16
|
|
|
12
17
|
name: str | None = Field(default=None)
|
|
@@ -31,5 +36,5 @@ class SynthesisJobDetails(VersionedModel):
|
|
|
31
36
|
max_gate_count: int | None = Field(default=None)
|
|
32
37
|
|
|
33
38
|
|
|
34
|
-
class
|
|
35
|
-
results: list[
|
|
39
|
+
class SynthesisActionsQueryResults(VersionedModel):
|
|
40
|
+
results: list[SynthesisActionDetails]
|