Skip to content
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

[torch.compile] add logging for compilation time #10941

Merged
merged 16 commits into from
Dec 6, 2024

Conversation

youkaichao
Copy link
Member

No description provided.

Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Copy link

github-actions bot commented Dec 6, 2024

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

Signed-off-by: youkaichao <[email protected]>
@youkaichao
Copy link
Member Author

example output (for the toy tests):

Compiling a graph for general shape takes 1.55 s

see https://buildkite.com/vllm/fastcheck/builds/9379#01939a08-6359-4659-9b3c-c07576a7efee/6465-8353

@youkaichao youkaichao requested a review from WoosukKwon December 6, 2024 04:33
@youkaichao youkaichao marked this pull request as draft December 6, 2024 05:08
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
Signed-off-by: youkaichao <[email protected]>
@youkaichao
Copy link
Member Author

youkaichao commented Dec 6, 2024

this pr aims to add three logging information:

  1. engine-level initialization, e.g.

INFO 12-05 22:37:22 llm_engine.py:493] init engine (profile, create kv cache, warmup model) took 15.08 seconds
INFO 12-05 22:39:24 llm_engine.py:493] init engine (profile, create kv cache, warmup model) took 40.77 seconds
INFO 12-05 22:41:51 llm_engine.py:493] init engine (profile, create kv cache, warmup model) took 50.18 seconds

  1. graph compilation for every shape (including the symbolic shape compilation), e.g.

INFO 12-05 22:39:02 backends.py:55] Compiling a graph for general shape takes 14.73 s
INFO 12-05 22:41:51 backends.py:58] Compiling a graph for shape 1 takes 9.99 s

  1. aggregation of the numbers in 2, e.g.

INFO 12-05 22:39:04 monitor.py:13] graph compilation takes 14.73 s in total
INFO 12-05 22:41:51 monitor.py:13] graph compilation takes 24.758146286010742 s in total

how to read it:

the increase in 1, when using or not using torch.compile , is the total cost of torch.compile .

2 shows the cost of every shape compilation, so that users can select it according to their budget. Note that some compilation like Dynamo bytecode compilation and triton compilation are not considered here.

3 just aggregates 2.

Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

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

Honestly, I don't have enough familiarity to the code for proper review. However, the code apparently looks OK to me. Please feel free to merge.

vllm/compilation/backends.py Outdated Show resolved Hide resolved
Comment on lines +12 to +14
if compilation_config.level == CompilationLevel.PIECEWISE:
logger.info("graph compilation takes %.2f s in total",
compilation_config.compilation_time)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dumb question: Why does it print only for pw CUDA graphs?

Copy link
Member Author

Choose a reason for hiding this comment

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

CompilationLevel.PIECEWISE is piecewise compile, not piecewise cudagraph. this is orthogonal to cudagraph.

@@ -108,6 +120,8 @@ def split_graph(graph: fx.GraphModule,
# we share the global graph pool among all the backends
global_graph_pool = None

compilation_start_time = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe None instead of 0.0?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wondering: can we somehow make this more robust? Since the code touching this var is scattered into different places, I feel it's error prone...

Copy link
Member Author

Choose a reason for hiding this comment

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

that's why I want to merge some functions in the worker/executor. however, given the current code status, i don't have bandwidth to refactor those files.

@WoosukKwon
Copy link
Collaborator

INFO 12-05 22:41:51 monitor.py:13] graph compilation takes 24.758146286010742 s in total

Please make sure to use %2f for this log (if it hasn't been fixed yet).

youkaichao and others added 2 commits December 5, 2024 23:39
Signed-off-by: youkaichao <[email protected]>
@youkaichao
Copy link
Member Author

@WoosukKwon thanks for the review!

@youkaichao youkaichao enabled auto-merge (squash) December 6, 2024 08:08
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 6, 2024
@youkaichao youkaichao merged commit b031a45 into vllm-project:main Dec 6, 2024
65 checks passed
@youkaichao youkaichao deleted the compilation_time branch December 6, 2024 16:18
sleepwalker2017 pushed a commit to sleepwalker2017/vllm that referenced this pull request Dec 13, 2024
BKitor pushed a commit to BKitor/vllm that referenced this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants