Skip to content

Add Containerized Benchmarking Support for GuideLLM #123

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

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

Conversation

wangchen615
Copy link

@wangchen615 wangchen615 commented Apr 17, 2025

Add Containerized Benchmarking Support for GuideLLM

Description

This PR adds containerization support for GuideLLM benchmarking, making it easier to run benchmarks in containerized environments. The changes include:

  1. A new Dockerfile that:

    • Uses Python 3.11 slim as the base image
    • Installs necessary dependencies, including git and curl
    • Sets up a non-root user for security
    • Includes healthcheck functionality
    • Properly configures the benchmark script
  2. A new run_benchmark.sh script that:

    • Provides a flexible way to run benchmarks with configurable parameters
    • Supports environment variable overrides for customization
    • Handles different output formats (json, yaml)
    • Includes proper error handling and logging

Testing

The container can be built and tested using:

docker build -t <container-image-repo>/guidellm-benchmark:latest .
docker run -e TARGET="http://localhost:8000" -e MODEL="neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16" <container-image-repo>/guidellm-benchmark:latest

Configuration Options

The container supports the following environment variables:

  • TARGET: The target endpoint for benchmarking (default: http://localhost:8000)
  • MODEL: The model to benchmark (default: neuralmagic/Meta-Llama-3.1-8B-Instruct-quantized.w4a16)
  • RATE_TYPE: The rate type for benchmarking (default: sweep)
  • DATA: The data configuration (default: prompt_tokens=256,output_tokens=128)
  • MAX_REQUESTS: Maximum number of requests (default: 100)
  • MAX_SECONDS: Maximum duration in seconds
  • OUTPUT_PATH: Path for output files (default: /results/guidellm_benchmark_results)
  • OUTPUT_FORMAT: Output format (json, yaml, or yml)

Security Considerations

  • Uses a non-root user for running the benchmark
  • Includes proper file permissions
  • Implements healthcheck for container monitoring
  • Follows container security best practices

Related Issues

Checklist

  • Added Dockerfile with proper security configurations
  • Added run_benchmark.sh script with environment variable support
  • Added documentation for configuration options
  • Tested container build and run
  • Followed security best practices

@sjmonson
Copy link
Collaborator

Could you put these files under a /build/ directory? Also why python 3.11 and not 3.13 since its the latest version we offer support for?

Dockerfile Outdated
Comment on lines 31 to 34
# Healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this was an accidental inclusion since GuideLLM does not provide a web server.

Suggested change
# Healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I remove this in the new build/Dockerfile.

Dockerfile Outdated
WORKDIR /app

# Install GuideLLM
RUN pip install git+https://github.com/neuralmagic/guidellm.git
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than installing main, install our current HEAD. Also cp from within the container to avoid having two COPY layers.

Suggested change
RUN pip install git+https://github.com/neuralmagic/guidellm.git
COPY . /source
RUN pip install /source && \
cp /source/build/run_benchmark.sh /app/

run_benchmark.sh Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this script is going to be the ENTRYPOINT and not the CMD than it needs to be more flexible. Either add an extra arguments variable or append command line arguments to the command.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I allow it to add extra arguments.

…arking

fix pre-commit issue?

Add Docker build files and update .gitignore
@wangchen615 wangchen615 requested a review from sjmonson April 22, 2025 04:08
Copy link
Member

@markurtz markurtz left a comment

Choose a reason for hiding this comment

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

Let some comments throughout. Additionally, I know we had a request to move it to build/, but this is a commonly named folder that python and potential future builds will use.

I've generally seen the parent folder be docker/ at the root and then different python versions could be either nested folders under that with a Dockerfile or multiple Dockerfiles a the root with extensions of the python version such as Dockerfile.py39

@@ -0,0 +1,32 @@
FROM python:3.12-slim
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to have this at one of the extremes for the supported versions rather than somewhere in the middle, especially since the max and min version are tested much more; ie 3.9 or 3.13

FROM python:3.12-slim

LABEL org.opencontainers.image.source="https://github.com/neuralmagic/guidellm"
LABEL org.opencontainers.image.description="GuideLLM Benchmark Container"
Copy link
Member

Choose a reason for hiding this comment

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

NIT: can we remove the benchmark from this so we keep it flexible towards future goals of evals and things like that?

RUN apt-get update && apt-get install -y \
git \
curl \
&& pip install git+https://github.com/neuralmagic/guidellm.git \
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned that this is too restrictive in that it always builds from the latest main, so it will be tough to specify what should be built here other than from the latest main either with the build system for a specific release or for a user.

Can we expand this with a build-arg for the package version to build? Which we can set as default to build from the latest main, but otherwise can utilize it to specify the release tag/branch to build from.

CMD curl -f http://localhost:8000/health || exit 1

# Set the entrypoint
ENTRYPOINT ["/app/run_benchmark.sh"]
Copy link
Member

Choose a reason for hiding this comment

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

Can we change this out so that we are setting the entrypoint to "guidellm" or "guidellm benchmark"? We can then set the CMD after to include any specific args we need passed in / surface from the settings or set it to --help for users to get started with. This way we can enable and passthrough and remove duplication of arguments we need to pass through and another script to maintain and add functionality to.

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

See note on the entrypoint for the Dockerfile, I'd like to see if we can remove this script fully or make it optional to package in

@@ -0,0 +1,32 @@
FROM python:3.12-slim
Copy link
Member

Choose a reason for hiding this comment

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

Also, what are our plans for supporting the range of python versions? Anything we should do here to create specific Dockerfiles for each supported python version?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Normally I would recommend handling this either though build args or postfixes on the Containerfile name. E.g.

Suggested change
FROM python:3.12-slim
ARG python_version=3.13
FROM python:${python_version}-slim

Or name this file something like Containerfile.python-3.13

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

Successfully merging this pull request may close these issues.

Add Docker and Kubernetes Support for GuideLLM Benchmarking [Nice to Have] Container builds
4 participants