@@ -20,6 +20,7 @@ _LAUNCH_CONFIG_ATTRS = (
2020 ' shmem_size' ,
2121 ' is_cooperative' ,
2222 ' programmatic_stream_serialization' ,
23+ ' priority' ,
2324)
2425
2526__all__ = [' LaunchConfig' ]
@@ -59,6 +60,9 @@ cdef class LaunchConfig:
5960 Whether to allow programmatic stream serialization (PDL). When True,
6061 the kernel may overlap with a previous kernel in the same stream that
6162 signals completion via programmatic means.
63+ priority : int, optional
64+ Execution priority of the kernel. Lower numbers represent higher
65+ priorities. When omitted, the launch uses the stream's priority.
6266 """
6367
6468 # TODO: expand LaunchConfig to include other attributes
@@ -72,6 +76,7 @@ cdef class LaunchConfig:
7276 shmem_size: int | None = None ,
7377 is_cooperative: bool = False ,
7478 programmatic_stream_serialization: bool = False ,
79+ priority: int | None = None ,
7580 ) -> None:
7681 """Initialize LaunchConfig with validation.
7782
@@ -89,6 +94,9 @@ cdef class LaunchConfig:
8994 Whether to launch as cooperative kernel (default: False )
9095 programmatic_stream_serialization : bool , optional
9196 Whether to allow programmatic stream serialization / PDL (default: False )
97+ priority : int , optional
98+ Execution priority of the kernel. Lower numbers represent higher
99+ priorities. When omitted , the launch uses the stream's priority.
92100 """
93101 # Convert and validate grid and block dimensions
94102 self.grid = cast_to_3_tuple(" LaunchConfig.grid" , grid)
@@ -116,6 +124,7 @@ cdef class LaunchConfig:
116124
117125 self .is_cooperative = is_cooperative
118126 self .programmatic_stream_serialization = programmatic_stream_serialization
127+ self .priority = priority
119128
120129 if self .is_cooperative and not Device().properties.cooperative_launch:
121130 raise CUDAError(" cooperative kernels are not supported on this device" )
@@ -169,6 +178,11 @@ cdef class LaunchConfig:
169178 attr.value.programmaticStreamSerializationAllowed = 1
170179 self ._attrs.push_back(attr)
171180
181+ if self .priority is not None :
182+ attr.id = cydriver.CUlaunchAttributeID.CU_LAUNCH_ATTRIBUTE_PRIORITY
183+ attr.value.priority = self .priority
184+ self ._attrs.push_back(attr)
185+
172186 drv_cfg.numAttrs = self ._attrs.size()
173187 drv_cfg.attrs = self ._attrs.data()
174188
@@ -230,6 +244,12 @@ cpdef object _to_native_launch_config(LaunchConfig config):
230244 attr.value.programmaticStreamSerializationAllowed = 1
231245 attrs.append(attr)
232246
247+ if config.priority is not None :
248+ attr = driver.CUlaunchAttribute()
249+ attr.id = driver.CUlaunchAttributeID.CU_LAUNCH_ATTRIBUTE_PRIORITY
250+ attr.value.priority = config.priority
251+ attrs.append(attr)
252+
233253 drv_cfg.numAttrs = len (attrs)
234254 drv_cfg.attrs = attrs
235255
0 commit comments