Skip to main content

Axolotl Finetuning with TensorFuse Job Queues

Run powerful and flexible Axolotl finetuning jobs on TensorFuse with support for multiple dataset formats, models, and configurations. Perfect for different customers, use cases, parameter sweeps, and model comparisons.

What You Can Do

  • Multiple Dataset Formats: JSONL, CSV, Parquet, HuggingFace datasets
  • Choose any Base Model: Llama, Qwen, Mistral, CodeLlama, and more
  • Flexible Chat Formats: Instructions, conversations, chat templates
  • Parameter Sweeps: Test different hyperparameters automatically
  • Model Comparisons: Compare different models on the same data
  • Automatic Uploads: Models uploaded to HuggingFace Hub
  • Training Monitoring: Full Weights & Biases integration
  • Queue Management: Run multiple experiments in parallel

Prerequisites

  1. TensorFuse Setup: Ensure your cluster is configured (see Getting Started)
  2. Set up Secrets:

Quick Start

1. Set Up Your Project

Create a new directory for your finetuning project:

2. Create Base Configuration

Create axolotl-config.yaml:

3. Create Training Script

Create axolotl-train.py:

4. Create Dockerfile

Create Dockerfile:

5. Deploy and Run

Dataset Formats

1. Chat/Conversation Format (JSONL)

Perfect for chatbots and conversational AI:
Configuration:

2. Instruction Format (CSV/Parquet/JSONL)

Great for instruction-following models: CSV Format (instructions.csv):
Configuration:

3. HuggingFace Datasets

Use any dataset from HuggingFace Hub:

4. Custom Message Mapping

For datasets with different field names:

Configurable Parameters

Model Configuration

Popular Models & Templates:
  • Llama 3.1: meta-llama/Llama-3.1-8B-Instruct + llama3
  • Qwen: Qwen/Qwen2.5-7B-Instruct + qwen2_5
  • Mistral: mistralai/Mistral-7B-Instruct-v0.3 + mistral
  • CodeLlama: codellama/CodeLlama-7b-Instruct-hf + llama3

Training Hyperparameters

LoRA Configuration

Monitoring & Logging

Example Use Cases

Function Calling Assistant

Train models to perform structured function calling for tool usage and API integration:

Code Assistant

Note: For local datasets, update your Dockerfile to copy the dataset file:

Multilingual Chat

Note: Add local dataset to Dockerfile: COPY multilingual-conversations.jsonl .

Configuration Templates

Ready-to-use YAML configurations for common finetuning scenarios. Copy these as starting points and modify for your specific needs.

Template 1: Chat Assistant

Optimized for conversational AI with balanced performance and memory usage:

Template 2: Code Generator

Configured for code generation tasks with longer context and specialized model:

Template 3: Instruction Follower

Designed for general instruction-following with efficient LoRA settings:

Job Management

Efficiently manage your training jobs, monitor progress, and handle multiple experiments running simultaneously.

Monitor Your Jobs

Batch Operations

Run multiple experiments programmatically for parameter sweeps and comparisons:
This approach lets you:
  • Automate experiments: No manual job queuing
  • Compare results: All experiments tracked in W&B
  • Save time: Queue multiple jobs at once

Parameter Sweeps

Learning Rate Sweep

LoRA Rank Comparison

Model Comparison

Monitoring with Weights & Biases

Key Metrics to Watch

  1. Training Loss: Should decrease steadily
  2. Learning Rate: Follow the schedule
  3. GPU Utilization: Should be consistently high
  4. Validation Loss: Check for overfitting

Advanced W&B Configuration

HuggingFace Integration

Automatic Model Upload

Models are automatically uploaded to HuggingFace Hub when training completes:

Upload Configuration Options

Advanced Features

Memory Optimization (for larger models)

Memory Usage Breakdown:
  • load_in_4bit: Reduces model weights from 16-bit to 4-bit (e.g., 8GB model → 2GB)
  • gradient_checkpointing: Trades compute for memory (slower but fits larger models)
  • flash_attention: 2-8x faster attention with lower memory footprint
  • sample_packing: Better GPU utilization, especially with variable-length sequences
  • pad_to_sequence_len: Predictable memory usage, prevents OOM errors

Multi-Dataset Training

Evaluation Configuration

Model Evaluation Integration

After training, evaluate your models using the integrated evaluation pipeline:

1. Deploy Inference Server

First, deploy your base model with LoRA support: Create inference/deployment.yaml:
Create inference/Dockerfile:
Deploy the inference server:

2. Create Evaluation Script

Create evals/evaluation_script.py to benchmark your models:

3. Run Evaluation

The evaluation will:
  • Load your trained LoRA adapter
  • Test on function calling tasks
  • Calculate accuracy metrics
  • Compare base vs fine-tuned performance
  • Save results to benchmark_results.json

4. Monitor Results

Check Weights & Biases for:
  • Training curves: Loss progression during finetuning
  • Evaluation metrics: Function calling accuracy
  • Validation performance: Generalization capability
This complete pipeline lets you:
  1. Finetune models with job queues
  2. Deploy inference servers with LoRA support
  3. Load trained adapters dynamically
  4. Evaluate performance on function calling tasks
  5. Compare different model configurations

LoRA Adapter Loading for Inference

Your trained models are automatically uploaded to HuggingFace Hub and can be loaded into running inference servers without restart:

Loading Process

  1. Training completes → Model uploaded to HuggingFace Hub
  2. Inference server running → vLLM with --enable-lora flag
  3. Load adapter → Call /v1/load_lora_adapter endpoint
  4. Ready for inference → Use adapter name in chat completions

API Usage

This enables:
  • Hot-swapping models without server restart
  • A/B testing different fine-tuned versions
  • Multi-tenant serving with customer-specific models
  • Rapid experimentation with new training runs

Troubleshooting

Out of Memory Issues

If you get OOM errors, try:

Slow Training

Speed up training with:

Upload Failures

Check your HuggingFace token:

W&B Connection Issues

Verify your W&B setup:

Debug Mode

For troubleshooting, use these Axolotl debugging settings:
Additional debugging options:
  • Set TRANSFORMERS_VERBOSITY=debug in environment
  • Use --debug flag with accelerate launch
  • Check logs with: tensorkube job logs --job-name your-job-name
  • For config-only testing: add "wandb_mode": "disabled" to skip W&B entirely