axolotl-ai-cloud--axolotl
78ec5d9290
ci-cd / build-axolotl-uv (<nil>, 130, 13.0.0, linux/amd64,linux/arm64, 3.12, 2.11.0) (push) Has been cancelled
ci-cd / build-axolotl-uv (<nil>, 130, 13.0.0, true, linux/amd64,linux/arm64, 3.12, 2.12.0) (push) Has been cancelled
ci-cd / build-axolotl-cloud-uv (<nil>, 130, 13.0.0, linux/amd64,linux/arm64, 3.12, 2.11.0) (push) Has been cancelled
ci-cd / build-axolotl-cloud-uv (<nil>, 130, 13.0.0, true, linux/amd64,linux/arm64, 3.12, 2.12.0) (push) Has been cancelled
ci-cd / build-axolotl-cloud-no-tmux-uv (<nil>, 130, 13.0.0, linux/amd64,linux/arm64, 3.12, 2.11.0) (push) Has been cancelled
ci-cd / build-axolotl-cloud-no-tmux-uv (<nil>, 130, 13.0.0, true, linux/amd64,linux/arm64, 3.12, 2.12.0) (push) Has been cancelled
ci-cd-base / build-base-uv (130, 13.0.0, , Dockerfile-uv-base, linux/amd64,linux/arm64, 3.12, 2.12.0, 9.0 10.0 10.3 12.0+PTX) (push) Has been cancelled
ci-cd-base / build-base-uv (130, 13.0.0, , Dockerfile-uv-base, linux/amd64,linux/arm64, 3.12, 2.12.1, 9.0 10.0 10.3 12.0+PTX) (push) Has been cancelled
ci-cd-base / build-base-uv (130, 13.0.0, , Dockerfile-uv-base, linux/amd64,linux/arm64, 3.12, 2.13.0, 9.0 10.0 10.3 12.0+PTX) (push) Has been cancelled
ci-cd-base / build-base-uv (132, 13.2.1, , Dockerfile-uv-base, linux/amd64,linux/arm64, 3.12, 2.13.0, 9.0 10.0 10.3 12.0+PTX, https://download.pytorch.org/whl/cu132) (push) Has been cancelled
ci-cd-base / build-base-uv (130, 13.0.0, , Dockerfile-uv-base, linux/amd64,linux/arm64, 3.12, 2.11.0, 9.0 10.0 10.3 12.0+PTX) (push) Has been cancelled
Tests / PyTest (3.12, 2.12.1) (push) Has been cancelled
Tests / PyTest (3.12, 2.13.0) (push) Has been cancelled
docker-e2e-tests / gate-skip-e2e (push) Has been cancelled
docker-e2e-tests / docker-e2e-tests-1st (<nil>, 130, 13.0.0, 1, 3.12, 2.12.1) (push) Has been cancelled
docker-e2e-tests / docker-e2e-tests (<nil>, 130, 13.0.0, 1, 3.12, 2.11.0) (push) Has been cancelled
docker-e2e-tests / docker-e2e-kernel-tests (<nil>, 130, 13.0.0, 1, 3.12, 2.11.0) (push) Has been cancelled
docker-e2e-tests / docker-e2e-kernel-tests (<nil>, 130, 13.0.0, 1, 3.12, 2.12.1) (push) Has been cancelled
docker-e2e-tests / docker-e2e-cleanup (<nil>, 130, 13.0.0, 1, 3.12, 2.12.1) (push) Has been cancelled
Publish Docs / build-deploy (push) Has been cancelled
Tests / PyTest from Source Dist (3.12, 2.11.0) (push) Has been cancelled
Tests / PyTest from Source Dist (3.12, 2.12.1) (push) Has been cancelled
Tests / PyTest from Source Dist (3.12, 2.13.0) (push) Has been cancelled
Tests / pre-commit (push) Has been cancelled
Tests / Prefetch S3 once to prime the CDN cache (push) Has been cancelled
Tests / PyTest (3.12, 2.11.0) (push) Has been cancelled
42 行
1.6 KiB
Python
42 行
1.6 KiB
Python
"""Regression tests: prompt-strategy ``_tokenize`` must not crash on an empty result.
|
|
|
|
A field that tokenizes to nothing (e.g. an empty ``generation``/sub-field with a
|
|
tokenizer that does not prepend BOS) used to raise ``IndexError`` in these overrides
|
|
because they indexed ``result["input_ids"][-1]`` without the empty-guard the base
|
|
``PromptTokenizingStrategy._tokenize`` already has.
|
|
"""
|
|
|
|
import pytest
|
|
from transformers import AutoTokenizer
|
|
|
|
from axolotl.prompt_strategies.metharme import MetharmePromptTokenizingStrategy
|
|
from axolotl.prompt_tokenizers import ReflectionPromptTokenizingStrategy
|
|
|
|
from tests.hf_offline_utils import enable_hf_offline
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
@enable_hf_offline
|
|
def no_bos_tokenizer(download_tiny_qwen3_model):
|
|
# Qwen3 sets add_bos_token=False, so tokenizing "" yields an empty input_ids list.
|
|
return AutoTokenizer.from_pretrained("axolotl-ai-co/tiny-qwen3-129m")
|
|
|
|
|
|
def _build(strategy_cls, tokenizer):
|
|
strategy = strategy_cls.__new__(strategy_cls)
|
|
strategy.tokenizer = tokenizer
|
|
strategy.sequence_len = 2048
|
|
return strategy
|
|
|
|
|
|
def test_metharme_tokenize_empty_does_not_crash(no_bos_tokenizer):
|
|
strategy = _build(MetharmePromptTokenizingStrategy, no_bos_tokenizer)
|
|
result = strategy._tokenize("") # raised IndexError before the fix
|
|
assert list(result["input_ids"]) == []
|
|
|
|
|
|
def test_reflection_tokenize_empty_does_not_crash(no_bos_tokenizer):
|
|
strategy = _build(ReflectionPromptTokenizingStrategy, no_bos_tokenizer)
|
|
result = strategy._tokenize("") # raised IndexError before the fix
|
|
assert list(result["input_ids"]) == []
|