-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Hardware][TPU][V1] Multi-LoRA Optimisations for the V1 TPU backend #15655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
268 commits
Select commit
Hold shift + click to select a range
1dbfcd9
Fixed lora_input preparation for actual execution
Akshat-Tripathi 1bb2578
Fixed wrong model bug
Akshat-Tripathi ddc4cbc
Moved if statements outside of for loops in PunicaWrapperTPU
Akshat-Tripathi 48a6944
Added early exits to PunicaWrapperTPU lora functions
Akshat-Tripathi 7802e84
Added torch ops for tpu (Static prefill sizes)
Akshat-Tripathi ab5396b
XLA bgmv operations are now imported from the default torch_ops
Akshat-Tripathi fdf29d3
Removed TODOs
Akshat-Tripathi c2b4139
Removed old code
Akshat-Tripathi f31b7d1
Linting
Akshat-Tripathi 87ff73e
Fixed import error
Akshat-Tripathi 96c3dde
lint
Akshat-Tripathi 4e72ede
Abstracted out infinity values
Akshat-Tripathi e4d35ce
Moved and modified bgmv ops from the cpu backend to the tpu backend, …
Akshat-Tripathi 3cf0680
Removed total_size for linting
Akshat-Tripathi a8ab0c9
Reverted changes to torch_ops
Akshat-Tripathi d73f1ce
Lint
Akshat-Tripathi e01d9a4
Replaced in-place buffer updates with direct returning
Akshat-Tripathi 0c1bfb9
PunicaWrapperTPU now returns unchanged buffer if no loras are needed
Akshat-Tripathi 46ce7fa
Simplified TPU prefill
Akshat-Tripathi 5d0cc37
Removed sgmv kernels from TPU implementation
Akshat-Tripathi 7590b0e
Fix bug
Akshat-Tripathi e7f75b5
Added torch.compiles to PunicaWrapperTPU functions
Akshat-Tripathi fe193f7
Replaced "x[x==-1] = y" with "x = torch.where(x == - 1, y)"
Akshat-Tripathi 52e3911
Revert "Added torch.compiles to PunicaWrapperTPU functions"
Akshat-Tripathi 33a70b0
Fix linting
Akshat-Tripathi 67446b2
Added lora hotswapping test
Akshat-Tripathi 0db19b1
Fixed hotswapping test prompt
Akshat-Tripathi a4c3b0a
Fixed bug in tpu lora test
Akshat-Tripathi 9d6c388
Merged set_no_lora() functionality with _udpate_prefill_metada
Akshat-Tripathi 2a9978e
Added Multi-LoRA functionality to TPU V1
Akshat-Tripathi b8c65bc
Added test that verifies switching
Akshat-Tripathi 942ef07
Added bgmv kernel test code
Akshat-Tripathi 56529b9
Added some dynamic lora selection
Akshat-Tripathi 735073f
Moved and modified bgmv ops from the cpu backend to the tpu backend, …
Akshat-Tripathi 1067b50
Added bgmv kernel test
Akshat-Tripathi d897f87
Made bgmv kernel fully functional (WIP on supporting smaller ranks) (…
Akshat-Tripathi d6eca29
Updated bgmv_kernel to work with ranks that aren't exact multiples of…
Akshat-Tripathi d97aae5
Removed interpreted mode on kernel
Akshat-Tripathi 3ac0f63
Added pallas kernel benchmarking script
Akshat-Tripathi a620e58
Fixed mosaic kernel compilation issue
Akshat-Tripathi 00d6dfd
Added reference kernel benchmarking
Akshat-Tripathi fb0601d
Registered the custom op
Akshat-Tripathi 89b062e
Integrated bgmv kernel
Akshat-Tripathi ef2ef8c
Fixed model compilation bugs
Akshat-Tripathi a79e19d
Minor changes
Akshat-Tripathi cc8cdf6
Removed scratch files
Akshat-Tripathi ad8c565
Minor pallas kernel fixes
Akshat-Tripathi 8d83065
integrate ragged paged attn v2
yaochengji dea7d02
fix precompile
yaochengji 0cf0eaa
Merge branch 'chengji/ragged_attn_v2_new' into multi_lora_tpu_v1
Akshat-Tripathi 6249307
Fixed padding issue with v1
Akshat-Tripathi af0a6a9
Added temporary patch over pallas kernel routing bug
Akshat-Tripathi 264d36a
Updated kernel test
Akshat-Tripathi b725c6a
Lint
Akshat-Tripathi 038465c
Removed duplicate method
Akshat-Tripathi 2004369
Lint
Akshat-Tripathi 71a1cdd
More linting
Akshat-Tripathi 3dba9e0
Linting
Akshat-Tripathi f7f95e4
Lint
Akshat-Tripathi adfdcdb
Fixed bug related to consecutive pallas kernels
Akshat-Tripathi a6d5c01
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 5a27785
Removed v0 TPU LoRA implementation
Akshat-Tripathi 5d15fbc
Fixed VocabParallelEmbeddingWithLoRA compilation error
Akshat-Tripathi ca3d810
Fixed LogitsProcessorWithLoRA layer compilation issue
Akshat-Tripathi 12f71ce
Slightly sped up the kernel
Akshat-Tripathi d040ee8
Lint
Akshat-Tripathi e696144
Fixed bug with higher batch sizes
Akshat-Tripathi d110613
Lint
Akshat-Tripathi f8d5da2
Removed TODO in bgmv pallas test
Akshat-Tripathi d114377
Fixed PunicaWrapperBase typing
Akshat-Tripathi 430bae9
Fixed bug where vLLM crashes on decode
Akshat-Tripathi fb36fd6
Fixed NaN bug with LogitsProcessor
Akshat-Tripathi c454062
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 23b14d1
Updated LoRALogitsProcessor to work with the TPU
Akshat-Tripathi 27d6f70
Lint
Akshat-Tripathi b547271
Fixed batched logits processing
Akshat-Tripathi f5138b8
Updated kernel test
Akshat-Tripathi ad14872
Added kernel benchmark (dev only, remove later)
Akshat-Tripathi 7418b5a
Tuned bgmv kernel block sizes
Akshat-Tripathi 2aacb34
Improved lora output masking
Akshat-Tripathi 6ee0b57
Skipped matmuls where no loras are needed
Akshat-Tripathi d9e415f
Renamed variables for better readabiity
Akshat-Tripathi 460e808
Moved inner loop into grid spec
Akshat-Tripathi 12ac3b8
Revert "Moved inner loop into grid spec"
Akshat-Tripathi 1bb152f
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi af15bd1
Added comment
Akshat-Tripathi 41555d1
Lint
Akshat-Tripathi 4ac7aa9
Added a fused shrink/expand kernel
Akshat-Tripathi 9f5a497
Revert "Added a fused shrink/expand kernel"
Akshat-Tripathi 54344b7
Added some autotuning for kernels
Akshat-Tripathi c5a42e2
Renamed padding variables
Akshat-Tripathi e66067c
Used a static ones vector, gives a 5%ish perf boost
Akshat-Tripathi 7c79683
Restricted block sizes to prevent memory from blowing up
Akshat-Tripathi d7338f8
Removed larger lora/dim block sizes since they reduce perf outside of…
Akshat-Tripathi 2bb8868
Allowed smaller LoRA blocks if necessary
Akshat-Tripathi 27ad793
Replaced torch.cat operations with F.pad
Akshat-Tripathi a82f3fe
Added fused lora transpose [experimental]
Akshat-Tripathi 640420b
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi de6746a
Separated bgmv_shrink and bgmv_expand kernels to avoid unneccessary d…
Akshat-Tripathi 19b9089
Removed redundant branch
Akshat-Tripathi a02d0e9
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi e07d6fb
Moved punica related `mark_dynamic` to the TPUModelRunner to allow th…
Akshat-Tripathi 5b4ba1b
Moved `maybe_dummy_run_with_lora` to the `_dummy_run` method
Akshat-Tripathi efbdc62
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi b64dc31
Lint
Akshat-Tripathi 49a8102
Minor fixes + lint
Akshat-Tripathi c1be5f9
Lint
Akshat-Tripathi bf44d65
Fixed mark_dynamic placement for eager/compiled modes
Akshat-Tripathi 15ff074
Fixed mark_dynamic placement for eager/compiled modes
Akshat-Tripathi d9f89b6
Temporary fix to LogitsProcessorWithLoRA pipeline bubble issue
Akshat-Tripathi 81775d3
Sampler is now compiled with LoRA
Akshat-Tripathi ab036e0
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 2bc00b8
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 829028d
Removed early exits since they cause eager execution
Akshat-Tripathi b6af323
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi df69c52
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 5638e7d
Removed some recompilations when updating LoRA metadata
Akshat-Tripathi bae61a2
Aligned lora codepath with recompilation fixes
Akshat-Tripathi dc8b940
Disabled add_lora_logits temporarily
Akshat-Tripathi eb804a0
Added the LoRA Laning optimisation + tests + explanation
Akshat-Tripathi fbb902a
Updated kernel benchmarking script with lora laning
Akshat-Tripathi 8ba2749
Added error for when someone tries to use LoRA adapters on the V0 TPU…
Akshat-Tripathi 51d87a5
Added test to buildkite
Akshat-Tripathi bf52dbd
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi fce044a
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 8b1dae8
Lint
Akshat-Tripathi aad109b
Optimised single lora kernels
Akshat-Tripathi b09d595
Fixed compilation bug
Akshat-Tripathi 151fde4
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi a1df8c8
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 72d95c6
Fixed LoRA Laning bug
Akshat-Tripathi be0915c
Fixed extra recompilations
Akshat-Tripathi 478a8bb
Lint
Akshat-Tripathi 4178e58
Lint
Akshat-Tripathi 8a3009d
Added type annotation to lora_output
Akshat-Tripathi 493e73f
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 1d6085a
Removed unused function/parameter
Akshat-Tripathi f208234
Removed redundant padding in kernel for larger lora/dim sizes
Akshat-Tripathi ec0e181
Moved xm.mark_step() calls to move appropriate places
Akshat-Tripathi 38de473
Reduced number of graphs compiled
Akshat-Tripathi 8dabfab
Fixed memory usage problem
Akshat-Tripathi f5949a7
Lint
Akshat-Tripathi a7ae288
Lint
Akshat-Tripathi 2e67aa8
Removed first inference recompilation
Akshat-Tripathi 27b3c52
Fixed more recompilations
Akshat-Tripathi d1452af
Added flag to disabled add_lora_logits()
Akshat-Tripathi 1cc89a5
Lint
Akshat-Tripathi 93d3e8f
Fixed performance issue where the sampler would face long stalls
Akshat-Tripathi 9fb50b9
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 592c62f
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi e1aaed6
Fixed laning integration bug
Akshat-Tripathi 62500e1
Lint
Akshat-Tripathi eb72ab6
Removed LoRA vocab padding for TPU
Akshat-Tripathi 49157b1
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 54db22d
Fixed 0 padding issue with LoRA
Akshat-Tripathi 5232785
Changed TPU lora_vocab_padding_size to 1
Akshat-Tripathi 1b4c2f2
Fixed bug in bgmv_expand kernel - outputs weren't being written with …
Akshat-Tripathi c8f68d7
Changed TPU lora_vocab_padding_size to 1
Akshat-Tripathi ed3b245
Enabled lora bias
Akshat-Tripathi 4855791
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 9d35414
Replaced `enable_laning` flag with dim comparison
Akshat-Tripathi 54c00c3
Enabled fully sharded loras
Akshat-Tripathi f3e48a6
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi a4b2e27
Removed test benchmarking file
Akshat-Tripathi 9f0fdbe
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi fbddd3c
Refactored add_shrink to return a tensor not a tuple
Akshat-Tripathi 2012bbd
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi d1c11c8
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 1803135
Removed tuple return in add_shrink()
Akshat-Tripathi 0eeb72c
Removed extra compilation
Akshat-Tripathi c1be9fe
Replaced copies with buffer donation to reduce memory usage
Akshat-Tripathi de5da33
Added explicit compilation in add_lora
Akshat-Tripathi 5adc67f
Removed LoRA ID collision
Akshat-Tripathi 342ff8b
Fix pre-commit
Akshat-Tripathi fc65edb
Reduced number of iterations in test_lora
Akshat-Tripathi 2f1da29
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 7daaafa
Lint
Akshat-Tripathi 893ac04
Reduced pallas kernel test size
Akshat-Tripathi 2a0fce7
Added/removed comments
Akshat-Tripathi 4d42844
Fixed pallas kernel test
Akshat-Tripathi 50a06fc
Made LoRA e2e test more robust
Akshat-Tripathi 9b78b74
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 177fced
Added mark_steps to set_lora to break up large graphs
Akshat-Tripathi 12ff364
Stopped index based recompilation for multi-lora
Akshat-Tripathi 491578d
Restored original maybe_dummy_run_with_lora
Akshat-Tripathi 5cb4724
Split up into lora setup and lora selection functions
Akshat-Tripathi ca68ce6
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi e91774a
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi f4be6cc
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 155c2ad
Merge branch 'multi_lora_tpu_v0' of https://github.com/krai/vllm into…
Akshat-Tripathi 317a131
Removed mark_compiled from punica_tpu
Akshat-Tripathi cba8267
refactor mark step from layers into tpu model runner
xihajun b482ec8
Split TPU LoRA test into several smaller ones
Akshat-Tripathi 2f26dd9
Fix lora spelling
Akshat-Tripathi d4b3707
refactor mark step from layers into tpu model runner
jdefreitas02 afd7690
Merge branch 'better_tpu_multilora_compilation' of https://github.com…
xihajun 8ccbaa8
Added comment explaining how multi-lora test adapters were trained
Akshat-Tripathi d227381
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi b65f60e
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 8a45758
Moved TPU lora tests into tests/tpu/lora
Akshat-Tripathi 987589a
Updated TPU tests
Akshat-Tripathi bc49d0f
Fixed tpu-test script
Akshat-Tripathi 50e9738
Fixed pallas kernel dtype in test
Akshat-Tripathi ed1738a
mask creation moved outside of matmul loop
f81111e
Moved mask setup outside of lora running loop
Akshat-Tripathi 4a07cf6
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 8cd5cb7
Disabled LoRA serving for now
Akshat-Tripathi 94bc0e2
compile reset_lora function as separate graph
b0bfc7a
update base metadata padding moved to cpu
6282cd5
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 975935e
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 1846ef3
Temporarily disabled the TPU lora tests
Akshat-Tripathi a6791a2
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi a006f6b
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 539366c
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 966e800
fix size of sampler indices
d72a86b
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi 139e9b1
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 22bafee
remove add lora
aff7414
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi dae6c40
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi e487ecb
Fixed incorrect torch.wheres
Akshat-Tripathi 20c5981
Merge branch 'main' into multi_lora_tpu_v1
Akshat-Tripathi df67053
Lint
Akshat-Tripathi f9f9011
Merge branch 'multi_lora_tpu_v1' into tpu_bgmv_optimisation
Akshat-Tripathi 8f5c64d
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 9f249bf
Updated comment + variable name fixes
Akshat-Tripathi 0fe1866
Removed unused function
Akshat-Tripathi 1e25225
Fixed spelling inconsistency
Akshat-Tripathi a5aba61
Removed redundant `mark_step`
Akshat-Tripathi bae5615
Merge branch 'better_tpu_multilora_compilation' into tpu_bgmv_optimis…
Akshat-Tripathi 19dc26f
Removed unlowered ops when resettiing loras
Akshat-Tripathi fff8b03
Fixed extra recompilation due to incorrect vocab size
Akshat-Tripathi d9aa141
Removed recompilations in logprobs gathering
Akshat-Tripathi f5b72ce
Replaced the pallas kernle with einsums
Akshat-Tripathi 17fcaef
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi cb18346
Reenabled TPU LoRA test
Akshat-Tripathi dd448d4
Fixed precommit
Akshat-Tripathi 69b5a33
Switched jax implementation to use a custom op
Akshat-Tripathi 71624c6
Fixed bug when setting LoRAs. This introduces recompilations
Akshat-Tripathi e6dfd00
Removed extra `add_lora` function
Akshat-Tripathi a242f31
Lint
Akshat-Tripathi 6770adf
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 820d9f6
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi 376b1a1
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi c575c0e
Addressed PR comments
Akshat-Tripathi 53ab8c4
Moved LoRA recompilation check to the test script
Akshat-Tripathi 6edf6fb
Lint
Akshat-Tripathi 8a87529
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi a3dcb2c
Merge branch 'main' into tpu_bgmv_optimisation
Akshat-Tripathi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this traced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be traced, I'm not sure if we actually hit this case though, it's based off the CPU implementation