-
Notifications
You must be signed in to change notification settings - Fork 14
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
Compile and Ctranslate2 support #161
Merged
Merged
Conversation
This file contains 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.
Tested with torch 2.5.1
Pytorch made a lot of progress with torch.compile especially with dynamic shapes (our case, seqlen varies accross batches)
torch.nn.RMSNorm is not fully compatible with torch.compile
Hence I kept our python code but added a torch.compile decorator
This makes RMSNorm as fast as the awq_ext (so I removed it)
Further improvement:
Training:
Added a model = torch.compile(model, dynamic=True) in train_single
Gain is more or less +10% in tok/sec
Inference:
We never use the model.forward() directly so using torch.compile(model) has no effect.
I tried to use some regional compilation for MLP, part of MHA, etc ... no improvements
The reason is that the use flash_attn_with_kvcache is the best optimization we can get at inference.
EDIT:
flash-attn is supposed to support torch.compile starting versions >=2.6.X
Issue flash_attn_with_kvcache (only function we use) does not support torch.compile as of 2.7.2.post1
Dao-AILab/flash-attention#1386
Also due to some changes between 2.5.9.post1 and 2.6.x (probably because of torch.compile support) 2.6 is slower
We recommend flash-attn 2.5.9.post1 for now.
CT2 Support within Eole:
I opened a PR to convert Eole models to CT2 here: OpenNMT/CTranslate2#1832
For NMT (Encoder/Decoder models) there seems to be nice speeds up but it may vary a lot depending on the inference config file (flash, batch_size, beam_size, ...)
For LLM (Decoder only models) CT2 remains slower because it does not support left padding yet.
Even with batch size = 1, my tests show that Eole is faster at the moment (with EuroLLM-9B-Instruc)