Build Release #186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test arm64 musllinux wheel repair | |
| on: workflow_dispatch | |
| permissions: | |
| contents: read | |
| jobs: | |
| build_and_test_arm64_wheels: | |
| name: Build and test arm64 wheels | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: "recursive" | |
| - name: Build and test wheels | |
| uses: pypa/cibuildwheel@v2.22.0 | |
| env: | |
| CIBW_SKIP: "pp*" | |
| CIBW_REPAIR_WHEEL_COMMAND: "LD_LIBRARY_PATH={project}/llama_cpp/lib auditwheel repair -w {dest_dir} {wheel}" | |
| CIBW_ARCHS: "aarch64" | |
| CIBW_ENVIRONMENT: CMAKE_ARGS="-DGGML_NATIVE=off" | |
| CIBW_BUILD: "cp38-*" | |
| CIBW_TEST_REQUIRES: "pytest" | |
| CIBW_TEST_COMMAND: | | |
| mkdir -p /tmp/llama-cpp-python-wheel-test | |
| cd /tmp/llama-cpp-python-wheel-test | |
| cat > test_wheel.py <<'PY' | |
| import json | |
| import os | |
| from pathlib import Path | |
| import llama_cpp | |
| from llama_cpp import ChatCompletionRequestUserMessage | |
| from llama_cpp.llama_chat_format import Jinja2ChatFormatter | |
| def test_native_library_loads(): | |
| assert llama_cpp.__version__ | |
| llama_cpp.llama_backend_init() | |
| llama_cpp.llama_backend_free() | |
| def test_vocab_tokenization(): | |
| project = Path(os.environ["LLAMA_CPP_TEST_PROJECT"]) | |
| model_path = project / "vendor/llama.cpp/models/ggml-vocab-llama-spm.gguf" | |
| model = llama_cpp.Llama( | |
| model_path=str(model_path), | |
| vocab_only=True, | |
| verbose=False, | |
| ) | |
| assert model.tokenize(b"Hello World") == [1, 15043, 2787] | |
| def test_grammar_helpers(): | |
| grammar = llama_cpp.LlamaGrammar.from_string('root ::= "true" | "false"') | |
| assert grammar is not None | |
| schema = { | |
| "type": "object", | |
| "properties": {"answer": {"type": "string"}}, | |
| "required": ["answer"], | |
| } | |
| assert llama_cpp.LlamaGrammar.from_json_schema(json.dumps(schema)) is not None | |
| def test_generation_tags_are_ignored(): | |
| formatter = Jinja2ChatFormatter( | |
| template="{% for message in messages %}{% generation %}{{ message['role'] }}: {{ message['content'] }}{% endgeneration %}{% endfor %}", | |
| eos_token="</s>", | |
| bos_token="<s>", | |
| ) | |
| response = formatter( | |
| messages=[ | |
| ChatCompletionRequestUserMessage(role="user", content="hi"), | |
| ] | |
| ) | |
| assert response.prompt == "user: hi" | |
| PY | |
| LLAMA_CPP_TEST_PROJECT={project} python -m pytest -q test_wheel.py | |
| with: | |
| output-dir: wheelhouse | |
| - name: Check wheel tags | |
| run: | | |
| ls -la wheelhouse | |
| test -n "$(find wheelhouse -name '*manylinux*aarch64*.whl' -print -quit)" | |
| test -n "$(find wheelhouse -name '*musllinux*aarch64*.whl' -print -quit)" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: arm64-wheel-repair-test | |
| path: ./wheelhouse/*.whl |