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

[V1] [2/n] Logging and Metrics - OutputProcessor Abstraction #11973

Merged

Conversation

robertgshaw2-neuralmagic
Copy link
Collaborator

@robertgshaw2-neuralmagic robertgshaw2-neuralmagic commented Jan 12, 2025

SUMMARY:

  • VLLM V1 design minimizes number of python loops over all items in the batch for performance. As we add metrics and logging, we need to loop over all items in the batch another time
  • This PR renames Detokenizer >> OutputProcessor.
    • All functionality that need to touch each item should implement XXXClass.update_from_output + be called in OutputProcessor.process_outputs loop.
    • Moves self._process_request_outputs into this loop (previously this was a separate loop in output_handler)
    • AddIterationStats.update_from_output() to this loop
  • Add more testing to abort

NOTES:

Copy link

👋 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.

🚀

@robertgshaw2-neuralmagic robertgshaw2-neuralmagic changed the title [V1] [2/n] Logging and Metrics - Output Processor Abstraction [V1] [2/n] Logging and Metrics - OutputProcessor Abstraction Jan 12, 2025
queue=queue,
)


Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this was previously called Detokenizer

@@ -59,9 +59,6 @@ def __init__(
lora_config=vllm_config.lora_config)
self.tokenizer.ping()

# Request streams (map of request_id -> queue).
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: these queues are held in OutputProcessor

Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

Nice structure and comments, this LGTM. It would be nice to have a test that IterationStats gets updated within the OutputProcessor

If you need to touch every element of the batch, implement a
method called XXXClass.update_from_output() to be called
within the loop below. For examples, see:
* IterationStats.update_from_output()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great abstraction IMO.

nit: I wonder if we also want to make it more explicit by having something like a OutputHandler protocol that takes in the engine core output + maybe a current request state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add a comment suggesting that we do this once we add RequestStats. I want to keep flexibility while we are in the development stage

return

self.num_generation_tokens += len(output.new_token_ids)
if is_prefilling:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think one scenario that might potentially complicate things is when a request has a pretty long prompt, and its prefill actually will span multiple "iteration". With current architecture, the prompt throughput stats is actually not accurate.

I wonder if we should have a path where we propogate each scheduler iteration rather than engine core iteration to the front end process for more accurate stats.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't send outputs from EngineCore until it generates a token.

So from the POV of the Engine len(new_token_ids) > 0. We should add an assert for this invariant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added comment and assert.

@robertgshaw2-neuralmagic
Copy link
Collaborator Author

robertgshaw2-neuralmagic commented Jan 13, 2025

@mgoin. Tests are added. Could I get an approval?

tests/v1/engine/test_async_llm.py Show resolved Hide resolved
tests/v1/engine/test_output_processor.py Outdated Show resolved Hide resolved
@robertgshaw2-neuralmagic robertgshaw2-neuralmagic enabled auto-merge (squash) January 13, 2025 03:00
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Jan 13, 2025
@robertgshaw2-neuralmagic robertgshaw2-neuralmagic merged commit 619ae26 into vllm-project:main Jan 13, 2025
61 of 64 checks passed
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.

3 participants