test_flash_starcoder.py 1.35 KB
Newer Older
1
2
import pytest

3
4
5
6
7

@pytest.fixture(scope="module")
def flash_starcoder_handle(launcher):
    with launcher("bigcode/starcoder", num_shard=2) as handle:
        yield handle
8
9
10


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


@pytest.mark.asyncio
@pytest.mark.private
18
async def test_flash_starcoder(flash_starcoder, response_snapshot):
19
20
21
    response = await flash_starcoder.generate("def print_hello", max_new_tokens=10)

    assert response.details.generated_tokens == 10
22
    assert response == response_snapshot
23
24
25
26


@pytest.mark.asyncio
@pytest.mark.private
27
async def test_flash_starcoder_default_params(flash_starcoder, response_snapshot):
28
29
30
31
    response = await flash_starcoder.generate(
        "def print_hello", max_new_tokens=60, temperature=0.2, top_p=0.95, seed=0
    )

32
    assert response.details.generated_tokens == 60
33
    assert response == response_snapshot
34
35
36
37


@pytest.mark.asyncio
@pytest.mark.private
38
async def test_flash_starcoder_load(flash_starcoder, generate_load, response_snapshot):
39
40
41
42
43
    responses = await generate_load(
        flash_starcoder, "def print_hello", max_new_tokens=10, n=4
    )

    assert len(responses) == 4
44
    assert all([r.generated_text == responses[0].generated_text for r in responses])
45

46
    assert responses == response_snapshot