Skip to main content

muBLASLt API Reference

This document describes the muBLASLt APIs supported in MUSA SDK 5.2. It starts with the muBLASLt programming model, then documents the supported matrix multiplication and descriptor APIs.

1. Introduction

1.1 What Is muBLASLt

muBLASLt is the lightweight matrix multiplication extension library for muBLAS. It provides descriptor-based matrix multiplication APIs that let applications describe operation attributes, matrix layouts, algorithm choices, workspace, stream execution, and floating-point emulation settings.

1.2 Document Scope in MUSA SDK 5.2

This reference describes the muBLASLt APIs supported in MUSA SDK 5.2. Use it as the compatibility reference for the functions, types, descriptor attributes, and status values documented here.

Note: Some muBLASLt declarations may appear in mublasLt.h but are not described in this reference. These declarations are experimental in MUSA SDK 5.2 and are provided for reference only.

1.3 Supported API Groups

API groupScoped APIs
Matrix multiplicationmublasLtMatmul
Matmul descriptor attributesmublasLtMatmulDescSetAttribute
Floating-point emulation descriptorsmublasLtEmulationDescInit_internal, mublasLtEmulationDescCreate, mublasLtEmulationDescDestroy, mublasLtEmulationDescSetAttribute, mublasLtEmulationDescGetAttribute

1.4 How to Use This Document

Start with Chapter 2 for the descriptor-based usage model. Use Chapter 3 to check status values, datatypes, descriptor attributes, function signatures, parameter lists, return values, and supported API entries.

2. Using the muBLASLt API

2.1 Matmul Operation Model

mublasLtMatmul computes:

D = alpha * op(A) * op(B) + beta * C

The operation is configured by the function arguments and the supplied descriptors. The computeDesc argument describes operation-level attributes such as transpose mode, scaling behavior, epilogue behavior, and optional emulation configuration. The Adesc, Bdesc, Cdesc, and Ddesc arguments describe the memory layout of each matrix operand.

The scalar arguments alpha and beta are passed as pointers. Their interpretation depends on descriptor settings such as scale type and pointer mode. The matrix arguments A, B, C, and D point to the input and output matrix data used by the operation.

The algo, workspace, and workspaceSizeInBytes arguments describe the algorithm configuration and available temporary storage. If the configured algorithm requires more workspace than workspaceSizeInBytes provides, mublasLtMatmul returns MUBLAS_STATUS_INVALID_VALUE.

2.2 Descriptor Attribute Model

muBLASLt uses descriptors to separate operation configuration from execution. Attribute setter APIs use the same basic pattern:

  1. Select a descriptor attribute enum value.
  2. Store the new attribute value in a buffer.
  3. Pass the buffer pointer and the exact value size in bytes.
  4. Check the returned mublasStatus_t.

mublasLtMatmulDescSetAttribute sets attributes on a matmul operation descriptor. mublasLtEmulationDescSetAttribute and mublasLtEmulationDescGetAttribute set and query attributes on a floating-point emulation descriptor.

For setter APIs, buf must point to the new value and sizeInBytes must match the internal storage size for the selected attribute. For getter APIs, buf receives the attribute value. If sizeInBytes is 0, sizeWritten can be used to query the number of bytes required for the full value.

2.3 Floating-Point Emulation Descriptor

The emulation descriptor stores floating-point emulation settings that can be attached to a matmul descriptor through MUBLASLT_MATMUL_DESC_EMULATION_DESCRIPTOR.

Use mublasLtEmulationDescInit_internal to initialize an emulation descriptor in caller-provided storage when the storage lifetime is managed outside the library. The current header also defines the inline convenience wrapper mublasLtEmulationDescInit, which forwards sizeof(*emulationDesc) to mublasLtEmulationDescInit_internal.

Use mublasLtEmulationDescCreate to allocate a descriptor through the library, and release that descriptor with mublasLtEmulationDescDestroy when it is no longer needed. Use the set and get attribute APIs to configure or query the emulation strategy, special-values behavior, and fixed-point mantissa controls.

2.4 Stream Usage

mublasLtMatmul takes a musaStream_t argument. The stream identifies where the matrix multiplication work is issued. Keep the stream, workspace, descriptors, and data buffers valid for the duration of the queued operation.

2.5 Error Handling

The supported muBLASLt APIs return mublasStatus_t. Check the return value after each call, especially for descriptor creation, attribute updates, and matrix multiplication calls that depend on descriptor compatibility, workspace size, and device support.

For status values used by the supported APIs, see 3.1 Return Value mublasStatus_t.

3. API Reference

This chapter describes muBLASLt status values, datatypes, descriptor attributes, and library functions. Function entries include signatures, parameters, return values, and descriptions derived from public header comments. APIs that may appear in public headers but are not documented here should be treated as experimental and for reference only in this release.

3.1 Return Value mublasStatus_t

Most supported muBLASLt APIs return mublasStatus_t. A return value of MUBLAS_STATUS_SUCCESS indicates that the call completed successfully. Any other value indicates that the call did not complete as requested.

The following table lists the status values emitted by the supported muBLASLt API entries in this reference.

Status valueMeaning
MUBLAS_STATUS_SUCCESSThe operation completed successfully.
MUBLAS_STATUS_NOT_INITIALIZEDThe muBLASLt handle has not been initialized.
MUBLAS_STATUS_INVALID_VALUEOne or more parameters are in conflict, invalid, null when required, or in an unsupported configuration.
MUBLAS_STATUS_NOT_SUPPORTEDThe selected device or implementation does not support the configured operation.
MUBLAS_STATUS_ARCH_MISMATCHThe configured operation cannot run on the selected device architecture.
MUBLAS_STATUS_EXECUTION_FAILEDMUSA reported a device execution error.
MUBLAS_STATUS_ALLOC_FAILEDMemory allocation failed.

3.2 muBLASLt Datatypes Reference

This section summarizes the public types that appear in the supported MUSA SDK 5.2 muBLASLt API signatures or descriptor attributes.

TypePurpose
mublasLtHandle_tOpaque muBLASLt context handle passed to mublasLtMatmul.
mublasLtMatrixLayout_tOpaque descriptor for matrix memory layout.
mublasLtMatmulAlgo_tSemi-opaque algorithm descriptor used by mublasLtMatmul.
mublasLtMatmulDesc_tOpaque descriptor for matrix multiplication operation details.
mublasLtMatmulDescAttributes_tAttribute selector used by mublasLtMatmulDescSetAttribute.
mublasLtEmulationDesc_tOpaque descriptor for floating-point emulation properties.
mublasLtEmulationDescAttributes_tAttribute selector used by emulation descriptor set and get APIs.
mublasStatus_tReturn type used by the supported muBLASLt APIs.
mublasComputeType_tCompute-precision selector used by matmul descriptor attributes.
mublasOperation_tOperation selector used by matmul descriptor attributes to control transpose behavior.
mublasFillMode_tFill-mode selector used by matmul descriptor attributes.
mublasLtPointerMode_tPointer-location selector used by matmul descriptor attributes for alpha and beta.
mublasLtEpilogue_tEpilogue selector used by matmul descriptor attributes.
musaDataType_tData-type selector used by matrix layouts and descriptor attributes.
musaStream_tMUSA stream handle passed to mublasLtMatmul.

3.2.1 Matmul Descriptor Attributes

mublasLtMatmulDescAttributes_t selects the matmul descriptor attribute to set. Attribute support can depend on the configured data types, scale types, layouts, device, and epilogue. Unsupported combinations can return MUBLAS_STATUS_INVALID_VALUE or MUBLAS_STATUS_NOT_SUPPORTED.

AttributeValue type and defaultPurpose
MUBLASLT_MATMUL_DESC_COMPUTE_TYPEint32_tSelects the data type used for multiply and accumulate operations and the accumulator.
MUBLASLT_MATMUL_DESC_SCALE_TYPEint32_t; default is the compute typeSelects the data type of alpha and beta.
MUBLASLT_MATMUL_DESC_POINTER_MODEint32_t; default is MUBLASLT_POINTER_MODE_HOSTSelects the pointer mode for alpha and beta.
MUBLASLT_MATMUL_DESC_TRANSAint32_t; default is MUBLAS_OP_NSelects the transform for matrix A.
MUBLASLT_MATMUL_DESC_TRANSBint32_t; default is MUBLAS_OP_NSelects the transform for matrix B.
MUBLASLT_MATMUL_DESC_TRANSCint32_t; default is MUBLAS_OP_NSelects the transform for matrix C. Currently only MUBLAS_OP_N is supported.
MUBLASLT_MATMUL_DESC_FILL_MODEint32_t; default is MUBLAS_FILL_MODE_FULLSelects the matrix fill mode.
MUBLASLT_MATMUL_DESC_EPILOGUEuint32_t; default is MUBLASLT_EPILOGUE_DEFAULTSelects the epilogue function.
MUBLASLT_MATMUL_DESC_BIAS_POINTERconst void * or void *; default is NULLProvides the device pointer for a bias or bias-gradient vector.
MUBLASLT_MATMUL_DESC_BIAS_BATCH_STRIDEint64_t; default is 0Provides the batch stride for the bias or bias-gradient vector.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_POINTERvoid * or const void *; default is NULLProvides the auxiliary buffer pointer used by supported epilogue modes.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_LDint64_t; default is 0Provides the leading dimension for the epilogue auxiliary buffer.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_BATCH_STRIDEint64_t; default is 0Provides the batch stride for the epilogue auxiliary buffer.
MUBLASLT_MATMUL_DESC_ALPHA_VECTOR_BATCH_STRIDEint64_t; default is 0Provides the batch stride for alpha-vector pointer modes.
MUBLASLT_MATMUL_DESC_SM_COUNT_TARGETint32_t; default is 0Targets a number of SMs for parallel execution. A value of 0 uses the device-reported count.
MUBLASLT_MATMUL_DESC_A_SCALE_POINTERconst void *; default is NULLProvides the device pointer to the scale factor for matrix A.
MUBLASLT_MATMUL_DESC_B_SCALE_POINTERconst void *; default is NULLProvides the device pointer to the scale factor for matrix B.
MUBLASLT_MATMUL_DESC_C_SCALE_POINTERconst void *; default is NULLProvides the device pointer to the scale factor for matrix C.
MUBLASLT_MATMUL_DESC_D_SCALE_POINTERconst void *; default is NULLProvides the device pointer to the scale factor for matrix D.
MUBLASLT_MATMUL_DESC_AMAX_D_POINTERvoid *; default is NULLProvides the device pointer that receives the maximum absolute value in the output matrix.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_DATA_TYPEint32_t based on musaDataType_t; default is -1Selects the data type stored in the epilogue auxiliary buffer.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_SCALE_POINTERvoid *; default is NULLProvides the device pointer to the scale factor for the auxiliary matrix.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_AMAX_POINTERvoid *; default is NULLProvides the device pointer that receives the maximum absolute value in the auxiliary buffer.
MUBLASLT_MATMUL_DESC_FAST_ACCUMint8_t; default is 0Enables or disables FP8 fast accumulation.
MUBLASLT_MATMUL_DESC_BIAS_DATA_TYPEint32_t based on musaDataType_t; default is -1Selects the data type of the bias or bias-gradient vector.
MUBLASLT_MATMUL_DESC_A_SCALE_MODEint32_t; default is 0Selects how the matrix A scale factor is interpreted.
MUBLASLT_MATMUL_DESC_B_SCALE_MODEint32_t; default is 0Selects how the matrix B scale factor is interpreted.
MUBLASLT_MATMUL_DESC_C_SCALE_MODEint32_t; default is 0Selects how the matrix C scale factor is interpreted.
MUBLASLT_MATMUL_DESC_D_SCALE_MODEint32_t; default is 0Selects how the matrix D scale factor is interpreted.
MUBLASLT_MATMUL_DESC_EPILOGUE_AUX_SCALE_MODEint32_t; default is 0Selects how the auxiliary matrix scale factor is interpreted.
MUBLASLT_MATMUL_DESC_D_OUT_SCALE_POINTERvoid *; default is NULLProvides the device pointer to the scale factors used to convert matrix D output data.
MUBLASLT_MATMUL_DESC_D_OUT_SCALE_MODEint32_t; default is 0Selects how the output matrix D scale factor is interpreted.
MUBLASLT_MATMUL_DESC_EMULATION_DESCRIPTORmublasLtEmulationDesc_t; default is NULLAttaches a floating-point emulation descriptor to the matmul operation.
MUBLASLT_MATMUL_DESC_ALPHA_BATCH_STRIDEint64_t; default is 0Provides the batch stride for alpha.
MUBLASLT_MATMUL_DESC_BETA_BATCH_STRIDEint64_t; default is 0Provides the batch stride for beta.

3.2.2 Emulation Descriptor Attributes

mublasLtEmulationDescAttributes_t selects the floating-point emulation descriptor attribute to set or query.

AttributeValue type and defaultPurpose
MUBLASLT_EMULATION_DESC_STRATEGYint32_t; default is 0Selects when to use floating-point emulation algorithms.
MUBLASLT_EMULATION_DESC_SPECIAL_VALUES_SUPPORTint32_t; default is 0xFFFFSelects special floating-point values that must be supported.
MUBLASLT_EMULATION_DESC_FIXEDPOINT_MANTISSA_CONTROLint32_t; default is 0Selects how fixed-point emulation computes retained mantissa bits.
MUBLASLT_EMULATION_DESC_FIXEDPOINT_MAX_MANTISSA_BIT_COUNTint32_t; default is 0Sets the maximum number of mantissa bits retained during fixed-point emulation.
MUBLASLT_EMULATION_DESC_FIXEDPOINT_MANTISSA_BIT_OFFSETint32_t; default is 0Biases the recommended mantissa bit count for dynamic mantissa control.
MUBLASLT_EMULATION_DESC_FIXEDPOINT_MANTISSA_BIT_COUNT_POINTERint32_t *; default is NULLPoints to device memory that receives the number of mantissa bits retained. If emulation is not used, the value is -1.

3.3 Matrix Multiplication Reference

This section covers the supported matrix multiplication API.

mublasLtMatmul

mublasStatus_t MUBLASWINAPI mublasLtMatmul(
mublasLtHandle_t lightHandle,
mublasLtMatmulDesc_t computeDesc,
const void *alpha,
const void *A,
mublasLtMatrixLayout_t Adesc,
const void *B,
mublasLtMatrixLayout_t Bdesc,
const void *beta,
const void *C,
mublasLtMatrixLayout_t Cdesc,
void *D,
mublasLtMatrixLayout_t Ddesc,
const mublasLtMatmulAlgo_t *algo,
void *workspace,
size_t workspaceSizeInBytes,
musaStream_t stream)

Description

Executes matrix multiplication:

D = alpha * op(A) * op(B) + beta * C

Parameters

ParameterTypeDescription
lightHandlemublasLtHandle_tmuBLASLt library context handle.
computeDescmublasLtMatmulDesc_tMatmul operation descriptor.
alphaconst void *Pointer to the scale factor applied to op(A) * op(B).
Aconst void *Pointer to matrix A data.
AdescmublasLtMatrixLayout_tMatrix layout descriptor for A.
Bconst void *Pointer to matrix B data.
BdescmublasLtMatrixLayout_tMatrix layout descriptor for B.
betaconst void *Pointer to the scale factor applied to matrix C.
Cconst void *Pointer to matrix C data.
CdescmublasLtMatrixLayout_tMatrix layout descriptor for C.
Dvoid *Pointer to matrix D output data.
DdescmublasLtMatrixLayout_tMatrix layout descriptor for D.
algoconst mublasLtMatmulAlgo_t *Algorithm descriptor for the operation.
workspacevoid *Temporary workspace buffer.
workspaceSizeInBytessize_tSize of the workspace buffer, in bytes.
streammusaStream_tMUSA stream used to issue the operation.

Returns

Status valueMeaning
MUBLAS_STATUS_NOT_INITIALIZEDThe muBLASLt handle has not been initialized.
MUBLAS_STATUS_INVALID_VALUEParameters are in conflict or in an impossible configuration. This includes a workspace size smaller than the configured algorithm requires.
MUBLAS_STATUS_NOT_SUPPORTEDThe current implementation on the selected device does not support the configured operation.
MUBLAS_STATUS_ARCH_MISMATCHThe configured operation cannot run on the selected device.
MUBLAS_STATUS_EXECUTION_FAILEDMUSA reported a device execution error.
MUBLAS_STATUS_SUCCESSThe operation completed successfully.

3.4 Matmul Descriptor Reference

This section covers the supported API for setting matmul operation descriptor attributes.

mublasLtMatmulDescSetAttribute

mublasStatus_t MUBLASWINAPI mublasLtMatmulDescSetAttribute(
mublasLtMatmulDesc_t matmulDesc,
mublasLtMatmulDescAttributes_t attr,
const void *buf,
size_t sizeInBytes)

Description

Sets an attribute on a matmul operation descriptor.

Parameters

ParameterTypeDescription
matmulDescmublasLtMatmulDesc_tMatmul operation descriptor.
attrmublasLtMatmulDescAttributes_tAttribute to set.
bufconst void *Pointer to the new attribute value.
sizeInBytessize_tSize of the value in buf, in bytes.

Returns

Status valueMeaning
MUBLAS_STATUS_INVALID_VALUEbuf is NULL, or sizeInBytes does not match the internal storage size for the selected attribute.
MUBLAS_STATUS_SUCCESSThe attribute was set successfully.

3.5 Emulation Descriptor Reference

This section covers the supported APIs for creating, destroying, setting, and querying floating-point emulation descriptors.

mublasLtEmulationDescInit_internal

mublasStatus_t MUBLASWINAPI mublasLtEmulationDescInit_internal(
mublasLtEmulationDesc_t emulationDesc,
size_t size)

Description

Initializes an emulation descriptor in pre-allocated space.

The current MUSA SDK 5.2 header also defines the inline convenience wrapper mublasLtEmulationDescInit, which forwards sizeof(*emulationDesc) to this exported symbol.

Parameters

ParameterTypeDescription
emulationDescmublasLtEmulationDesc_tEmulation descriptor to initialize.
sizesize_tSize of the pre-allocated descriptor storage, in bytes.

Returns

Status valueMeaning
MUBLAS_STATUS_ALLOC_FAILEDThe size of the pre-allocated space is insufficient.
MUBLAS_STATUS_SUCCESSThe descriptor was initialized successfully.

mublasLtEmulationDescCreate

mublasStatus_t MUBLASWINAPI mublasLtEmulationDescCreate(
mublasLtEmulationDesc_t *emulationDesc)

Description

Creates an emulation descriptor.

Parameters

ParameterTypeDescription
emulationDescmublasLtEmulationDesc_t *Output pointer that receives the created emulation descriptor.

Returns

Status valueMeaning
MUBLAS_STATUS_ALLOC_FAILEDMemory could not be allocated.
MUBLAS_STATUS_SUCCESSThe descriptor was created successfully.

mublasLtEmulationDescDestroy

mublasStatus_t MUBLASWINAPI mublasLtEmulationDescDestroy(
mublasLtEmulationDesc_t emulationDesc)

Description

Destroys an emulation descriptor.

Parameters

ParameterTypeDescription
emulationDescmublasLtEmulationDesc_tEmulation descriptor to destroy.

Returns

Status valueMeaning
MUBLAS_STATUS_SUCCESSThe operation completed successfully.

mublasLtEmulationDescSetAttribute

mublasStatus_t MUBLASWINAPI mublasLtEmulationDescSetAttribute(
mublasLtEmulationDesc_t emulationDesc,
mublasLtEmulationDescAttributes_t attr,
const void *buf,
size_t sizeInBytes)

Description

Sets an attribute on an emulation descriptor.

Parameters

ParameterTypeDescription
emulationDescmublasLtEmulationDesc_tEmulation descriptor.
attrmublasLtEmulationDescAttributes_tAttribute to set.
bufconst void *Pointer to the new attribute value.
sizeInBytessize_tSize of the value in buf, in bytes.

Returns

Status valueMeaning
MUBLAS_STATUS_INVALID_VALUEbuf is NULL, or sizeInBytes does not match the internal storage size for the selected attribute.
MUBLAS_STATUS_SUCCESSThe attribute was set successfully.

mublasLtEmulationDescGetAttribute

mublasStatus_t MUBLASWINAPI mublasLtEmulationDescGetAttribute(
mublasLtEmulationDesc_t emulationDesc,
mublasLtEmulationDescAttributes_t attr,
void *buf,
size_t sizeInBytes,
size_t *sizeWritten)

Description

Gets an attribute from an emulation descriptor.

Parameters

ParameterTypeDescription
emulationDescmublasLtEmulationDesc_tEmulation descriptor.
attrmublasLtEmulationDescAttributes_tAttribute to query.
bufvoid *Destination buffer that receives the attribute value.
sizeInBytessize_tSize of the destination buffer, in bytes.
sizeWrittensize_t *Output pointer that receives the number of bytes written when sizeInBytes is non-zero, or the number of bytes required when sizeInBytes is 0.

Returns

Status valueMeaning
MUBLAS_STATUS_INVALID_VALUEsizeInBytes is 0 and sizeWritten is NULL, or sizeInBytes is non-zero and buf is NULL, or sizeInBytes does not match the internal storage size for the selected attribute.
MUBLAS_STATUS_SUCCESSThe attribute value was written to user memory successfully.