Introduction#
Overview#
Modern NVIDIA GPUs expose asynchronous operations such as TMA, tcgen05 MMA, CLC fetch, and copy to Tensor Memory. Programming them efficiently requires asynchronous warp-specialized programs where each warp or group of warps is responsible for a task, such as data loading or math computation. These tasks communicate through memory, such as shared memory or tensor memory.
Synchronization with mbarriers and named barriers is needed to prevent concurrent data accesses. Barrier behavior depends on the kernel configuration (1-CTA or Cluster-wide kernel), the producer/consumer pattern (how many warps are writing and reading data) between specialized warps, the operation type (TMA, MMA, etc), which threads signal each barrier, and which memory regions overlap in time. A wrong arrival count, a missed barrier advance, or a release before the producer has finished writing can cause a wrong result or a runtime hang.
In bare-metal code, the schedule is implicit. Warp specialization, barrier arrivals, and phase advancement are scattered across warp branches and mixed into the kernel body. There is no separate schedule object to inspect, so there is no deadlock or race checker either.
Task Scheduling makes the schedule explicit. The developer still writes the low-level work methods for TMA, MMA, and memory operations. TS adds a checked structure around that code:
resources describe the communication objects used by the kernel;
a dependency graph states which resources must be produced before other resources can be produced or consumed;
schedules record the order of acquire/work/commit and wait/work/release calls;
tasks bind schedules and resources to a concrete warp range.
Task Scheduling statically checks the schedule for deadlocks, race conditions, and barrier initialization before lowering the kernel to GPU code. Many synchronization ordering mistakes fail early instead of becoming runtime hangs or race conditions. The warp-role structure is written in one concise place, making the kernel easier to inspect and review. Schedule edits and optimizations are easier to audit because Task Scheduling re-checks the schedule ordering before lowering to GPU code.
Core Terms#
- Resource
A
MemoryResourceor subclass wrapping a physical resource such as global memory, shared memory, tensor memory, a persistent tile queue, or a PDL barrier. A resource may carry a pipeline withPipelineConfigguarding storage withacquire/commitfunctions on the producer side andwait/releasefunctions on the consumer side.- Task
A contiguous warp range, described by
warp_idxandnum_warps, bound to one explicit execution schedule. A task lists the resources it reads from insrc_resourcesand the resources it writes to indst_resources. It may also declare anum_registersbudget for warp-group register validation.- Schedule
A function decorated with
@schedule. The schedule function explicitly specifies the order of operations on resources plus the synchronization primitives used to synchronize concurrent access to those resources. Calling the decorated function records resource method calls, but it does not execute the work. The call returns aScheduleResultpassed toTask(schedule=...).- TaskManager
The object that ties tasks, the dependency graph, and optional SMEM/TMEM allocators together. It validates the schedule and then runs each task on its assigned warps.
- Dependency graph
A
dictmapping each resource to the list of resources it depends on. TS uses it to verify the order of pipeline operations in the schedule.
Producer and Consumer#
The kernel developer is still responsible for providing the logic
that writes data to a resource (producer work) and reads data from the resource
(consumer work).
The work each resource does is declared as methods decorated with
@producer_work or @consumer_work.
@consumer_work reads a value out of the resource.
@producer_work writes a value into the resource.
For example, a load task reads coordinates from a GMEM resource and produces a tile into SMEM:
Load task
1 warp
src_resource dst_resource
+--------------+ +--------------+
| InputGmem | -----------------------> | Smem |
+-------------o+ +o------------o+
| | |
| | |
consumer_work() producer_work() consumer_work()
get tile coords TMA load load from shared
A task that calls consumer_work on InputGmem lists that resource in
src_resources. A task that calls producer_work on Smem lists that
resource in dst_resources.