| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | import pytest |
| 4 | |
| 5 | from vllm.platforms import current_platform |
| 6 | |
| 7 | from ..utils import compare_two_settings, create_new_process_for_each_test |
| 8 | |
| 9 | |
| 10 | @pytest.mark.parametrize( |
| 11 | "PP_SIZE, MODEL_NAME", |
| 12 | [ |
| 13 | (2, "JackFram/llama-160m"), |
| 14 | ], |
| 15 | ) |
| 16 | @pytest.mark.parametrize( |
| 17 | "ATTN_BACKEND", |
| 18 | [None] if current_platform.is_rocm() else ["FLASH_ATTN"], |
| 19 | ) |
| 20 | @create_new_process_for_each_test() |
| 21 | def test_pp_cudagraph( |
| 22 | PP_SIZE: int, |
| 23 | MODEL_NAME: str, |
| 24 | ATTN_BACKEND: str | None, |
| 25 | ): |
| 26 | cudagraph_args = [ |
| 27 | # use half precision for speed and memory savings in CI environment |
| 28 | "--dtype", |
| 29 | "float16", |
| 30 | "--pipeline-parallel-size", |
| 31 | str(PP_SIZE), |
| 32 | "--distributed-executor-backend", |
| 33 | "mp", |
| 34 | ] |
| 35 | # On ROCm, defer to the platform attention selector instead of forcing a backend. |
| 36 | if ATTN_BACKEND is not None: |
| 37 | cudagraph_args.append(f"--attention-backend={ATTN_BACKEND}") |
| 38 | |
| 39 | eager_args = cudagraph_args + ["--enforce-eager"] |
| 40 | |
| 41 | compare_two_settings(MODEL_NAME, eager_args, cudagraph_args) |