---
id: carbon-x/Carbon-X
title: Carbon-X post-training
type: recipe
project: carbon-x
model_id: HuggingFaceBio/Carbon-X
trainers:
- SFTTrainer
- AsyncGRPOTrainer
platforms:
- local
- hf_jobs
gpus:
- H100
- H200
verified:
  local: false
  hf_jobs: false
trl_source:
- Released TRL
tags:
- full-finetune
- dna
- genomics
- rlvr
- deepspeed
- fsdp2
date_added: '2026-11-20'
url: https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/index.html
markdown_url: https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/index.md
json_url: https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/recipe.json
yaml_url: https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/recipe.yaml
hub_tree: https://huggingface.co/spaces/trl-lib/trl-recipes/tree/main/recipes/carbon-x/Carbon-X
released_collection: https://huggingface.co/collections/HuggingFaceBio/carbon-x-6ad91dc8e24ad724eb111842
blog: https://huggingface.co/spaces/HuggingFaceBio/Carbon-X-Release
---

# HuggingFaceBio/Carbon-X — Carbon-X

Post-training of Carbon-X, a 14B DNA and language model: SFT of the midtrained Carbon-X-Base on FineDNA, then async GRPO with verifiable DNA rewards, thinking off.

## Summary & Links

- **Recipe ID:** `carbon-x/Carbon-X`
- **Model:** [HuggingFaceBio/Carbon-X](https://huggingface.co/HuggingFaceBio/Carbon-X)
- **Project:** [Carbon-X](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/index.md)
- **Trainers:** `SFTTrainer`, `AsyncGRPOTrainer`
- **GPUs:** H100, H200
- **Platforms:** Local machine, HF Jobs
- **Released models collection:** https://huggingface.co/collections/HuggingFaceBio/carbon-x-6ad91dc8e24ad724eb111842
- **Blog post:** https://huggingface.co/spaces/HuggingFaceBio/Carbon-X-Release
- **Interactive command builder:** https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/index.html
- **Structured JSON:** https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/recipe.json
- **Recipe YAML:** https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/recipe.yaml
- **Space files:** https://huggingface.co/spaces/trl-lib/trl-recipes/tree/main/recipes/carbon-x/Carbon-X

## Quickstart Commands

### Train on HF Jobs (not run as written yet · h200x8 per stage)

```bash
hf download trl-lib/trl-recipes --repo-type space --include "recipes/carbon-x/*" --local-dir trl-recipes
cd trl-recipes/recipes/carbon-x/Carbon-X
STAGE=sft bash train_hf_jobs.sh
```

### Train on Local machine (not run as written yet · 8 GPUs, H100 or H200 class (FlashAttention 3), per stage)

```bash
hf download trl-lib/trl-recipes --repo-type space --include "recipes/carbon-x/*" --local-dir trl-recipes
cd trl-recipes/recipes/carbon-x/Carbon-X
STAGE=sft bash train_local.sh
```

### Evaluate on HF Jobs (not run as written yet · h200x8 per stage)

```bash
hf download trl-lib/trl-recipes --repo-type space --include "recipes/carbon-x/*" --local-dir trl-recipes
cd trl-recipes/recipes/carbon-x/Carbon-X
bash eval_hf_jobs.sh
```

### Evaluate on Local machine (not run as written yet · 8 GPUs, H100 or H200 class (FlashAttention 3), per stage)

```bash
hf download trl-lib/trl-recipes --repo-type space --include "recipes/carbon-x/*" --local-dir trl-recipes
cd trl-recipes/recipes/carbon-x/Carbon-X
bash eval_local.sh
```

## Guide

Two stages, each on one machine with 8 GPUs (`h200x8` on HF Jobs), from the released checkpoints:

1. **SFT** of [`HuggingFaceBio/Carbon-X-Base`](https://huggingface.co/HuggingFaceBio/Carbon-X-Base) on the `sft_mix`
   config of [`HuggingFaceBio/FineDNA`](https://huggingface.co/datasets/HuggingFaceBio/FineDNA): 20 subsets, 3 epochs,
   loss on assistant tokens only, DeepSpeed ZeRO-3. The mixture covers variant-effect reasoning (about 30%), sequence
   classification, DNA operations and skills, sequence recovery, biology Q&A, and chat and instruction-following data
   that keep the model a good assistant.
2. **RL** of `Carbon-X-SFT` with `AsyncGRPOTrainer` on the `rl_mix` config: 16 completions per prompt, thinking off,
   rewards from code-checked verifiers. vLLM generates on 4 GPUs while FSDP2 trains on the other 4.

| | SFT | RL |
|---|---|---|
| Learning rate | 1e-5, cosine to 1e-6 | 1e-6 |
| Batch | 32 sequences (2 per GPU × 2 accumulation × 8 GPUs) | 16 completions per prompt, 134 accumulation steps on 4 GPUs |
| Length | 9,984 tokens | 4,096 completion tokens, 16,384 tokens per micro-batch |
| Other | Liger kernels, FlashAttention 3, max grad norm 0.2 | clip ε 0.2 / 0.28 (DAPO clip-higher), rollouts at most 4 updates stale, max grad norm 0.2 |

The released model comes from two RL rounds: one epoch over 98,433 prompts chosen from the SFT model's own pass rates,
then a second round from that checkpoint on 58,249 prompts re-selected from its rollouts (about 2.2 passes in all).
`rl.yaml` runs one round. Its rewards cover variant-effect prediction (with a penalty for rationales the sequence does
not support), sequence-feature classification, basic DNA operations, DNA skills, positions within sequences, biology
multiple-choice questions and instruction following. They are in
[`src/carbon_x/rewards.py`](https://github.com/huggingface/carbon/blob/4ca3ce3e5c55e5821d6068bac5c6e3806027a26f/carbon-x/src/carbon_x/rewards.py).

## Train

`job.sh` runs one stage on an 8-GPU machine. It clones
[huggingface/carbon](https://github.com/huggingface/carbon) at commit `4ca3ce3e`, installs its `uv.lock` (TRL 1.16.0,
vLLM 0.25.1, Transformers 5.12.1, DeepSpeed 0.18.9) and runs `training/posttraining/sft.py` or `rl.py` with their
configs. `train_hf_jobs.sh` sends it to an `h200x8` job; `train_local.sh` runs it on your machine.

```sh
STAGE=sft bash train_hf_jobs.sh
STAGE=rl MODEL=<you>/Carbon-X-SFT bash train_hf_jobs.sh
```

- `MODEL` is the checkpoint to start from. Without it, SFT starts from `Carbon-X-Base` and RL from the released
  `Carbon-X-SFT`.
- Checkpoints are pushed to your namespace as they are saved: `<you>/Carbon-X-SFT` at every epoch, and
  `<you>/Carbon-X-RL` (private) every 30 steps. The job needs nothing else: no bucket, no upload.
- `MAX_STEPS=2` makes a smoke run. `TIMEOUT` sets the job's limit (default `3d`).

These scripts have not been run as written. The released model was trained on SLURM, and its RL stage served vLLM on a
separate 8-GPU node; on one node, vLLM gets 4 GPUs and training's gradient accumulation doubles to keep the batch.

## Evaluate

The five benchmarks of the model card, from
[`HuggingFaceBio/DNAIntelligenceIndex`](https://huggingface.co/datasets/HuggingFaceBio/DNAIntelligenceIndex), run as
[Inspect](https://inspect.aisi.org.uk/) tasks with thinking off, the model's `generation_config.json` sampling and one
sample per problem.

| Benchmark | Task | Metric | Carbon-X |
|---|---|---|--:|
| BioReason Coding | `bioreason_coding_sequence_only` | balanced accuracy | 74.9 |
| BioReason Non-SNV | `bioreason_non_snv` | balanced accuracy | 85.1 |
| GenomeQA | `genomeqa_mcq_carbon` | mean of 6 task accuracies | 63.6 |
| NextBase | `seqrecqa_varlen` | per-base accuracy | 39.4 |
| FrontierVEP | `vepqa_single_1k` | accuracy | 70.4 |

`eval_hf_jobs.sh` submits one `rtx-pro-6000` job per benchmark with the repository's `evaluation/evaluate.py`, and
writes Inspect logs and a `summary.json` per benchmark to your private bucket `<you>/Carbon-X-Evals`. `eval_local.sh`
serves the model with vLLM on your GPUs and runs the same tasks with Inspect.

```sh
MODEL=<you>/Carbon-X-RL bash eval_hf_jobs.sh
BENCHMARKS="vepqa_single_1k genomeqa_mcq_carbon" LIMIT=8 bash eval_hf_jobs.sh   # quick check
```

## Hyperparameters

| Parameter | Value |
|---|---|
| `sft_start` | `HuggingFaceBio/Carbon-X-Base` |
| `sft_learning_rate` | `1e-5` |
| `sft_lr_schedule` | `cosine to 1e-6` |
| `sft_global_batch_size` | `32` |
| `sft_max_length` | `9,984` |
| `sft_epochs` | `3` |
| `sft_loss` | `assistant tokens only` |
| `rl_start` | `HuggingFaceBio/Carbon-X-SFT` |
| `rl_learning_rate` | `1e-6` |
| `rl_num_generations` | `16` |
| `rl_max_completion_length` | `4,096` |
| `rl_epsilon` | `0.2` |
| `rl_epsilon_high` | `0.28` |
| `rl_max_staleness` | `4` |
| `rl_temperature` | `1` |
| `max_grad_norm` | `0.2` |
| `thinking` | `false` |

### Serving (vLLM)

| Setting | Value |
|---|---|
| `version` | `0.25.1` |
| `rl_server` | `4 GPUs, data parallel, max_model_len 16384, NCCL weight transfer` |

### Hardware

- **HF Jobs:** h200x8 per stage (untested)
- **Local machine:** 8 GPUs, H100 or H200 class (FlashAttention 3), per stage (untested)

## Datasets

### Training

- [`HuggingFaceBio/FineDNA (sft_mix)`](https://huggingface.co/datasets/HuggingFaceBio/FineDNA)
- [`HuggingFaceBio/FineDNA (rl_mix)`](https://huggingface.co/datasets/HuggingFaceBio/FineDNA)

### Evaluation

| Benchmark | Details |
|---|---|
| `bioreason_coding` | HuggingFaceBio/DNAIntelligenceIndex, BioReason Coding (1,018 variants, balanced accuracy) |
| `bioreason_non_snv` | HuggingFaceBio/DNAIntelligenceIndex, BioReason Non-SNV (873 variants, balanced accuracy) |
| `genomeqa` | HuggingFaceBio/DNAIntelligenceIndex, GenomeQA (2,600 questions, mean of 6 task accuracies) |
| `nextbase` | HuggingFaceBio/DNAIntelligenceIndex, NextBase (600 sequences, per-base accuracy) |
| `frontier_vep` | HuggingFaceBio/DNAIntelligenceIndex, FrontierVEP (1,000 variants, accuracy) |

## TRL Version

Runs on released TRL `1.16.0` from PyPI.

```bash
pip install "trl[peft]==1.16.0"
```

## Files

- [`train_local.sh`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/train_local.sh) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/train_local.sh))
- [`train_hf_jobs.sh`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/train_hf_jobs.sh) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/train_hf_jobs.sh))
- [`eval_local.sh`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/eval_local.sh) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/eval_local.sh))
- [`eval_hf_jobs.sh`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/eval_hf_jobs.sh) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/eval_hf_jobs.sh))
- [`recipe.yaml`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/recipe.yaml) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/recipe.yaml))
- [`job.sh`](https://trl-lib-trl-recipes.static.hf.space/recipes/carbon-x/Carbon-X/job.sh) ([Hub raw](https://huggingface.co/spaces/trl-lib/trl-recipes/raw/main/recipes/carbon-x/Carbon-X/job.sh))
