‘cudm’ Dialect#

Dialect wrapping the NVIDIA cuDensityMat API for quantum dynamics

The cudm dialect provides an MLIR representation of the NVIDIA cuDensityMat library API for GPU-accelerated quantum dynamics simulation. It serves as the lowering target for the qop dialect and the source for call generation targeting the cuDensityMat runtime API.

Two tiers of operations:

  • API ops: wrappers around cudensitymat* C API functions, which cudm-to-llvm lowers to calls into the cudaq-pulse cuDensityMat runtime

  • Solver ops: cudm.evolve, which the runtime integrates with its own rk1, rk2, rk4, Magnus or Crank-Nicolson stepper, and the reserved cudm.sse_evolve and cudm.apply_decoherence, which nothing lowers yet

Operations#

cudm.append_elementary_product (::cudm::AppendElementaryProductOp)#

Append a product of elementary operators to a term

Syntax:

operation ::= `cudm.append_elementary_product` $handle `,` $op_term `,` $elem_ops attr-dict `:` type($handle) `,` type($op_term) `,` type($elem_ops)

Appends to a term the product of elem_ops on the modes modes_acted_on, weighted by coeff_real + i coeff_imag. An operator on several modes takes that many consecutive entries of modes_acted_on; a mode may appear twice in one operator, once on each side. Each duality entry says whether its operator acts on the ket (0) or the bra (1) side of that mode. The weight of a time-dependent product is also multiplied, at each time, by the drive envelope that its cudm.callback_kind and cudm.callback_params attributes describe. callback names that envelope’s qop callback when there is one; a sum of envelopes (kind 512, whose parameters list each envelope’s kind, parameter count and parameters) has none.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
modes_acted_on::mlir::DenseI32ArrayAttri32 dense array attribute
duality::mlir::DenseI32ArrayAttri32 dense array attribute
coeff_real::mlir::FloatAttr64-bit float attribute
coeff_imag::mlir::FloatAttr64-bit float attribute
callback::mlir::FlatSymbolRefAttrflat symbol reference attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op_term

Operator term: sum of products of elementary/matrix operators

elem_ops

variadic of Elementary tensor operator acting on specific modes

cudm.apply_decoherence (::cudm::ApplyDecoherenceOp)#

Apply Lindblad T1/T2 decoherence for one time step

Syntax:

operation ::= `cudm.apply_decoherence` $handle `,` $state `,` $model `,` $dt attr-dict `:` type($handle) `,` type($state) `,` type($model)

Applies T1 and T2 decoherence of model over one step dt. The execution lowering puts decoherence in the Lindblad operator instead and does not use this op yet.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

state

Quantum state (pure or mixed, optionally batched)

model

T1/T2 decoherence parameters per qubit mode

dt

64-bit float

cudm.create_elementary_op (::cudm::CreateElementaryOpOp)#

Create an elementary tensor operator

Syntax:

operation ::= `cudm.create_elementary_op` $handle `,` $tensor_data attr-dict `:` type($handle) `,` type($tensor_data) `->` type($elem_op)

An elementary operator on modes of mode_extents levels, copied to the device. Dense, tensor_data is its matrix (column-major, interleaved real and imaginary parts, as qop.matrix_leaf holds it). Multi-diagonal, it acts on one mode and tensor_data holds one vector of the mode’s extent per entry of diagonal_offsets (ascending; positive above the main diagonal), element (r, r + offset) at index min(r, r + offset).

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
sparsity::cudm::SparsityAttrElementary operator sparsity pattern
data_type::cudm::ComputeTypeAttrFloating-point compute precision; the runtime computes in complex128 only
mode_extents::mlir::DenseI64ArrayAttri64 dense array attribute
callback::mlir::FlatSymbolRefAttrflat symbol reference attribute
diagonal_offsets::mlir::DenseI32ArrayAttri32 dense array attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

tensor_data

any type

Results:#

Result

Description

elem_op

Elementary tensor operator acting on specific modes

cudm.create_expectation (::cudm::CreateExpectationOp)#

Create expectation value computation object

Syntax:

operation ::= `cudm.create_expectation` $handle `,` $op attr-dict `:` type($handle) `,` type($op) `->` type($expectation)

An object computing the expectation value of an operator (cudensitymatCreateExpectation). The execution lowering does not use it yet; observables are reserved.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op

Composite operator / super-operator

Results:#

Result

Description

expectation

Expectation value computation handle

cudm.create_op_term (::cudm::CreateOpTermOp)#

Create an empty operator term

Syntax:

operation ::= `cudm.create_op_term` $handle attr-dict `:` functional-type($handle, $op_term)

An empty operator term over modes of mode_extents levels, to which products of elementary operators are appended.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
mode_extents::mlir::DenseI64ArrayAttri64 dense array attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

Results:#

Result

Description

op_term

Operator term: sum of products of elementary/matrix operators

cudm.create_operator (::cudm::CreateOperatorOp)#

Create an empty composite operator (super-operator)

Syntax:

operation ::= `cudm.create_operator` $handle attr-dict `:` functional-type($handle, $op)

An empty composite operator (a super-operator on the state) over modes of mode_extents levels.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
mode_extents::mlir::DenseI64ArrayAttri64 dense array attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

Results:#

Result

Description

op

Composite operator / super-operator

cudm.create_state (::cudm::CreateStateOp)#

Define an empty quantum state of given purity and shape

Syntax:

operation ::= `cudm.create_state` $handle attr-dict `:` functional-type($handle, $state)

A state over modes of mode_extents levels (each at least 2): a pure state vector or, with purity mixed, a density matrix, in complex128. It starts as the ground state, or as the initial state the host set for the next allocation on the thread.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
purity::cudm::StatePurityAttrQuantum state purity
data_type::cudm::ComputeTypeAttrFloating-point compute precision; the runtime computes in complex128 only
mode_extents::mlir::DenseI64ArrayAttri64 dense array attribute
batch_size::mlir::IntegerAttr64-bit signless integer attribute
distributed::mlir::BoolAttrbool attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

Results:#

Result

Description

state

Quantum state (pure or mixed, optionally batched)

cudm.create_workspace (::cudm::CreateWorkspaceOp)#

Create a workspace descriptor

Syntax:

operation ::= `cudm.create_workspace` $handle attr-dict `:` functional-type($handle, $workspace)

A workspace descriptor (cudensitymatCreateWorkspace). The runtime allocates its scratch memory when an operator action is prepared.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

Results:#

Result

Description

workspace

Workspace buffer descriptor

cudm.destroy_elementary_op (::cudm::DestroyElementaryOpOp)#

Destroy an elementary tensor operator

Syntax:

operation ::= `cudm.destroy_elementary_op` $elem_op attr-dict `:` type($elem_op)

Destroys an elementary operator and frees its device data.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

elem_op

Elementary tensor operator acting on specific modes

cudm.destroy_expectation (::cudm::DestroyExpectationOp)#

Destroy expectation computation object

Syntax:

operation ::= `cudm.destroy_expectation` $expectation attr-dict `:` type($expectation)

Destroys an expectation object.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

expectation

Expectation value computation handle

cudm.destroy_handle (::cudm::DestroyHandleOp)#

Destroy cuDensityMat library context

Syntax:

operation ::= `cudm.destroy_handle` $handle attr-dict `:` type($handle)

Destroys a library context (cudensitymatDestroy) after everything created on it.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

cudm.destroy_op_term (::cudm::DestroyOpTermOp)#

Destroy an operator term

Syntax:

operation ::= `cudm.destroy_op_term` $op_term attr-dict `:` type($op_term)

Destroys an operator term and releases its envelope callbacks.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

op_term

Operator term: sum of products of elementary/matrix operators

cudm.destroy_operator (::cudm::DestroyOperatorOp)#

Destroy a composite operator

Syntax:

operation ::= `cudm.destroy_operator` $op attr-dict `:` type($op)

Destroys a composite operator.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

op

Composite operator / super-operator

cudm.destroy_state (::cudm::DestroyStateOp)#

Destroy a quantum state

Syntax:

operation ::= `cudm.destroy_state` $state attr-dict `:` type($state)

Destroys a state and frees its storage.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

state

Quantum state (pure or mixed, optionally batched)

cudm.destroy_workspace (::cudm::DestroyWorkspaceOp)#

Destroy a workspace descriptor

Syntax:

operation ::= `cudm.destroy_workspace` $workspace attr-dict `:` type($workspace)

Destroys a workspace descriptor and frees its memory.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

workspace

Workspace buffer descriptor

cudm.evolve (::cudm::EvolveOp)#

Time-evolve a quantum state under an operator

Syntax:

operation ::= `cudm.evolve` $handle `,` $op `,` $state_in `,` $state_out `,` $workspace attr-dict `:` type($handle) `,` type($op) `,` type($state_in) `,` type($state_out) `,` type($workspace) `->` type($result)

Evolves state_in under the operator from t_start to t_end in step_count equal steps of the integrator (rk1, rk2, rk4, magnus or crank_nicolson), writing the final state to state_out, which is also the result. cudm-to-llvm lowers it to the runtime’s cudm_evolve followed by a capture of the result for the host.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
integrator::cudm::IntegratorKindAttrTime-integration strategy
t_start::mlir::FloatAttr64-bit float attribute
t_end::mlir::FloatAttr64-bit float attribute
step_count::mlir::IntegerAttr64-bit signless integer attribute
compute_type::cudm::ComputeTypeAttrFloating-point compute precision; the runtime computes in complex128 only

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op

Composite operator / super-operator

state_in

Quantum state (pure or mixed, optionally batched)

state_out

Quantum state (pure or mixed, optionally batched)

workspace

Workspace buffer descriptor

Results:#

Result

Description

result

Quantum state (pure or mixed, optionally batched)

cudm.expectation_compute (::cudm::ExpectationComputeOp)#

Compute operator expectation value(s)

Syntax:

operation ::= `cudm.expectation_compute` $handle `,` $expectation `,` $time `,` $batch_size `,` $param_count `,` $params `,` $state `,` $workspace attr-dict `:` type($handle) `,` type($expectation) `,` type($params) `,` type($state) `,` type($workspace) `->` type($value)

The expectation value of an operator in state at time.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

expectation

Expectation value computation handle

time

64-bit float

batch_size

64-bit signless integer

param_count

32-bit signless integer

params

any type

state

Quantum state (pure or mixed, optionally batched)

workspace

Workspace buffer descriptor

Results:#

Result

Description

value

any type

cudm.init_handle (::cudm::InitHandleOp)#

Create cuDensityMat library context

Syntax:

operation ::= `cudm.init_handle` attr-dict `:` type($handle)

A cuDensityMat library context (cudensitymatCreate). The lowered program creates one per run, builds its states and operators on it and destroys it last; the run’s drive-envelope callbacks belong to it.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Results:#

Result

Description

handle

cuDensityMat library context handle

cudm.operator_append_term (::cudm::OperatorAppendTermOp)#

Append an operator term to a composite operator

Syntax:

operation ::= `cudm.operator_append_term` $handle `,` $op `,` $term attr-dict `:` type($handle) `,` type($op) `,` type($term)

Appends a term to a composite operator, weighted by coeff_real + i coeff_imag. With duality 1, every mode action of the term is flipped between the ket and bra sides; the lowering uses this for the bra half of -i [H, rho].

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
duality::mlir::IntegerAttr32-bit signless integer attribute
coeff_real::mlir::FloatAttr64-bit float attribute
coeff_imag::mlir::FloatAttr64-bit float attribute
callback::mlir::FlatSymbolRefAttrflat symbol reference attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op

Composite operator / super-operator

term

Operator term: sum of products of elementary/matrix operators

cudm.operator_compute_action (::cudm::OperatorComputeActionOp)#

Compute operator action: state_out += Op(t, params) * state_in

Syntax:

operation ::= `cudm.operator_compute_action` $handle `,` $op `,` $time `,` $batch_size `,` $param_count `,` $params `,` $state_in `,` $state_out `,` $workspace attr-dict `:` type($handle) `,` type($op) `,` type($params) `,` type($state_in) `,` type($state_out) `,` type($workspace)

Accumulates the action of an operator at time and parameters params on state_in into state_out (cudensitymatOperatorComputeAction).

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op

Composite operator / super-operator

time

64-bit float

batch_size

64-bit signless integer

param_count

32-bit signless integer

params

any type

state_in

Quantum state (pure or mixed, optionally batched)

state_out

Quantum state (pure or mixed, optionally batched)

workspace

Workspace buffer descriptor

cudm.operator_prepare_action (::cudm::OperatorPrepareActionOp)#

Prepare operator for action on quantum state

Syntax:

operation ::= `cudm.operator_prepare_action` $handle `,` $op `,` $state_in `,` $state_out `,` $workspace attr-dict `:` type($handle) `,` type($op) `,` type($state_in) `,` type($state_out) `,` type($workspace)

Prepares the action of an operator on states of the given shape within workspace_limit bytes of workspace (cudensitymatOperatorPrepareAction).

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
compute_type::cudm::ComputeTypeAttrFloating-point compute precision; the runtime computes in complex128 only
workspace_limit::mlir::IntegerAttr64-bit signless integer attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

op

Composite operator / super-operator

state_in

Quantum state (pure or mixed, optionally batched)

state_out

Quantum state (pure or mixed, optionally batched)

workspace

Workspace buffer descriptor

cudm.sse_evolve (::cudm::SSEEvolveOp)#

Stochastic Schrodinger equation ensemble evolution

Syntax:

operation ::= `cudm.sse_evolve` $handle `,` $hamiltonian `,` `(` $collapse_ops `)` `,` $initial_state `,` $workspace attr-dict `:` type($handle) `,` type($hamiltonian) `,` `(` type($collapse_ops) `)` `,` type($initial_state) `,` type($workspace) `->` type($result)

Evolves trajectory_count stochastic Schrodinger trajectories under a Hamiltonian and collapse operators from t_start to t_end in step_count steps, seeded by seed. The counts must be at least 1 and t_end later than t_start. Reserved for trajectory simulation; nothing lowers it yet.

Interfaces: MemoryEffectOpInterface (MemoryEffectOpInterface)

Effects: MemoryEffects::Effect{MemoryEffects::Write on ::mlir::SideEffects::DefaultResource}

Attributes:#

AttributeMLIR TypeDescription
integrator::cudm::IntegratorKindAttrTime-integration strategy
trajectory_count::mlir::IntegerAttr64-bit signless integer attribute
t_start::mlir::FloatAttr64-bit float attribute
t_end::mlir::FloatAttr64-bit float attribute
step_count::mlir::IntegerAttr64-bit signless integer attribute
seed::mlir::IntegerAttr64-bit signless integer attribute

Operands:#

Operand

Description

handle

cuDensityMat library context handle

hamiltonian

Composite operator / super-operator

collapse_ops

variadic of Elementary tensor operator acting on specific modes

initial_state

Quantum state (pure or mixed, optionally batched)

workspace

Workspace buffer descriptor

Results:#

Result

Description

result

Ensemble results from the SSE quantum trajectory solver

Attributes#

ComputeTypeAttr#

Floating-point compute precision; the runtime computes in complex128 only

Syntax:

#cudm.compute_type<
  ::cudm::ComputeType   # value
>

Parameters:#

Parameter

C++ type

Description

value

::cudm::ComputeType

an enum of type ComputeType

IntegratorKindAttr#

Time-integration strategy

Syntax:

#cudm.integrator<
  ::cudm::IntegratorKind   # value
>

Parameters:#

Parameter

C++ type

Description

value

::cudm::IntegratorKind

an enum of type IntegratorKind

SparsityAttr#

Elementary operator sparsity pattern

Syntax:

#cudm.sparsity<
  ::cudm::Sparsity   # value
>

Parameters:#

Parameter

C++ type

Description

value

::cudm::Sparsity

an enum of type Sparsity

StatePurityAttr#

Quantum state purity

Syntax:

#cudm.purity<
  ::cudm::StatePurity   # value
>

Parameters:#

Parameter

C++ type

Description

value

::cudm::StatePurity

an enum of type StatePurity

Types#

DecoherenceModelType#

T1/T2 decoherence parameters per qubit mode

Syntax: !cudm.decoherence_model

ElementaryOpType#

Elementary tensor operator acting on specific modes

Syntax: !cudm.elementary_op

ExpectationType#

Expectation value computation handle

Syntax: !cudm.expectation

HandleType#

CuDensityMat library context handle

Syntax: !cudm.handle

MatrixOpType#

Full matrix operator acting on all modes

Syntax: !cudm.matrix_op

OpActionType#

Aggregate operator action for coupled ODE systems

Syntax: !cudm.op_action

OpTermType#

Operator term: sum of products of elementary/matrix operators

Syntax: !cudm.op_term

OperatorType#

Composite operator / super-operator

Syntax: !cudm.operator

SpectrumType#

Operator eigenspectrum computation handle

Syntax: !cudm.spectrum

StateType#

Quantum state (pure or mixed, optionally batched)

Syntax: !cudm.state

TrajectoryResultType#

Ensemble results from the SSE quantum trajectory solver

Syntax: !cudm.trajectory_result

WorkspaceType#

Workspace buffer descriptor

Syntax: !cudm.workspace

Enums#

ComputeType#

Floating-point compute precision; the runtime computes in complex128 only

Cases:#

Symbol

Value

String

F64

16

f64

IntegratorKind#

Time-integration strategy

Cases:#

Symbol

Value

String

RungeKutta1

2

rk1

RungeKutta2

3

rk2

RungeKutta4

4

rk4

Magnus

5

magnus

CrankNicolson

6

crank_nicolson

Sparsity#

Elementary operator sparsity pattern

Cases:#

Symbol

Value

String

None

0

none

Multidiagonal

1

multidiagonal

StatePurity#

Quantum state purity

Cases:#

Symbol

Value

String

Pure

0

pure

Mixed

1

mixed