TRL /Recipes

HuggingFaceBio/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.

SFTTrainerAsyncGRPOTrainerH100 · H200full-finetunednagenomicsrlvrdeepspeedfsdp2

Command builder

Train · Local machine · 8 GPUs, H100 or H200 class (FlashAttention 3), per stage

Not run as written yet
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

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 on the sft_mix config of 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.

Train #

job.sh runs one stage on an 8-GPU machine. It clones 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.

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, run as Inspect 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.

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

sft_startHuggingFaceBio/Carbon-X-Base
sft_learning_rate1e-5
sft_lr_schedulecosine to 1e-6
sft_global_batch_size32
sft_max_length9,984
sft_epochs3
sft_lossassistant tokens only
rl_startHuggingFaceBio/Carbon-X-SFT
rl_learning_rate1e-6
rl_num_generations16
rl_max_completion_length4,096
rl_epsilon0.2
rl_epsilon_high0.28
rl_max_staleness4
rl_temperature1
max_grad_norm0.2
thinkingfalse

Serving (vLLM)

version0.25.1
rl_server4 GPUs, data parallel, max_model_len 16384, NCCL weight transfer

Hardware

HF Jobsh200x8 per stage untested
Local machine8 GPUs, H100 or H200 class (FlashAttention 3), per stage untested

Datasets

Training

Evaluation

bioreason_codingHuggingFaceBio/DNAIntelligenceIndex, BioReason Coding (1,018 variants, balanced accuracy)
bioreason_non_snvHuggingFaceBio/DNAIntelligenceIndex, BioReason Non-SNV (873 variants, balanced accuracy)
genomeqaHuggingFaceBio/DNAIntelligenceIndex, GenomeQA (2,600 questions, mean of 6 task accuracies)
nextbaseHuggingFaceBio/DNAIntelligenceIndex, NextBase (600 sequences, per-base accuracy)
frontier_vepHuggingFaceBio/DNAIntelligenceIndex, FrontierVEP (1,000 variants, accuracy)

TRL version

This recipe runs on a TRL release from PyPI, with no fork and no patch.

pip install "trl[peft]==1.16.0"

Files

Added 2026-11-20 Report an issue