Documentation
¶
Overview ¶
Package pulse provides types for pulse-level quantum control.
Pulse programming operates at a lower level than gate-based circuits, directly controlling the analog signals sent to quantum hardware. This package implements the OpenPulse model used by AWS Braket and compatible with the OpenQASM 3.0 pulse grammar.
The three core types are Port (hardware I/O endpoint), Frame (software reference clock), and Waveform (signal envelope interface). Eight instruction types (Play, Delay, SetPhase, ShiftPhase, SetFrequency, ShiftFrequency, Barrier, Capture) compose into an immutable Program via a fluent Builder.
Timing uses float64 seconds (not time.Duration) for sub-nanosecond precision required by quantum hardware. Frames are stateless value types - phase and frequency changes are expressed as instructions.
Standard waveform shapes are provided in the [waveform] sub-package. IonQ custom pulse envelopes use a separate model; see the [ionq.PulseShapes] type in the backend/ionq package.
Index ¶
- type Barrier
- type Builder
- func (b *Builder) AddFrame(f Frame) *Builder
- func (b *Builder) AddPort(p Port) *Builder
- func (b *Builder) Barrier(frames ...Frame) *Builder
- func (b *Builder) Build() (*Program, error)
- func (b *Builder) Capture(f Frame, duration float64) *Builder
- func (b *Builder) Delay(f Frame, duration float64) *Builder
- func (b *Builder) Play(f Frame, wf Waveform) *Builder
- func (b *Builder) SetFrequency(f Frame, frequency float64) *Builder
- func (b *Builder) SetPhase(f Frame, phase float64) *Builder
- func (b *Builder) ShiftFrequency(f Frame, delta float64) *Builder
- func (b *Builder) ShiftPhase(f Frame, delta float64) *Builder
- func (b *Builder) WithMetadata(key, value string) *Builder
- type Capture
- type Delay
- type Frame
- type Instruction
- type Play
- type Port
- type Program
- type ProgramStats
- type SetFrequency
- type SetPhase
- type ShiftFrequency
- type ShiftPhase
- type Waveform
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs a Program using a fluent API with eager validation and error short-circuiting.
Example ¶
package main
import (
"fmt"
"github.com/splch/goqu/pulse"
"github.com/splch/goqu/pulse/waveform"
)
func main() {
port := pulse.MustPort("d0", 1e-9)
frame := pulse.MustFrame("q0_drive", port, 5e9, 0)
gauss := waveform.MustGaussian(1.0, 160e-9, 40e-9)
prog, err := pulse.NewBuilder("x90").
AddPort(port).
AddFrame(frame).
ShiftPhase(frame, 0).
Play(frame, gauss).
Capture(frame, 1e-6).
Build()
if err != nil {
panic(err)
}
stats := prog.Stats()
fmt.Printf("name=%s ports=%d frames=%d instructions=%d\n",
prog.Name(), stats.NumPorts, stats.NumFrames, stats.NumInstructions)
}
Output: name=x90 ports=1 frames=1 instructions=3
func NewBuilder ¶
NewBuilder creates a Builder for a pulse program with the given name.
func (*Builder) AddFrame ¶
AddFrame registers a software frame. The frame's port must have been added via [AddPort] first.
func (*Builder) Build ¶
Build constructs the immutable Program. Returns an error if any builder method failed or if the program has no instructions.
func (*Builder) SetFrequency ¶
SetFrequency appends a SetFrequency instruction.
func (*Builder) ShiftFrequency ¶
ShiftFrequency appends a ShiftFrequency instruction.
func (*Builder) ShiftPhase ¶
ShiftPhase appends a ShiftPhase instruction.
func (*Builder) WithMetadata ¶
WithMetadata adds a key-value pair to the program metadata.
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents a software reference clock attached to a port. Frames are stateless value types - phase and frequency changes are expressed as SetPhase, ShiftPhase, SetFrequency, and ShiftFrequency instructions.
func NewFrame ¶
NewFrame creates a Frame with the given name, port, initial frequency (Hz), and initial phase (radians).
type Instruction ¶
type Instruction interface {
// contains filtered or unexported methods
}
Instruction is a sealed interface for pulse program instructions. Only the eight types defined in this package implement it.
type Port ¶
type Port struct {
// contains filtered or unexported fields
}
Port represents a hardware I/O endpoint on the quantum device. dt is the minimum time resolution in seconds.
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
Program is an immutable pulse schedule consisting of ports, frames, and a sequence of instructions. Construct programs using Builder.
func NewProgram ¶
func NewProgram(name string, ports []Port, frames []Frame, instrs []Instruction, metadata map[string]string) *Program
NewProgram creates an immutable Program. All slices and maps are defensively copied. Prefer the Builder for validated construction.
func (*Program) Instructions ¶
func (p *Program) Instructions() []Instruction
Instructions returns a copy of the instruction sequence.
func (*Program) Stats ¶
func (p *Program) Stats() ProgramStats
Stats returns summary statistics for the program.
type ProgramStats ¶
type ProgramStats struct {
NumPorts int
NumFrames int
NumInstructions int
TotalDuration float64 // seconds (sum of play/delay/capture durations)
}
ProgramStats holds summary statistics for a pulse program.
type SetFrequency ¶
SetFrequency sets the absolute frequency of a frame (Hz).
type ShiftFrequency ¶
ShiftFrequency adds a relative frequency offset to a frame (Hz).
type ShiftPhase ¶
ShiftPhase adds a relative phase offset to a frame (radians).
type Waveform ¶
type Waveform interface {
// Name returns the waveform identifier (e.g., "gaussian(0.5, 1e-8, 2.5e-9)").
Name() string
// Duration returns the total waveform duration in seconds.
Duration() float64
// Sample returns the waveform envelope sampled at the given time
// resolution dt (seconds). The returned slice length is ceil(Duration/dt).
Sample(dt float64) []complex128
}
Waveform defines a signal envelope that can be played on a frame. Standard waveforms are provided in the waveform sub-package.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package defcal maps gate-level circuits to pulse programs via calibration tables.
|
Package defcal maps gate-level circuits to pulse programs via calibration tables. |
|
Package qasmparse parses OpenQASM 3.0 with OpenPulse cal {} blocks into pulse.Program objects.
|
Package qasmparse parses OpenQASM 3.0 with OpenPulse cal {} blocks into pulse.Program objects. |
|
Package waveform provides standard pulse envelope shapes for the pulse package.
|
Package waveform provides standard pulse envelope shapes for the pulse package. |