nemo_automodel.components.models.minimax_m3_vl.kernels.msa_task_build_sm100
nemo_automodel.components.models.minimax_m3_vl.kernels.msa_task_build_sm100
Build locality-ordered backward task tables and their CTA walk on the device.
One JIT issues four launches: work scan, segment keys, bin scan, table scatter. Forward buckets have
ascending queries and contiguous (head, query window, key block) segments, so
offsets[segment] + task - first_tasks[segment] reproduces the Torch reference order kept in
tests/functional_tests/models/minimax_m3_vl/test_msa_task_build_sm100.py. Noncontiguous segments
keep source order (descriptor flag 2). Capacity overflow disables the CTA walk (flag 1). Exact task
counts and the walk stay on the device; the host launches a grid bound and surplus CTAs take empty
intervals.
Module Contents
Classes
Functions
Data
API
Task tables in the locality order plus the CTA-walk descriptor the main kernel reads.
The tables hold capacity rows; rows past the task count are never written nor read (the
descriptor’s exact count bounds every CTA interval). grid_launch >= desc[DESC_GRID_CTAS].
One JIT owns the four build stages and the interpretation of segment scratch.
Exclusive bin offsets; flag segments that are not contiguous source runs.
Inclusive task offsets, exact counts and cleared segment bins.
Compile the four-launch build once per process with dynamic work, row, edge, document and bin counts.
Exclusive prefix across SCAN_THREADS; all threads must participate.
Forward-order task task -> (index_head, document, local kblock, valid, first edge).
(capacity, bins, scratch_words, table_words) of the build for this schedule (host shape math only).
Upper bound of the task count from the schedule shapes (disjoint work items).
Inclusive prefix sum across the 32 lanes of a warp (shfl.up; clamp 0 = plain up-shuffle).
Enqueue the four build launches without a host sync; return the tables and the CTA walk.
Parameters:
Forward-derived int32 schedule (see MSABackwardSchedule), all on one CUDA device.
Compact token count T of the backward call.
Aligned K/V workspace length W, a multiple of 128.
Streaming multiprocessors of the device; sizes the CTA walk.
Int32 buffer of task_build_storage(...)[0] words on the schedule device, carved as
descriptor | task ends | task segments | bins. The descriptor stays at offset zero to keep
its 16-byte alignment.
Int32 buffer of task_build_storage(...)[1] words on the schedule device, carved as
task_meta [capacity, 4] | task_qrows [capacity, 8] | task_qpos [capacity, 8].
Returns: _MSABackwardTaskTables
The three task tables (views into tables), the device descriptor (a view into
Raises:
ValueError: If the locality bins exceedMAX_BINS, which happens past roughly 250k tokens.
Required scratch/table int32 words; the caller owns and may reuse both buffers.