cuSPARSELt 数据类型#
不透明数据结构#
cusparseLtHandle_t#
该结构体保存了cuSPARSELt库的上下文(设备属性、系统信息等)。The handle must be initialized and destroyed with cusparseLtInit() and cusparseLtDestroy() functions respectively.
cusparseLtMatDescriptor_t#
该结构捕获了矩阵的形状和特征。It is initialized with cusparseLtDenseDescriptorInit() or cusparseLtStructuredDescriptorInit() functions and destroyed with cusparseLtMatDescriptorDestroy().
cusparseLtMatmulDescriptor_t#
该结构体用于描述矩阵乘法运算。It is initialized with cusparseLtMatmulDescriptorInit() function.
cusparseLtMatmulAlgSelection_t#
该结构体用于描述矩阵乘法算法的相关信息。It is initialized with cusparseLtMatmulAlgSelectionInit() function.
cusparseLtMatmulPlan_t#
The structure holds the matrix multiplication execution plan, namely all the information necessary to execute thecusparseLtMatmul()operation.It is initialized and destroyed with cusparseLtMatmulPlanInit() and cusparseLtMatmulPlanDestroy() functions respectively.
枚举器#
cusparseLtSparsity_t#
枚举器将结构化矩阵的稀疏比率指定为
值 |
描述 |
|---|---|
|
50% 稀疏比例: - 配对4:8 用于 - 1:2 对应 |
The sparsity property is used in the cusparseLtStructuredDescriptorInit() function.
cusparseComputeType#
枚举器指定了矩阵的计算精度模式
值 |
描述 |
|---|---|
|
- 对矩阵A和B进行逐元素乘法运算,中间值的累加采用32位整数精度执行。 - Alpha和beta系数以及尾声部分使用单精度浮点数执行。 - 在可能的情况下将使用Tensor Cores。 |
|
- 对矩阵A和B进行逐元素乘法运算,中间结果的累加采用单精度浮点数完成。 - Alpha和beta系数以及尾声部分使用单精度浮点数执行。 - 在可能的情况下将使用Tensor Cores。 |
|
- 对矩阵A和B进行逐元素乘法运算,中间值的累加采用半精度浮点数完成。 - Alpha和beta系数以及尾声部分使用单精度浮点数执行。 - 在可能的情况下将使用Tensor Cores。 |
The compute precision is used in the cusparseLtMatmulDescriptorInit() function.
cusparseLtMatDescAttribute_t#
枚举器指定了矩阵描述符的附加属性
值 |
描述 |
|---|---|
|
批处理中的矩阵数量 |
|
批次中连续矩阵之间的步长,以矩阵元素表示 |
The algorithm enumerator is used in the cusparseLtMatDescSetAttribute() and cusparseLtMatDescGetAttribute() functions.
cusparseLtMatmulDescAttribute_t#
枚举器指定了矩阵乘法描述符的附加属性
值 |
类型 |
默认值 |
描述 |
|---|---|---|---|
|
|
|
ReLU激活函数 |
|
|
|
ReLU激活函数的上界 |
|
|
|
ReLU激活函数的下限阈值 |
|
|
|
|
|
|
|
GeLU激活函数的缩放系数。它表示 |
|
|
|
启用/禁用 alpha 向量(逐通道)缩放 |
|
|
|
启用/禁用测试版向量(每通道)缩放功能。 |
|
|
|
偏置指针。偏置向量的大小必须等于输出矩阵(D)的行数。 偏置向量的数据类型与矩阵C相同,以下情况除外:
其中偏置的数据类型为 |
|
|
|
连续偏置向量之间的偏置步长。 |
|
|
|
指向修剪后的稀疏矩阵的指针。 |
|
|
|
定义如何解释矩阵A的矩阵缩放因子的缩放模式。 |
|
|
|
缩放模式,定义如何解释矩阵B的矩阵缩放因子。 |
|
|
|
定义如何解释矩阵C的矩阵缩放因子的缩放模式。 |
|
|
|
缩放模式,定义如何解释矩阵D的矩阵缩放因子。 |
|
|
|
定义如何解释矩阵D的输出矩阵缩放因子的缩放模式。 |
|
|
|
指向将矩阵A中的数据转换为计算数据类型范围的缩放因子值的指针。 缩放因子必须与计算类型相同。如果未指定, 则假定缩放因子为1。 |
|
|
|
等同于矩阵B的 |
|
|
|
相当于矩阵C的 |
|
|
|
相当于矩阵D的 |
|
|
|
指向比例因子的设备指针,这些比例因子用于将矩阵D中的数据转换为计算数据类型范围。比例因子值类型由缩放模式定义(参见 |
其中ReLU激活函数的定义为:
CUSPARSELT_MATMUL_SPARSE_MAT_POINTER为 cusparseLtMatmulSearch() 提供了更大的灵活性来选择最佳算法。在被调用之前,所引用的内存不能被修改。
cusparseLtMatmulAlg_t#
该枚举器指定了矩阵-矩阵乘法的算法
值 |
描述 |
|---|---|
|
默认算法 |
The algorithm enumerator is used in the cusparseLtMatmulAlgSelectionInit() function.
cusparseLtMatmulAlgAttribute_t#
枚举器指定了矩阵乘法算法的属性
值 |
描述 |
可选值 |
|---|---|---|
|
算法ID |
[0, MAX) (参见 |
|
算法ID限制(仅查询) |
|
|
cusparseLtMatmulSearch() 的迭代次数(每次算法的内核启动次数) |
> 0 (默认=5) |
|
Split-K因子(切片数量) |
在 |
|
Split-K算法使用的内核数量 |
|
|
用于存储归约操作部分结果的设备内存缓冲区 |
在 |
The algorithm attribute enumerator is used in the cusparseLtMatmulAlgGetAttribute() and cusparseLtMatmulAlgSetAttribute() functions.Split-K parameters allow users to split the GEMM computation along the K dimension so that more CTAs will be created with a better SM utilization when N or M dimensions are small. However, this comes with the cost of reducing the operation of K slides to the final results. The cusparseLtMatmulSearch() function can be used to find the optimal combination of Split-K parameters.Segment-K is a split-K method onSM 9.0that utilizes warp-specialized persistent CTAs for enhanced efficiency and replaces the tranditional split-K method.
cusparseLtSplitKMode_t#
The enumerator specifies the Split-K mode values corresponding toCUSPARSELT_MATMUL_SPLIT_K_MODEattribute in cusparseLtMatmulAlgAttribute_t
值 |
描述 |
|---|---|
|
为Split-K使用单一内核 |
|
使用两个内核实现Split-K:一个GPU内核执行GEMM运算,另一个执行最终归约 |
|
使用split-k分解 |
|
不沿K维度分割 |
|
使用流式K分解 |
|
使用启发式方法确定分解模式 | 启动另一个GPU内核执行最终归约 |
cusparseLtPruneAlg_t#
枚举器指定在压缩前应用于结构化矩阵的剪枝算法
值 |
描述 |
|---|---|
|
- - - |
|
- - - 条带方向是根据操作 |
The pruning algorithm is used in the cusparseLtSpMMAPrune() function.
cusparseLtMatmulMatrixScale_t#
该枚举器指定了缩放模式,用于定义如何解释缩放因子指针。
值 |
描述 |
|---|---|
|
缩放功能已禁用。这是默认设置,也是不使用窄数据类型的矩阵唯一有效的值。 |
|
缩放因子是应用于整个矩阵的单精度标量。当D矩阵使用窄精度数据类型时,这是 |
|
缩放因子是张量,其中包含针对对应数据矩阵最内层维度中每个32元素块存储的专用缩放因子,以8位 |
|
缩放因子是张量,其中包含针对对应数据矩阵最内维度中每个64元素块的专用缩放因子,存储为8位 |
cusparrseLtMatmulMatrixScale_t is introduced for narrow precisions (E4M3 and E2M1) to be scaled or dequantized before and potentially quantized after computations. See FP8和FP4数据类型的1D块缩放 for more details. The translation from row and column indices to linear offset is the same, as well as how multiple blocks are arranged. The only difference with cuBLASLt is the block size: in cuSPARSELt a single tile of scaling factors is applied to a 128x128 block when the scaling mode is CUSPARSELT_MATMUL_MATRIX_SCALE_VEC32_UE4M3 and to a 128x256 block when it is CUSPARSELT_MATMUL_MATRIX_SCALE_VEC64_UE8M0.