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

[Misc] Add image repeat option to benchmark_serving.py (to test hit/miss of MM cache) #11177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alexm-neuralmagic
Copy link
Collaborator

benchmark_serving.py: This PR adds the option to repeat images with specific probability so we can test HIT/MISS of MM cache.

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.

🚀

Signed-off-by: Alexander Matveev <alexm@neuralmagic.com>
…ache

Signed-off-by: Alexander Matveev <alexm@neuralmagic.com>
Copy link

mergify bot commented Dec 13, 2024

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @alexm-neuralmagic.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@alexm-neuralmagic
Copy link
Collaborator Author

/ready

self.mm_cache_hits = 0
self.mm_cache_total = 0

def cache_hit_ratio(self, steps) -> float:
if self.mm_cache_total > 0 and self.mm_cache_total % steps == 0:
logger.debug("MMInputMapper: cache_hit_ratio = %.2f ",
self.mm_cache_hits / self.mm_cache_total)
print("MMInputMapper: cache_hit_ratio = %.2f ",
Copy link
Member

Choose a reason for hiding this comment

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

Is this intended?

Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK no. This should be reverted before merging the PR.

self.mm_cache_hits = 0
self.mm_cache_total = 0

def cache_hit_ratio(self, steps) -> float:
if self.mm_cache_total > 0 and self.mm_cache_total % steps == 0:
logger.debug("MMInputMapper: cache_hit_ratio = %.2f ",
self.mm_cache_hits / self.mm_cache_total)
print("MMInputMapper: cache_hit_ratio = %.2f ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK no. This should be reverted before merging the PR.

Comment on lines +261 to +262
if image_repeater is not None:
image = image_repeater.process(image)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks to me that we don't have to make it complicate. For example we're benchmarking 1k prompts. The original behavior is "taking the first 1k data from dataset" and all images in data are different. If we just want to simulate the image caching, we could simply do the following

# Get the first N unique images.
n_requests = len(sampled_requests)
n_unique_images = int(n_requests * (1 - hit_rate))
unique_images = [data["image"] for data in dataset[:n_unique_images]]

# Repeat the unique images to meet the number of requests.
all_images = images * ceil(n_requests / n_unique_images)[:n_requests]
for image in all_images:
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants