-
Notifications
You must be signed in to change notification settings - Fork 515
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
Optimize internvit #3316
base: dev
Are you sure you want to change the base?
Optimize internvit #3316
Conversation
if tensor is None: | ||
continue | ||
torch._dynamo.mark_dynamic(tensor, dynamic_dims) | ||
self.compiled = True |
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.
The code is a little bit confusing(TorchCompile mode == not enable_graph
and enter the not enable_graph
branch)
I think the following code is more readable:
if self.compiled:
self.model(**kwargs) # or something like self.compiled_model(**kwargs)
lmdeploy/pytorch/models/internvl.py
Outdated
): | ||
"""forward.""" | ||
hidden_states = hidden_states + self.attn(self.norm1(hidden_states).to(hidden_states.dtype)) * self.ls1 | ||
def enable_micro_batch(func): |
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.
move this function to a common file? like until.py
873c99a
to
832c2d8
Compare
Introduction
Optimize internvit.
Benchmark serving result on A100 using 4 gpus with
python benchmark/profile_restful_api.py --backend lmdeploy --base-url http://0.0.0.0:23333 --dataset-name sharegpt --dataset-path /workspace/caikun/benchmark/ShareGPT_V3_unfiltered_cleaned_split.json --sharegpt-output-len 4 --num-prompts 500 --model OpenGVLab/InternVL2_5-78B
Benchmark input image use https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg.
About 13%+ improvement of the prefill phase.
Optimization methods
performance before optimization
performance after optimization