Download code/tt_embgemma/tests/test_host_config.py from changh95/embeddinggemma-2: direct link, hf CLI and curl.
- Browser
- Download file 2.51 kB
-
https://huggingface.co/changh95/embeddinggemma-2/resolve/main/code/tt_embgemma/tests/test_host_config.py
- Command line
-
hf download hf://changh95/embeddinggemma-2/code/tt_embgemma/tests/test_host_config.py
-
curl -L -o test_host_config.py https://huggingface.co/changh95/embeddinggemma-2/resolve/main/code/tt_embgemma/tests/test_host_config.py
2.51 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """Host tests of the server-start configuration (COMPILE-TIME surface) and the model constants.""" | |
| import pytest | |
| from tt_embgemma import config as C | |
| from tt_embgemma import model_spec as S | |
| def test_defaults(): | |
| c = C.resolve_config({}) | |
| assert c.modalities == ("text", "image", "video", "audio") | |
| assert (c.max_batch, c.max_seq_len, c.image_tokens_max) == (32, 2048, 280) | |
| assert c.text_buckets == (32, 64, 128, 256, 512, 1024, 2048) and c.long_buckets == (1024, 2048) | |
| assert c.vision_buckets == (864, 1440, 2592) | |
| assert c.audio_buckets == (512, 1024, 2048, 3072) | |
| assert c.max_images == 64 and c.text_engine == "ttnn" | |
| assert not hasattr(c, "vision_engine") and not hasattr(c, "audio_engine") | |
| def test_overrides(): | |
| c = C.resolve_config({"EMBGEMMA_MODALITIES": "audio,text", "EMBGEMMA_MAX_SEQ_LEN": "512", | |
| "EMBGEMMA_IMAGE_TOKENS_MAX": "1120", "EMBGEMMA_DEFAULT_PROMPT": "SearchQuery", | |
| "EMBGEMMA_TEXT_BUCKETS": "64,32,512"}) | |
| assert c.modalities == ("text", "audio") | |
| assert c.max_seq_len == 512 and c.long_buckets == () and c.text_buckets == (32, 64, 512) | |
| assert c.vision_buckets == (864, 1440, 2592, 5184, 10368) | |
| assert c.default_prompt == "SearchQuery" | |
| c = C.resolve_config({"EMBGEMMA_MAX_SEQ_LEN": "8192"}) | |
| assert max(c.long_buckets) == 8192 and max(c.text_buckets) == 8192 | |
| def test_refusals(env): | |
| with pytest.raises(ValueError): | |
| C.resolve_config(env) | |
| def test_audio_tokens(): | |
| assert S.audio_tokens_for_samples(16000) == 25 | |
| assert S.audio_tokens_for_samples(480000) == 750 | |
| assert S.audio_tokens_for_samples(10 ** 7) == 750 | |
| assert S.audio_tokens_for_samples(100) == 0 | |
| def test_server_import_has_no_device_side_effects(): | |
| import sys | |
| import tt_embgemma.server.app as a | |
| assert a.app is not None and "ttnn" not in sys.modules | |