# Axolotl

#### Setup

This example is based on <https://github.com/axolotl-ai-cloud/axolotl/tree/main/examples/mistral>.

```bash
git clone git@github.com:axolotl-ai-cloud/axolotl.git
cd axolotl/examples
```

#### Define workload

```yaml
resources:
  accelerators: B200:8
  infra: mithril

workdir: mistral

setup: |
  docker pull winglian/axolotl:main-py3.10-cu118-2.0.1

run: |
  docker run --gpus all \
    -v ~/sky_workdir:/sky_workdir \
    -v /root/.cache:/root/.cache \
    winglian/axolotl:main-py3.10-cu118-2.0.1 \
    huggingface-cli login --token ${HF_TOKEN} 

  docker run --gpus all \
    -v ~/sky_workdir:/sky_workdir \
    -v /root/.cache:/root/.cache \
    winglian/axolotl:main-py3.10-cu118-2.0.1 \
    accelerate launch -m axolotl.cli.train /sky_workdir/qlora.yaml

envs:
  HF_TOKEN: null # Pass with `--secret HF_TOKEN` in CLI
  
```

#### Run workload

{% code overflow="wrap" %}

```bash
HF_TOKEN=xxx ml launch -c axolotl axolotl.yaml --secret HF_TOKEN -y -i30 --down
```

{% endcode %}

* `--cluster axolotl` — Name the cluster axolotl. If a cluster with this name already exists, it will be reused; otherwise a new one is created.
* `--secret HF_TOKEN` Pass HF\_TOKEN as a secret environment variable to the remote cluster. Since no =value is provided, it reads the value from your local environment ($HF\_TOKEN). Secrets behave like --env but are redacted in logs and YAML outputs for security.
* `-i30` or `--idle-minutes-to-autostop 30` — Automatically stop the cluster after 30 minutes of idleness (no running or pending jobs in the cluster's job queue).
* `--down` Autodown — Instead of just stopping the cluster when the autostop timer fires, tear it down entirely (delete the cloud resources). Combined with -i30, this means: after all jobs finish and the cluster has been idle for 30 minutes, destroy the cluster completely.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mithril.ai/mithril-cli/tutorials/axolotl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
