2023-05-15 15:36:30 -06:00
|
|
|
import pytest
|
|
|
|
|
2023-05-16 12:22:11 -06:00
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def flash_neox_handle(launcher):
|
2023-05-22 07:05:32 -06:00
|
|
|
with launcher("stabilityai/stablelm-tuned-alpha-3b", num_shard=1) as handle:
|
2023-05-16 12:22:11 -06:00
|
|
|
yield handle
|
2023-05-15 15:36:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
2023-05-16 12:22:11 -06:00
|
|
|
async def flash_neox(flash_neox_handle):
|
|
|
|
await flash_neox_handle.health(240)
|
|
|
|
return flash_neox_handle.client
|
2023-05-15 15:36:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
2023-05-16 12:22:11 -06:00
|
|
|
async def test_flash_neox(flash_neox, response_snapshot):
|
2023-05-15 15:36:30 -06:00
|
|
|
response = await flash_neox.generate(
|
2023-05-22 07:05:32 -06:00
|
|
|
"<|USER|>What's your mood today?<|ASSISTANT|>",
|
2023-05-15 15:36:30 -06:00
|
|
|
max_new_tokens=10,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert response.details.generated_tokens == 10
|
2023-05-16 12:22:11 -06:00
|
|
|
assert response == response_snapshot
|
2023-05-15 15:36:30 -06:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
2023-05-16 12:22:11 -06:00
|
|
|
async def test_flash_neox_load(flash_neox, generate_load, response_snapshot):
|
2023-05-15 15:36:30 -06:00
|
|
|
responses = await generate_load(
|
|
|
|
flash_neox,
|
2023-05-22 07:05:32 -06:00
|
|
|
"<|USER|>What's your mood today?<|ASSISTANT|>",
|
2023-05-15 15:36:30 -06:00
|
|
|
max_new_tokens=10,
|
|
|
|
n=4,
|
|
|
|
)
|
|
|
|
|
2023-05-22 07:05:32 -06:00
|
|
|
generated_texts = [r.generated_text for r in responses]
|
|
|
|
|
|
|
|
assert len(generated_texts) == 4
|
2023-05-23 10:16:48 -06:00
|
|
|
assert generated_texts, all(
|
|
|
|
[text == generated_texts[0] for text in generated_texts]
|
|
|
|
)
|
2023-05-15 15:36:30 -06:00
|
|
|
|
2023-05-16 12:22:11 -06:00
|
|
|
assert responses == response_snapshot
|