test_flash_starcoder.py 1.52 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
async def flash_starcoder(flash_starcoder_handle):
OlivierDehaene's avatar
OlivierDehaene committed
12
    await flash_starcoder_handle.health(300)
13
    return flash_starcoder_handle.client
14
15


16
@pytest.mark.release
17
18
@pytest.mark.asyncio
@pytest.mark.private
19
async def test_flash_starcoder(flash_starcoder, response_snapshot):
20
21
22
    response = await flash_starcoder.generate(
        "def print_hello", max_new_tokens=10, decoder_input_details=True
    )
23
24

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


28
@pytest.mark.release
29
30
@pytest.mark.asyncio
@pytest.mark.private
31
async def test_flash_starcoder_default_params(flash_starcoder, response_snapshot):
32
    response = await flash_starcoder.generate(
33
34
35
36
37
38
        "def print_hello",
        max_new_tokens=60,
        temperature=0.2,
        top_p=0.95,
        decoder_input_details=True,
        seed=0,
39
40
    )

41
    assert response.details.generated_tokens == 60
42
    assert response == response_snapshot
43
44


45
@pytest.mark.release
46
47
@pytest.mark.asyncio
@pytest.mark.private
48
async def test_flash_starcoder_load(flash_starcoder, generate_load, response_snapshot):
49
50
51
52
53
    responses = await generate_load(
        flash_starcoder, "def print_hello", max_new_tokens=10, n=4
    )

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

56
    assert responses == response_snapshot