test_oot_registration.py 1013 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import pytest
  3. from aphrodite import LLM, SamplingParams
  4. from ..utils import fork_new_process_for_each_test
  5. @fork_new_process_for_each_test
  6. def test_plugin(dummy_opt_path):
  7. os.environ["APHRODITE_PLUGINS"] = ""
  8. with pytest.raises(Exception) as excinfo:
  9. LLM(model=dummy_opt_path, load_format="dummy")
  10. assert "are not supported for now" in str(excinfo.value)
  11. @fork_new_process_for_each_test
  12. def test_oot_registration(dummy_opt_path):
  13. os.environ["APHRODITE_PLUGINS"] = "register_dummy_model"
  14. prompts = ["Hello, my name is", "The text does not matter"]
  15. sampling_params = SamplingParams(temperature=0)
  16. llm = LLM(model=dummy_opt_path, load_format="dummy")
  17. first_token = llm.get_tokenizer().decode(0)
  18. outputs = llm.generate(prompts, sampling_params)
  19. for output in outputs:
  20. generated_text = output.outputs[0].text
  21. # make sure only the first token is generated
  22. rest = generated_text.replace(first_token, "")
  23. assert rest == ""