test_models.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import pytest
  2. MODELS = [
  3. "EleutherAI/pythia-70m-deduped",
  4. "meta-llama/Llama-2-7b-hf",
  5. "Deci/DeciLM-7b",
  6. "tiiuae/falcon-7b",
  7. "microsoft/phi-2",
  8. ]
  9. @pytest.mark.parametrize("model", MODELS)
  10. @pytest.mark.parametrize("dtype", ["half"])
  11. @pytest.mark.parametrize("max_tokens", [128])
  12. def test_models(
  13. hf_runner,
  14. aphrodite_runner,
  15. example_prompts,
  16. model: str,
  17. dtype: str,
  18. max_tokens: int,
  19. ) -> None:
  20. hf_model = hf_runner(model, dtype=dtype)
  21. hf_outputs = hf_model.generate_greedy(example_prompts, max_tokens)
  22. del hf_model
  23. aphrodite_model = aphrodite_runner(model, dtype=dtype)
  24. aphrodite_outputs = aphrodite_model.generate_greedy(
  25. example_prompts, max_tokens)
  26. del aphrodite_model
  27. for i in range(len(example_prompts)):
  28. hf_output_ids, hf_output_str = hf_outputs[i]
  29. aphrodite_output_ids, aphrodite_output_str = aphrodite_outputs[i]
  30. assert hf_output_str == aphrodite_output_str, (
  31. f"Test{i}:\nHF: {hf_output_str!r}\nAphrodite: "
  32. f"{aphrodite_output_str!r}")
  33. assert hf_output_ids == aphrodite_output_ids, (
  34. f"Test{i}:\nHF: {hf_output_ids}\nAphrodite: {aphrodite_output_ids}"
  35. )