Name Strings
SPV_NV_cooperative_vector
Contact
To report problems with this extension, please open a new issue at:
Contributors
-
Jeff Bolz, NVIDIA
-
Karthik Vaidyanathan, NVIDIA
-
Yury Uralsky, NVIDIA
-
Sean Treichler, NVIDIA
-
Eric Werness, NVIDIA
Notice
Copyright (c) 2023-2025 NVIDIA Corporation
Status
-
Complete
Version
Last Modified Date |
2024-07-25 |
Revision |
2 |
Dependencies
This extension is written against the SPIR-V Specification, Version 1.6, Revision 2, Unified.
This extension requires SPIR-V 1.6.
This extension interacts with SPV_KHR_physical_storage_buffer.
Overview
This extension adds a new set of types known as "cooperative vector" types. Unlike cooperative matrix types, a variable with a cooperative vector type is logically stored in the invocation it belongs to, but they can opportunistically cooperate behind the scenes when performing matrix-vector multiplies. Cooperative vectors don’t require a fully occupied subgroup or uniform control flow like cooperative matrices, although these do increase the likelihood of being on the fast path. And unlike normal vector types, they have arbitrary length and support a relatively limited set of operations. These types are intended to help accelerate the evaluation of small neural networks, where each invocation is performing its own independent evaluation of the network.
This extension introduces the types and instructions, but does not specify rules about what types are supported. This is left to the client API specifications, and it is expected that different implementations may support different types.
Extension Name
To use this extension within a SPIR-V module, the following OpExtension must be present in the module:
OpExtension "SPV_NV_cooperative_vector"
Modifications to the SPIR-V Specification, Version 1.6
2.2 Terms
Add new terms to section 2.2.2 Types:
Cooperative Vector: An ordered homogeneous collection of one or more scalars. The number of components is not as limited as normal vector types. Cooperative Vectors are optimized for matrix-vector multiplies. The set of supported component types is defined by the client API.
Add Cooperative Vector to the definition of Abstract Type.
Add Cooperative Vector to the definition of Composite. A cooperative vector is a composite with a number of components equal to the component count declared in its type. It can be used as a composite for all operations that act on composite types. It can be used for OpVectorExtractDynamic and OpVectorInsertDynamic, but not OpVectorShuffle.
2.16 Validation Rules
Modify section 2.16.1. Universal Validation Rules:
-
Add OpCooperativeVectorMatrixMulNV, OpCooperativeVectorMatrixMulAddNV, OpCooperativeVectorLoadNV, OpCooperativeVectorStoreNV, OpCooperativeVectorOuterProductAccumulateNV, and OpCooperativeVectorReduceSumAccumulateNV to the list of instructions under "It is invalid for a pointer to be an operand to any instruction other than:", when the Logical addressing model is selected and neither the VariablePointers nor VariablePointersStorageBuffer capability are declared.
-
Cooperative vector types (or types containing them) can only be allocated in Function or Private storage classes.
Modify section 2.16.2. Validation Rules for Shader Capabilities:
Add:
-
If the CooperativeVectorNV capability is declared then the VulkanMemoryModel capability must be declared as well.
3.26 Memory Operands
Modify Section 3.26, "Memory Operands":
In the description of MakePointerAvailable, change "Not valid with OpLoad" to "Not valid with OpLoad or OpCooperativeVectorLoadNV".
In the description of MakePointerVisible, change "Not valid with OpStore" to "Not valid with OpStore or OpCooperativeVectorStoreNV".
3.31 Capabilities
Modify Section 3.31, "Capability", adding these rows to the Capability table:
Capability | Enabling Capabilities | |
---|---|---|
5394 |
CooperativeVectorNV |
|
5435 |
CooperativeVectorTrainingNV |
3.X Cooperative Vector Matrix Layout
New section in 3 "Binary Form".
Cooperative Vector Matrix Layout | Enabling Capabilities | |
---|---|---|
0 |
RowMajorNV |
|
1 |
ColumnMajorNV |
|
2 |
InferencingOptimalNV |
|
3 |
TrainingOptimalNV |
Component Type | Enabling Capabilities | |
---|---|---|
0 |
Float16NV |
|
1 |
Float32NV |
|
2 |
Float64NV |
|
3 |
SignedInt8NV |
|
4 |
SignedInt16NV |
|
5 |
SignedInt32NV |
|
6 |
SignedInt64NV |
|
7 |
UnsignedInt8NV |
|
8 |
UnsignedInt16NV |
|
9 |
UnsignedInt32NV |
|
10 |
UnsignedInt64NV |
|
1000491000 |
SignedInt8PackedNV |
|
1000491001 |
UnsignedInt8PackedNV |
|
1000491002 |
FloatE4M3NV |
|
1000491003 |
FloatE5M2NV |
3.42.6 Type-Declaration Instructions
3.42.8 Memory Instructions
3.42.11 Conversion Instructions
Allow cooperative vector types for the following conversion instructions (if the component types are appropriate): OpConvertFToU, OpConvertFToS, OpConvertSToF, OpConvertUToF, OpUConvert, OpSConvert, OpFConvert. The result type and value type must have the same Component Count.
Allow cooperative vector types for OpBitcast. The result type and value type must have the same number of components and same number of bits per component.
3.42.13 Arithmetic Instructions
Allow cooperative vector types for the following arithmetic instructions:
-
OpSNegate and OpFNegate
-
OpIAdd, OpFAdd, OpISub, OpFSub, OpFMul, OpIMul, OpFDiv, OpSDiv, and OpUDiv.
if their Component Type is appropriate:
-
OpF instructions can be used with cooperative vector types whose Component Type is a floating-point type.
-
OpI, OpS, and OpU instructions can be used with cooperative vector types whose Component Type is an integer type.
Unary arithmetic instructions operate on the individual elements of the cooperative vector.
Binary arithmetic instructions operate on the individual elements of a pair of cooperative vectors whose type must match.
Allow floating point cooperative vector types for OpVectorTimesScalar.
Allow cooperative vector types for the following GLSL.std.450 extended instruction set instructions:
-
FMin, UMin, SMin, NMin, FMax, UMax, SMax, NMax, FClamp, UClamp, SClamp, NClamp, Step, Exp, Log, Tanh, Atan, and Fma
if their Component Type is appropriate.
3.42.14 Bit Instructions
Allow cooperative vector types for the following bit instructions:
-
OpShiftRightLogical, OpShiftRightArithmetic, OpShiftLeftLogical, OpBitwiseOr, OpBitwiseXor, OpBitwiseAnd, and OpNot.
3.42.X Cooperative Vector Instructions
Issues
-
How can a shader construct a vector with number of components defined by a specialization constant?
RESOLVED: Use the instructions in SPV_EXT_replicated_composites to construct a vector with the same value replicated for all components.
Revision History
Rev | Date | Author | Changes |
---|---|---|---|
1 |
2024-05-21 |
Jeff Bolz |
Initial revision of SPV_NV_cooperative_vector |
2 |
2024-07-25 |
Jeff Bolz |
Remove special cases for constructing composites |