# Base models

A tenant can’t download models from the internet. You add base models to the tenant’s bucket and register them, and they show up in the tenant’s model list for your service to offer.

## Add a model

### What you do

1. Get the model files on a machine that can reach the tenant’s object store. A model directory holds `config.json`, the tokenizer files and the weights (`.safetensors`), as published on Hugging Face.
2. Copy the directory into the tenant bucket under `models/`:
   ```bash
   aws --endpoint-url https://s3.internal s3 sync ./Qwen3.5-9B \
     s3://arena-tenant-a/models/qwen3.5-9b/
   ```
3. Register it:
   ```bash
   kubectl -n arena-tenant-a exec deploy/arena-api -- \
     /usr/app/arena-cli task register_model name:qwen3.5-9b \
     path:s3://arena-tenant-a/models/qwen3.5-9b/
   ```

The name may use letters, digits, `.`, `-` and `_`. The path must be in the tenant’s own bucket.

### What happens

Arena reads `config.json` and checks that the weights and tokenizer are there: `config.json`, at least one `.safetensors` file, every shard named in `model.safetensors.index.json`, and one of `tokenizer.json`, `tokenizer.model` or `vocab.json`. It matches the architecture to a [supported model](#supported-models), which it then uses to size runs, and reports whether the model fits the tenant’s GPUs for training and for inference:

```text
model          qwen3.5-9b (Qwen3_5ForConditionalGeneration, 9.4B parameters, 262144 context)
base           Qwen/Qwen3.5-9B
files          ok   4 safetensors shards, tokenizer
training fit   ok   b300-8x1 (LoRA)
inference fit  ok   b300-8x1
registered     yes
```

Training fit sizes a LoRA SFT run at batch size 8, first at the model’s full context. If a class doesn’t fit there, Arena tries the shorter context lengths a run can set (powers of 2, down to 4096 tokens) and names the longest one that fits, for example `l4-1x1 (LoRA at 32768 context)`. Set `network.max_context_length` in your run spec to train at that length.

Running the command again with the same files prints `registered yes (unchanged)`; with changed files, `yes (updated)`.

When the files match more than one supported model of different sizes, the command stops and lists them. Pick one with `base:`:

```bash
kubectl -n arena-tenant-a exec deploy/arena-api -- \
  /usr/app/arena-cli task register_model name:support-tuned \
  path:s3://arena-tenant-a/models/support-tuned/ base:Qwen/Qwen3.5-9B
```

The model is available to every user of the tenant straight away. Your service trains and deploys it by its registered name, here `qwen3.5-9b`.

## Prefetch onto the GPU nodes

Workers on the GPU cluster can copy a base model’s weights before a job starts. They read a Hugging Face id `org/name` from `<bucket>/<prefix>/org/name/`, where the bucket and prefix are the chart values `storage.modelStore.bucket` and `storage.modelStore.prefix` ([Values](reference.md#values)). The bucket defaults to the tenant bucket and the prefix has no default. The workers read it with the GPU cluster’s store Secret, so that key needs read access to the bucket, which matters when you point it at a shared bucket.

## Share models across tenants

Each tenant has its own bucket, so each tenant needs its own copy. To add the same model to many tenants, run the copy and register commands per tenant. A script over your tenant list works well, because both commands are safe to repeat.

## Remove a model

```bash
kubectl -n arena-tenant-a exec deploy/arena-api -- /usr/app/arena-cli task unregister_model name:qwen3.5-9b
```

The model disappears from the model list. The files stay in the bucket; delete them afterwards if you want the space back.

## Supported models

A model can be registered when its `config.json` matches a model in the release’s catalogue: the same model type, hidden size, number of layers, vocabulary size and context length. That covers the published checkpoints and fine-tunes of them that keep the architecture. The catalogue ships in each release’s API image. To print the one a tenant runs:

```bash
kubectl -n arena-tenant-a exec deploy/arena-api -- python3 -m agilerl.cli models supported
```

On release 4.8 and earlier the module is `agilerl.arena.cli`: `python3 -m agilerl.arena.cli models supported`.

Datasets don’t need registering: your service uploads them through the API.
