Files
axolotl/examples/apertus/README.md
NanoCode012 c51d6b06c3 feat: add apertus model and cce (#3144) [skip ci]
* feat: add apertus, glm4v, glm4v_moe cce

* fix: arcee docs

* feat: add apertus

* feat: added vram usage

* fix: add apertus note

* feat: update doc on apertus xielu

* fix: add monkeypatch for xielu activation issue

* fix: simplify env

* feat: pin commit

* feat: add packing

* chore: move patch calling

* Update examples/apertus/README.md

Co-authored-by: salman <salman.mohammadi@outlook.com>

* Update examples/apertus/README.md

Co-authored-by: salman <salman.mohammadi@outlook.com>

* Update examples/apertus/README.md

Co-authored-by: salman <salman.mohammadi@outlook.com>

---------

Co-authored-by: salman <salman.mohammadi@outlook.com>
2025-09-19 17:34:04 +07:00

3.8 KiB

Finetune Swiss-AI's Apertus with Axolotl

Apertus is a family of opensource models trained by Swiss-ai.

This guide shows how to fine-tune it with Axolotl with multi-turn conversations and proper masking.

Getting started

  1. Install Axolotl following the installation guide. You need to install from main as Apertus is only on nightly or use our latest Docker images.

    Here is an example of how to install from main for pip:

# Ensure you have Pytorch installed (Pytorch 2.6.0 min)
git clone https://github.com/axolotl-ai-cloud/axolotl.git
cd axolotl

pip3 install packaging==23.2 setuptools==75.8.0 wheel ninja
pip3 install --no-build-isolation -e '.[flash-attn]'

# Install CCE https://docs.axolotl.ai/docs/custom_integrations.html#cut-cross-entropy
python scripts/cutcrossentropy_install.py | sh
  1. (Optional, highly recommended) Install XIELU CUDA
## Recommended for reduced VRAM and faster speeds

# Point to CUDA toolkit directory
# For those using our Docker image, use the below path.
export CUDA_HOME=/usr/local/cuda

pip3 install git+https://github.com/nickjbrowning/XIELU@59d6031 --no-build-isolation --no-deps

For any installation errors, see XIELU Installation Issues

  1. Run the finetuning example:
axolotl train examples/apertus/apertus-8b-qlora.yaml

This config uses about 8.7 GiB VRAM.

Let us know how it goes. Happy finetuning! 🚀

Tips

  • For inference, the official Apertus team recommends top_p=0.9 and temperature=0.8.
  • You can instead use full paremter fine-tuning by removing the adapter: qlora and load_in_4bit: true from the config.
  • Read more on how to load your own dataset at docs.
  • The dataset format follows the OpenAI Messages format as seen here.

XIELU Installation Issues

ModuleNotFoundError: No module named 'torch'

Please check these one by one:

  • Running in correct environment
  • Env has PyTorch installed
  • CUDA toolkit is at CUDA_HOME

If those didn't help, please try the below solutions:

  1. Pass env for CMAKE and try install again:

    Python_EXECUTABLE=$(which python) pip3 install git+https://github.com/nickjbrowning/XIELU@59d6031 --no-build-isolation --no-deps
    
  2. Git clone the repo and manually hardcode python path:

    git clone https://github.com/nickjbrowning/XIELU
    cd xielu
    git checkout 59d6031
    
    cd xielu
    nano CMakeLists.txt  # or vi depending on your preference
    
    execute_process(
    -    COMMAND ${Python_EXECUTABLE} -c "import torch.utils; print(torch.utils.cmake_prefix_path)"
    +    COMMAND /root/miniconda3/envs/py3.11/bin/python -c "import torch.utils; print(torch.utils.cmake_prefix_path)"
        RESULT_VARIABLE TORCH_CMAKE_PATH_RESULT
        OUTPUT_VARIABLE TORCH_CMAKE_PATH_OUTPUT
        ERROR_VARIABLE TORCH_CMAKE_PATH_ERROR
    )
    
    pip3 install . --no-build-isolation --no-deps
    

Optimization Guides