Skip to content

Commit 9888f25

Browse files
committed
[pulse] Add release-function declarations and Module Flags Metadata section
1 parent d61d378 commit 9888f25

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

‎specification/profiles/Pulse_Profile.md‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,18 @@ The following Pulse runtime functions must be supported by all backends:
416416
| `__quantum__rt__pulse__waveform_gaussian` | `ptr(double %amplitude, double %sigma, double %duration)` | Constructs a Gaussian-envelope waveform with peak amplitude `%amplitude`, standard deviation `%sigma (seconds)`, and total duration `%duration (seconds)`, centered at `%duration / 2`, and returns a reference to it. |
417417
| `__quantum__rt__pulse__waveform_from_samples` | `ptr(ptr %samples, i64 %n_samples, double %sample_rate)` | Constructs a waveform from `%n_samples` complex-valued IQ samples pointed to by `%samples`, discretized at the description sample rate `%sample_rate (Hz)`. The resulting envelope has duration `%n_samples / %sample_rate`. |
418418

419+
The above functions dynamically construct resources at runtime. Dynamic
420+
construction is indicated via the module flags: `dynamic_port_management`,
421+
`dynamic_frame_management`, `dynamic_waveform_management`. To reclaim the
422+
constructed or allocated resources, following resource release functions can be
423+
used:
424+
425+
```llvm
426+
declare void @__quantum__rt__pulse__release_port(ptr %port)
427+
declare void @__quantum__rt__pulse__release_frame(ptr %frame)
428+
declare void @__quantum__rt__pulse__release_waveform(ptr %waveform)
429+
```
430+
419431
### Initialization Functions
420432

421433
## Attributes
@@ -426,10 +438,39 @@ following key difference with respect to attributes attached to an entry point
426438
function:
427439

428440
- The Pulse Profile does not support the `"required_num_qubits"` attribute since
429-
the pulse profile does not define a `"qubit"` resource.
441+
the profile does not define a `"qubit"` resource.
430442

431443
## Module Flags Metadata
432444

445+
The Pulse Profile requires the following module flags to be present within the
446+
QIR bitcode:
447+
448+
- a flag with the string identifier `"qir_major_version"` that contains a
449+
constant value of type `i32`
450+
- a flag with the string identifier `"qir_minor_version"` that contains a
451+
constant value of type `i32`
452+
- a flag with the string identifier `"dynamic_port_management"` that contains a
453+
constant `true` or `false` value of type `i1` indicating whether the program
454+
uses dynamic port construction and release. When set to `true`, the runtime
455+
API functions `__quantum__rt__pulse__get_port` and
456+
`__quantum__rt__pulse__release_port` may be used in the program.
457+
- a flag with the string identifier `"dynamic_frame_management"` that contains a
458+
constant `true` or `false` value of type `i1` indicating whether the program
459+
uses dynamic frame construction and release. When set to `true`, the runtime
460+
API functions `__quantum__rt__pulse__create_frame` and
461+
`__quantum__rt__pulse__release_frame` may be used in the program.
462+
- a flag with the string identifier `"dynamic_waveform_management"` that
463+
contains a constant `true` or `false` value of type `i1` indicating whether
464+
the program uses dynamic waveform construction and release. When set to
465+
`true`, the runtime API functions `__quantum__rt__pulse__waveform_gaussian` or
466+
`__quantum__rt__pulse__waveform_from_samples` for waveform construction and
467+
`__quantum__rt__pulse__release_waveform` for waveform release may be used in
468+
the program.
469+
470+
These flags are attached as `llvm.module.flags` metadata to the module. They can
471+
be queried using the standard LLVM tools and follow the LLVM specification in
472+
behavior and purpose.
473+
433474
## Additional Examples
434475

435476
## Glossary

0 commit comments

Comments
 (0)