> For the complete documentation index, see [llms.txt](https://docs.mithril.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mithril.ai/mithril-cli/tutorials/axolotl.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
