Serialization API¶
qm.serialization.generate_qua_script.generate_qua_script ¶
Serializes a QUA program into a runnable QUA Python script.
The returned string is standalone Python source that reconstructs the given program, useful for debugging, sharing, or archiving a program.
Note
This function must be called outside of a program() scope.
Note
In some cases the serialization may be incomplete. When that happens, the generated
script silently contains a SERIALIZATION WAS NOT COMPLETE comment block with the
raw protobuf representation of the program. This indicates a problem in the
serialization itself and should be reported to Quantum Machines.
| PARAMETER | DESCRIPTION |
|---|---|
prog
|
The QUA
TYPE:
|
config
|
A QUA configuration to embed in the generated script. When omitted, the script is generated without a configuration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The generated QUA Python script as a string. |
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
If called inside a QUA program scope, or if the given config is invalid. |
qm.serialization.generate_qua_script.assert_programs_are_equal ¶
Asserts that two QUA programs are structurally equivalent.
Both programs are first normalized with standardize_program_for_comparison, so that
differences that do not affect runtime behavior (source locations, variable and stream
names, result-analysis ordering) are ignored.
| PARAMETER | DESCRIPTION |
|---|---|
prog1
|
The first program to compare.
TYPE:
|
prog2
|
The second program to compare.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
AssertionError
|
If the two programs are not structurally equivalent. |