[CuTe,Sm100] Varlen Dynamic Persistent scheduler and metadata#2559
Open
reubenconducts wants to merge 9 commits into
Open
[CuTe,Sm100] Varlen Dynamic Persistent scheduler and metadata#2559reubenconducts wants to merge 9 commits into
reubenconducts wants to merge 9 commits into
Conversation
…sm100, update tests to use scheduler metadata
…for non-varlen blocksparse batch sorting
…namicPersistent schedulers
…nto dynamic_metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft for now until I get comprehensive benchmark numbers.
This PR adds the
VarlenDynamicPersistentScheduler, seen in FA3, to FA4.prepare_scheduler_metadata.pyFlashPrepareSchedulerkernel:num_m_blocks_ptrto precompute number of m blocks for the lpt sort (unused on SM100)num_splits_dynamic_ptr: holdsnum_splitsfor each sequence in a batch, which can vary in mixed workloadsvirtual_batch_idx_ptr: unused currently; used to permute sequences according to "virtual" batch indices, e.g. when sorting a batch for load balancing (to be utilized in a subsequent PR)num_nheads_in_l2_ptr: used for head swizzle computation in the tile schedulertile_count_semaphore: zeroed out here, used in main kernel for dynamic persistenceFlashPrepareKernel, or pass in pre-computed cached metadata to amortize cost across layers.tile_scheduler.pyso that dynamic persistent schedulers (CLC and "traditional", like that in this PR) share methods and so that varlen schedulers (SingleTileandDynamicPersistent) reuse common methods.Comprehensive performance numbers are attached. The regressions seen (e.g. with large batch, small seqlen) are attributable mainly to the fact that the combine kernel does not early-exit for 1-split sequences. We see that "traditional" dynamic persistent outperforms CLC (to which I've also wired up the appropriate metadata tensors) almost always. It's worth noting that in the few tests where prepare kernel latency appears extreme, a large proportion of that latency comes from torch.empty (known issue on Grace CPUs; ostensibly fixed with cuda 13.x, but I ran on 12.x).
varlen_dynamic_scheduler_perf.txt
To-do in follow-up PRs:
FlashPrepareKernel. This is proven to have an enormous impact on mixed prefill/decode workloads (including with CLC, from my preliminary testing). (In addition to this varlen case, batch sort will be helpful for load balancing with blocksparsity.)