test_full_graph.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import pytest
  3. from aphrodite.common.utils import cuda_device_count_stateless
  4. from ..utils import fork_new_process_for_each_test
  5. @pytest.mark.parametrize("model", ["meta-llama/Meta-Llama-3-8B"])
  6. @pytest.mark.parametrize("tp_size", [1, 2])
  7. @fork_new_process_for_each_test
  8. def test_full_graph(model, tp_size):
  9. # Skip the test if there are not enough CUDA devices.
  10. if cuda_device_count_stateless() < tp_size:
  11. pytest.skip("Not enough CUDA devices for the test.")
  12. # make sure these models can be captured in full graph mode
  13. os.environ["APHRODITE_TEST_DYNAMO_GRAPH_CAPTURE"] = "1"
  14. from aphrodite import LLM, SamplingParams
  15. prompts = [
  16. "Hello, my name is",
  17. "The president of the United States is",
  18. "The capital of France is",
  19. "The future of AI is",
  20. ]
  21. sampling_params = SamplingParams(temperature=0)
  22. llm = LLM(model=model, enforce_eager=True, tensor_parallel_size=tp_size)
  23. outputs = llm.generate(prompts, sampling_params)
  24. # Print the outputs.
  25. for output in outputs:
  26. prompt = output.prompt
  27. generated_text = output.outputs[0].text
  28. print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")