test_flash_neox.py 1.15 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
async def flash_neox(flash_neox_handle):
OlivierDehaene's avatar
OlivierDehaene committed
12
    await flash_neox_handle.health(300)
13
    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
        max_new_tokens=10,
21
        decoder_input_details=True,
22
23
24
    )

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


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

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

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

44
    assert responses == response_snapshot