test_flash_neox.py 1.12 KB
Newer Older
1
2
import pytest

3
4
5

@pytest.fixture(scope="module")
def flash_neox_handle(launcher):
6
    with launcher("stabilityai/stablelm-tuned-alpha-3b", num_shard=1) as handle:
7
        yield handle
8
9
10


@pytest.fixture(scope="module")
11
12
13
async def flash_neox(flash_neox_handle):
    await flash_neox_handle.health(240)
    return flash_neox_handle.client
14
15
16


@pytest.mark.asyncio
17
async def test_flash_neox(flash_neox, response_snapshot):
18
    response = await flash_neox.generate(
19
        "<|USER|>What's your mood today?<|ASSISTANT|>",
20
21
22
23
        max_new_tokens=10,
    )

    assert response.details.generated_tokens == 10
24
    assert response == response_snapshot
25
26
27


@pytest.mark.asyncio
28
async def test_flash_neox_load(flash_neox, generate_load, response_snapshot):
29
30
    responses = await generate_load(
        flash_neox,
31
        "<|USER|>What's your mood today?<|ASSISTANT|>",
32
33
34
35
        max_new_tokens=10,
        n=4,
    )

36
37
38
    generated_texts = [r.generated_text for r in responses]

    assert len(generated_texts) == 4
39
40
41
    assert generated_texts, all(
        [text == generated_texts[0] for text in generated_texts]
    )
42

43
    assert responses == response_snapshot