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):
|
2023-05-31 02:55:59 -06:00
|
|
|
await flash_neox_handle.health(300)
|
2023-05-16 12:22:11 -06:00
|
|
|
return flash_neox_handle.client
|
2023-05-15 15:36:30 -06:00
|
|
|
|
|
|
|
|
2024-06-25 08:53:20 -06:00
|
|
|
@pytest.mark.release
|
2023-06-30 11:09:59 -06:00
|
|
|
@pytest.mark.skip
|
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,
|
2023-06-02 09:12:30 -06:00
|
|
|
decoder_input_details=True,
|
2023-05-15 15:36:30 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
2024-06-25 08:53:20 -06:00
|
|
|
@pytest.mark.release
|
2023-06-30 11:09:59 -06:00
|
|
|
@pytest.mark.skip
|
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-06-08 06:51:52 -06:00
|
|
|
assert all(
|
2023-05-23 10:16:48 -06:00
|
|
|
[text == generated_texts[0] for text in generated_texts]
|
2023-06-08 06:51:52 -06:00
|
|
|
), generated_texts
|
2023-05-15 15:36:30 -06:00
|
|
|
|
2023-05-16 12:22:11 -06:00
|
|
|
assert responses == response_snapshot
|