AFFINE
Affine
Live
Back to Blog
Dec 8, 2024·15 min read

Getting Started as an Affine Miner

A comprehensive guide to setting up your environment, pulling models, training improvements with RL, and deploying to Chutes for rewards.

Prerequisites

Before you begin, ensure you have:

  • A Linux-based system (Ubuntu 20.04+ recommended)
  • NVIDIA GPU with CUDA support (for training)
  • At least 32GB RAM
  • Python 3.10 or higher
  • Basic familiarity with machine learning concepts

Step 1: Install the UV Package Manager

Affine uses UV for fast, reliable Python package management:

curl -LsSf https://astral.sh/uv/install.sh | sh

Restart your terminal or run source ~/.bashrc to update your PATH.

Step 2: Clone and Install Affine

git clone https://github.com/AffineFoundation/affine.git
cd affine
uv venv && source .venv/bin/activate
uv pip install -e .

Verify your installation:

af --help

You should see the Affine CLI help message.

Step 3: Configure Your Environment

Create a .env file based on the example:

cp .env.example .env

Edit the file to add your API keys and configuration:

BITTENSOR_WALLET_NAME=your_wallet_name
BITTENSOR_WALLET_HOTKEY=your_hotkey
CHUTES_API_KEY=your_chutes_api_key

Step 4: Pull Current Models

To understand the current state of the network, pull the top-performing models:

af pull --top 5

This downloads the top 5 models from the Pareto frontier for local evaluation and study.

Step 5: Evaluate Locally

Before making improvements, understand how models perform:

af evaluate --model ./models/top_1 --env DED-V2 ABD-V2

This runs the model through the evaluation environments and reports scores.

Step 6: Train Improvements

This is where the magic happens. Use reinforcement learning to improve the model:

af train \
  --base-model ./models/top_1 \
  --env DED-V2 ABD-V2 \
  --steps 10000 \
  --output ./models/improved

Training Tips

  1. Start small — Begin with fewer steps to validate your approach
  2. Monitor both environments — Ensure you're not regressing on one while improving another
  3. Use checkpoints — Save intermediate models to avoid losing progress
  4. Experiment with hyperparameters — Learning rate and batch size significantly impact results

Step 7: Validate Your Improvements

Before deploying, confirm your model achieves Pareto dominance:

af compare --model ./models/improved --baseline ./models/top_1

The output will show whether your model dominates, is dominated by, or is incomparable with the baseline.

Step 8: Deploy to Chutes

Once you have a model that achieves Pareto dominance:

af deploy --model ./models/improved --name "my_improved_model_v1"

This uploads your model to Chutes and registers it with the network.

Step 9: Commit On-Chain

Finally, commit your model to the Bittensor blockchain:

af commit --model-id <model_id_from_deploy>

Monitoring Your Performance

Track your miner's performance:

af status --uid <your_uid>

Or visit the live dashboard to see real-time metrics.

Common Issues

"CUDA out of memory"

Reduce batch size or use gradient checkpointing.

"Model not achieving dominance"

Ensure you're training on all environments, not just one.

"Deployment failed"

Check your Chutes API key and network connectivity.

Next Steps

Happy mining! 🚀