Optimize DSpark hot paths for T4#8
Merged
Merged
Conversation
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.
Measured problem
Tesla T4 benchmark from the merged DSpark implementation:
The scheduler was already 4.7x faster, but the scalar Markov kernel was 36.8x slower.
Root cause
The raw Markov kernel decomposed a dense
[128,256] @ [256,32000]operation into independent GEMVs. That reread the 16 MiB projection for each request and accumulated through scalar FP32 CUDA-core FMAs. PyTorch used one tiled GEMM with projection reuse and T4 Tensor Cores.Changes
addmm/cuBLAS GEMM the production Markov path:markov_logits_raw_cudaresearch baseline.requests * proposal_length <= 1024:*.egg-info/;install.sh;Validation performed
python -m pytest DSpark/tests -q: 6 passed, 2 CUDA-only tests skipped locallygit diff --check: passed62fe74a6cc85d3badbc5e13a4d849c4ea25407b3The CUDA-specific tests and benchmark must be rerun on the Tesla T4 before this draft is marked ready.