-
Notifications
You must be signed in to change notification settings - Fork 454
[CI] add diffusion ci #174
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
Changes from 15 commits
ca509e6
852d51d
ddd603a
c604ffc
e01765b
e5ec82b
0fb901b
405a2dd
5948882
ccf084b
6d8de80
570beb6
82dc002
af75322
94f6fc9
22f150a
9586a86
a0626e1
1c9235c
e63c151
ebd1700
9dc7a70
205238f
edda013
0b86583
1b12c80
28e45fd
baa9740
f3ca068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if command -v nvidia-smi >/dev/null 2>&1; then | ||
| nvidia-smi | ||
| fi | ||
|
|
||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../.." && pwd)" | ||
| UV_BIN="uv" | ||
| PYTHON_BOOTSTRAP="${PYTHON:-python3}" | ||
| VENV_DIR="${VENV_DIR:-${REPO_ROOT}/.venv-simple-test}" | ||
| TARGET_PY_VERSION="3.12" | ||
|
|
||
| if ! command -v "${PYTHON_BOOTSTRAP}" >/dev/null 2>&1; then | ||
| PYTHON_BOOTSTRAP="python" | ||
| fi | ||
|
|
||
| cd "${REPO_ROOT}" | ||
|
|
||
| # Ensure pip-installed scripts (including uv) are on PATH | ||
| PYTHON_SCRIPTS="$(${PYTHON_BOOTSTRAP} -c 'import sysconfig; print(sysconfig.get_path("scripts"))')" | ||
| USER_BASE="$(${PYTHON_BOOTSTRAP} -m site --user-base 2>/dev/null || true)" | ||
| PATH="${PYTHON_SCRIPTS}:${PATH}" | ||
| if [[ -n "${USER_BASE}" ]]; then | ||
| PATH="${USER_BASE}/bin:${PATH}" | ||
| fi | ||
| export HF_HOME=/fsx/hf_cache | ||
|
|
||
| if ! command -v "${UV_BIN}" >/dev/null 2>&1; then | ||
| "${PYTHON_BOOTSTRAP}" -m pip install --upgrade pip | ||
| "${PYTHON_BOOTSTRAP}" -m pip install uv | ||
| hash -r | ||
| fi | ||
|
|
||
| TARGET_PY_PATH="$(${UV_BIN} python find "${TARGET_PY_VERSION}" 2>/dev/null | head -n1 || true)" | ||
| if [[ -z "${TARGET_PY_PATH}" ]]; then | ||
| "${UV_BIN}" python install "${TARGET_PY_VERSION}" | ||
| TARGET_PY_PATH="$(${UV_BIN} python find "${TARGET_PY_VERSION}" 2>/dev/null | head -n1 || true)" | ||
| fi | ||
|
|
||
| if [[ -z "${TARGET_PY_PATH}" ]]; then | ||
| echo "Failed to locate python ${TARGET_PY_VERSION}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -d "${VENV_DIR}" ]]; then | ||
| "${UV_BIN}" venv --python "${TARGET_PY_PATH}" "${VENV_DIR}" | ||
| fi | ||
|
|
||
| VENV_PYTHON="${VENV_DIR}/bin/python" | ||
| [[ -x "${VENV_PYTHON}" ]] || { echo "Python not found in ${VENV_DIR}"; exit 1; } | ||
|
|
||
| "${UV_BIN}" pip install --python "${VENV_PYTHON}" vllm==0.11.0 | ||
| "${UV_BIN}" pip install --python "${VENV_PYTHON}" -e ".[dev]" | ||
| "${VENV_PYTHON}" -m pytest -s -v tests/test_diffusion_model.py | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import pytest | ||
| import torch | ||
|
|
||
| from vllm_omni import Omni | ||
|
|
||
| models = ["Tongyi-MAI/Z-Image-Turbo"] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("model_name", models) | ||
| def test_diffusion_model(model_name: str): | ||
| m = Omni(model=model_name) | ||
| # high resolution may cause OOM on L4 | ||
| height = 256 | ||
| width = 256 | ||
| images = m.generate( | ||
| "a photo of a cat sitting on a laptop keyboard", | ||
| height=height, | ||
| width=width, | ||
| num_inference_steps=2, | ||
| guidance_scale=0.0, | ||
| generator=torch.Generator("cuda").manual_seed(42), | ||
| num_outputs_per_prompt=2, | ||
| ) | ||
| assert len(images) == 2 | ||
| # check image size | ||
| assert images[0].width == width | ||
| assert images[0].height == height | ||
| images[0].save("z_image_output.png") |
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.
Is it possible to use this file as a general env setup for all current examples? If it is, we can rename it. And also it can be used to run all UT/ST.
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.
I have tried it before. But I don't know how to set environment variables persistent which will lead to error like
/bin/bash: line 2: pytest: command not found.We will have a general env setup when dockerfile is ready.
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.
@congw729 Could you please help to resolve this? I don't have bandwidth today.
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.
Let me check what I can do.