Skip to content

Sarkar/mistral optimizations#804

Merged
regisss merged 18 commits into
mainfrom
sarkar/mistral_opt
Mar 21, 2024
Merged

Sarkar/mistral optimizations#804
regisss merged 18 commits into
mainfrom
sarkar/mistral_opt

Conversation

@ssarkar2
Copy link
Copy Markdown
Contributor

What does this PR do?

Pull in optimizations from llama for mistral

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@libinta libinta added run-test Run CI for PRs from external contributors synapse 1.15 labels Mar 15, 2024
Comment thread optimum/habana/transformers/generation/utils.py Outdated
Copy link
Copy Markdown
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left several comments. Can you also provide a command that I can use for testing please?

Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py
Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated
@ssarkar2
Copy link
Copy Markdown
Contributor Author

ssarkar2 commented Mar 19, 2024

I left several comments. Can you also provide a command that I can use for testing please?

command line to test (as tested on gaudi 2):
For gaudi1 the batch sizes will be smaller
#cfg 1
python run_generation.py --model_name_or_path mistralai/Mistral-7B-v0.1 --use_hpu_graphs --use_kv_cache --bf16 --batch_size 500 --max_input_tokens 128 --max_new_tokens 128 --reuse_cache --trim_logits --attn_softmax_bf16

#cfg 2:
python run_generation.py --model_name_or_path mistralai/Mistral-7B-v0.1 --use_hpu_graphs --use_kv_cache --bf16 --batch_size 116 --max_input_tokens 128 --max_new_tokens 2048 --reuse_cache --trim_logits --bucket_internal --bucket_size 256 --attn_softmax_bf16

#cfg 3:
python run_generation.py --model_name_or_path mistralai/Mistral-7B-v0.1 --use_hpu_graphs --use_kv_cache --bf16 --batch_size 116 --max_input_tokens 2048 --max_new_tokens 128 --reuse_cache --trim_logits --attn_softmax_bf16 --limit_hpu_graphs

#cfg 4
python run_generation.py --model_name_or_path mistralai/Mistral-7B-v0.1 --use_hpu_graphs --use_kv_cache --bf16 --batch_size 46 --max_input_tokens 2048 --max_new_tokens 2048 --reuse_cache --trim_logits --attn_softmax_bf16 --limit_hpu_graphs --bucket_internal --bucket_size 256

Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py Outdated

def reorder_kv_cache(self, beam_idx: torch.LongTensor):
if self.past_key is None:
# if not hasattr(self, 'past_key'):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented line is still there

Comment thread optimum/habana/transformers/models/mistral/modeling_mistral.py
@regisss regisss merged commit 44388aa into main Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-test Run CI for PRs from external contributors synapse 1.15

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants