Errors#
Every error CUDA-Q Pulse raises on purpose derives from PulseError, so
except cudaq_pulse.PulseError catches them all. Each also has the
built-in base of its kind of error, so except ValueError or except
RuntimeError catches it as it would the built-in one: InvalidValueError
is a ValueError, NotFoundError and UnknownQuantumSystemError are
KeyErrors, IndexOutOfRangeError is an IndexError, and CompilationError and NoProcessQuantumSystemError are
RuntimeErrors.
- exception cudaq_pulse.PulseError(*args, problems=())[source]#
Bases:
ExceptionBase class of every error cudaq-pulse raises on purpose.
Each subclass also has the built-in base its kind of error has in Python, so
except ValueError,except KeyErrororexcept RuntimeErrorcatches it as it would the built-in error. Errors that the native extension raises while running MLIR passes are not subclasses yet, nor are someValueErrorandTypeErrorfor a malformed compile option or controller limit.An error that found several problems at once lists them in
problems, and its message shows the first ten.- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- property location: Problem | None#
The first problem that names a file, if any; else, for an error raised while a kernel was traced, the kernel line that raised it:
file,line,source(the line’s text) andpath(the function’s name), with the error’s message and fix, and asvaluethe misspelled name adid_you_meanreplaces.
An error that finds several problems at once, such as
QuantumSystemDefinitionError, lists each as a Problem in problems:
-
class cudaq_pulse.Problem(
)[source]#message,path='',value=UNSET,fix='',file=None,line=None,column=None,source='',
Bases:
objectOne thing that is wrong, where it is, and how to fix it.
messagesays what is wrong;pathwhere, in the terms of what the user wrote ("layout[2]","controllers[0].drive_lines");valueis the offending value (Problem.UNSETwhen there is none);fixwhat to do.file,lineandcolumnlocate it in a file, when it came from one;lineandcolumncount from 1, andsourceis that line’s text, stripped, when it was read.- Parameters:
message (str)
path (str)
value (Any)
fix (str)
file (str | None)
line (int | None)
column (int | None)
source (str)
- UNSET: ClassVar[Any] = UNSET#
- message: str#
- path: str = ''#
- value: Any = UNSET#
- fix: str = ''#
- file: str | None = None#
- line: int | None = None#
- column: int | None = None#
- source: str = ''#
Arguments and names#
- exception cudaq_pulse.InvalidValueError(*args, problems=())[source]#
Bases:
PulseError,ValueErrorAn argument, option or setting has the right type but a value that cannot be used: a negative duration, an empty list, a shape that does not match.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.InvalidTypeError(*args, problems=())[source]#
Bases:
PulseError,TypeErrorAn argument, option or callback result has a type that cannot be used, such as a string where a number is needed.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.NotFoundError(*args, problems=())[source]#
Bases:
PulseError,KeyErrorA name has nothing behind it: a calibration value, a handler, a parameter or a file that is not there. The message lists what there is.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.IndexOutOfRangeError(*args, problems=())[source]#
Bases:
PulseError,IndexErrorAn index past the end of what it indexes, such as a qudit index past the qudits of a quantum system or register. The message says how many there are.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.UnsupportedError(*args, problems=())[source]#
Bases:
PulseError,NotImplementedErrorWhat was asked is not available yet, or not on this platform or Python version. It is a
NotImplementedError, and so also aRuntimeError.- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Compiling#
-
exception cudaq_pulse.CompilationError(
)[source]#*args,problems=(),code=None,fix='',did_you_mean=None,misspelled=None,
Bases:
PulseError,RuntimeErrorA kernel cannot be traced or compiled: an unsupported construct, an operation given the wrong kind of argument, or invalid pulse IR. The message says what to write instead, and a note gives the kernel line.
codeis theErrorCodeof the error;fix, when not empty, the part of the message that says what to write instead;did_you_mean, when notNone, the name to write in place of the misspelled one, whichlocation.valueholds; andlocation, for an error raised while the kernel was traced, the kernel line that raised it.- Parameters:
args (object)
problems (tuple[Problem, ...])
code (str | None)
fix (str)
did_you_mean (str | None)
misspelled (str | None)
- Return type:
None
-
exception cudaq_pulse.TimingError(
)[source]#*args,problems=(),code=None,fix='',did_you_mean=None,misspelled=None,
Bases:
CompilationErrorA program cannot meet a timing it declares: a deadline for an answer, or a limit on its length.
problemsnames each one that is missed.- Parameters:
args (object)
problems (tuple[Problem, ...])
code (str | None)
fix (str)
did_you_mean (str | None)
misspelled (str | None)
- Return type:
None
- exception cudaq_pulse.compiler.UnsupportedInterpreterError(*args, problems=())[source]#
Bases:
UnsupportedErrorThe running interpreter’s bytecode is not known to the kernel tracer.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Error codes#
Every CompilationError has a code, an ErrorCode, so a program
or a tool can act on the kind of error without reading the message. The
codes are stable: a code keeps its meaning, and a new kind of error gets a
new code. fix holds the part of the message that says what to write
instead (empty when the message gives none), did_you_mean the name to
write in place of a misspelled one, and location, for an error raised
while the kernel is traced, a Problem with the kernel’s file,
line and source (the text of that line), as path the name of
the function and, with did_you_mean, as value the misspelled name.
The message is the same as without them. For a kernel k that
misspells an operation, and its qudit q:
try:
pulse.compile(k).lower(q)
except pulse.CompilationError as error:
if error.code == pulse.ErrorCode.UNKNOWN_NAME and error.did_you_mean:
where = error.location
fixed = where.source.replace(where.value, error.did_you_mean, 1)
print(f"{where.file}:{where.line}: write {fixed!r}")
Code |
What it means |
|---|---|
|
A name the kernel calls or reads that nothing in its scope
defines; |
|
An attribute the value does not have; |
|
A name read before it is assigned on the path traced. |
|
An argument of the wrong kind, or the wrong number of them. |
|
Python the kernel language does not trace, such as a
|
|
A value known only when the program runs, such as a measurement result, used where tracing needs its value. |
|
A |
|
A duration that is not a whole number of cycles, or that mixes times with numbers of cycles. |
|
A waveform that cannot be made. |
|
A calibration that cannot play, or that the trace cannot read. |
|
A program larger than a limit of the compiler. |
|
An |
|
Python code of the kernel that failed as it would outside one; the message holds Python’s error. |
|
A program the control system cannot play as written. |
|
A kernel called with its own |
|
A missed deadline or length limit ( |
|
A limit of the controller exceeded
( |
|
Any other compilation error. |
- class cudaq_pulse.ErrorCode(*values)[source]#
Bases:
StrEnumWhat kind of
CompilationErroran error is: itscode.The codes are stable, so a program, a test or a tool can act on one without reading the message. Each member is a string; the plain string (
"unknown_name") compares equal to it.- UNKNOWN_NAME = 'unknown_name'#
A name the kernel calls or reads that nothing in its scope defines, such as a misspelled operation;
did_you_meannames a close one.
- UNKNOWN_ATTRIBUTE = 'unknown_attribute'#
An attribute the value does not have, such as a misspelled method of a line;
did_you_meannames a close one.
- UNASSIGNED_NAME = 'unassigned_name'#
A name read before it is assigned on the path the trace took.
- WRONG_ARGUMENT = 'wrong_argument'#
An operation given an argument of the wrong kind, such as a qudit where it takes a line, or the wrong number of arguments.
- UNSUPPORTED_CONSTRUCT = 'unsupported_construct'#
Python the kernel language does not trace: a
whileloop,try, a generator, a class definition.
- RUNTIME_VALUE = 'runtime_value'#
A value known only when the program runs, such as a measurement result, used where tracing needs its value: compared, converted, iterated or hashed; or a branch on one that does what a branch taken at run time cannot.
- SYMBOLIC_PARAMETER = 'symbolic_parameter'#
A
floatparameter whose value the program needs while it compiles (SymbolicValueError).
- INVALID_DURATION = 'invalid_duration'#
A duration or time that is not a whole number of clock cycles, a float where a duration takes an int or a time, or arithmetic that mixes times with numbers of cycles.
- INVALID_WAVEFORM = 'invalid_waveform'#
A waveform that cannot be made: a
custom()envelope that returns what is not a number, waveform arithmetic on different durations, samples made for another rate.
- CALIBRATION = 'calibration'#
A calibration the kernel plays that cannot play, or that its trace cannot read.
- LIMIT_EXCEEDED = 'limit_exceeded'#
A program larger than a limit of the compiler: more operations than the controller holds, a loop unrolled past its limit, kernel calls nested too deep.
- KERNEL_RAISED = 'kernel_raised'#
An
assertthat failed, or araise, in the kernel.
- PYTHON_ERROR = 'python_error'#
Python code of the kernel that failed as it would outside one: a subscript, an unpacking, an operator or a helper call that raised; the message holds Python’s error.
- CONTROL_SYSTEM = 'control_system'#
A program the control system cannot play as written: a link it does not have, a qudit the quantum system does not define, a call across its controllers.
- SCHEDULE_BLOCK = 'schedule_block'#
A kernel called with its own
schedule=that the program cannot schedule on its own: underrcporalap_rcp, which schedule a whole program, or with amax_duration_cyclesthatflatten_schedules=Truecannot hold.fixsays whether to compile withflatten_schedules=Trueor without it.
- TIMING = 'timing'#
A program that misses a timing it declares (
TimingError).
- CONTROLLER_LIMIT = 'controller_limit'#
A program over a limit of its controller (
ControllerLimitError).
- OTHER = 'other'#
Any other compilation error; the message says what is wrong.
Running#
- exception cudaq_pulse.ExecutionError(*args, problems=())[source]#
Bases:
PulseError,RuntimeErrorRunning a compiled program failed: a simulation, a classical call or a GPU launch.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.InternalError(*args, problems=())[source]#
Bases:
PulseError,RuntimeErrorA bug in cudaq-pulse: a check that a valid program never fails. The message asks for a report with the kernel that raised it.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Quantum systems#
- exception cudaq_pulse.QuantumSystemDefinitionError(message='', *, problems=())[source]#
Bases:
PulseError,ValueErrorA quantum system’s definition is wrong:
pulse.quantum_system()lists every problem of its config or file inproblems, each with its path in the config (and, for a file, its line and column).- Parameters:
message (str)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.NoQuantumSystemError(*args, problems=())[source]#
Bases:
NoProcessQuantumSystemErrorA kernel was called without qudit handles and was not compiled for a quantum system, so it has no quantum system to run on. The process quantum system is never used for a kernel call.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.NoProcessQuantumSystemError(*args, problems=())[source]#
Bases:
PulseError,RuntimeErrorquantum_system()was called with no argument andCUDAQ_PULSE_QUANTUM_SYSTEMnames no process quantum system.- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.QuantumSystemMismatchError(*args, problems=())[source]#
Bases:
PulseError,RuntimeErrorA kernel call mixes handles of different quantum systems, or of an unpinned one.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.quantum_systems.UnknownQuantumSystemError(*args, problems=())[source]#
Bases:
NotFoundErrorA quantum system name, given to
quantum_system(), in a system file or inCUDAQ_PULSE_QUANTUM_SYSTEM, is not registered; the message lists the registered ones.- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
GPU simulation#
pulse.simulate(..., backend="gpu") raises one of the three subclasses of
GpuRuntimeError (cudaq_pulse.GpuRuntimeError), an ExecutionError,
when GPU simulation cannot run; see GPU Runtime Errors.
- exception cudaq_pulse.runtime.GpuRuntimeError(*args, problems=())[source]#
Bases:
ExecutionErrorBase class for every reason GPU execution cannot proceed.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.runtime.GpuSupportNotBuiltError(*args, problems=())[source]#
Bases:
GpuRuntimeErrorThis cudaq-pulse build does not contain the GPU runtime.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.runtime.GpuRuntimeLoadError(*args, problems=())[source]#
Bases:
GpuRuntimeErrorThe GPU runtime is part of this build but could not be loaded.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Bases:
GpuRuntimeErrorThe GPU runtime loaded, but no usable NVIDIA device or driver exists.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Controller backends#
Compiling for a controller whose limits a program exceeds raises
ControllerLimitError; finding a backend raises a BackendError. See
Controller Backends API.
- exception cudaq_pulse.controller.ControllerLimitError(violations, *, system=False, usage=None)[source]#
Bases:
CompilationErrorA scheduled program exceeds a limit of the controller it is for.
violationshas every limit exceeded: a tuple, or past 10,000 of them in rolled loops a sequence that builds each one when read, with an exactlen(). For a control system with processors,usageis the program’sUsageReport: what each processor holds against its limits, and each limit exceeded with by how much (usage.exceeded); the message ends with its table.- Parameters:
violations (Sequence[str])
system (bool)
usage (UsageReport | None)
- Return type:
None
- violations: Sequence[str]#
- exception cudaq_pulse.backends.BackendError(*args, problems=())[source]#
Bases:
PulseErrorA controller backend cannot be found or used.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.backends.BackendNotFoundError(*args, problems=())[source]#
Bases:
BackendError,NotFoundErrorNo backend of that name is installed or registered.
- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
- exception cudaq_pulse.backends.IncompatibleBackendError(*args, problems=())[source]#
Bases:
BackendError,TypeErrorA backend fails to load, is not a
Backend, or reads none of the export formats this version writes.- Parameters:
args (object)
problems (tuple[Problem, ...])
- Return type:
None
Warnings#
- exception cudaq_pulse.PulseWarning[source]#
Bases:
UserWarningBase class of the warnings cudaq-pulse issues, so that
warnings.filterwarnings("error", category=pulse.PulseWarning)turns them all into errors.
- exception cudaq_pulse.UpgradeNotice[source]#
Bases:
PulseWarningSomething still works but has a newer form, such as a file in an older format; the message names the newer form. Issued once per cause.
- exception cudaq_pulse.UnitWarning[source]#
Bases:
PulseWarningA number given without units that is probably not what was meant: a bare number as a duration, wait or other time of a pulse, which counts clock cycles, or a frequency so far below the quantum system’s carriers that it is probably in MHz or kHz rather than Hz.
Issued while a kernel compiled with
unit_warnings=Truetraces, at the kernel line;warnings.filterwarnings("error", category=pulse.UnitWarning)makes each one an error.
See unit warnings for what unit_warnings=True checks.