Instructions to use HuggingFaceBio/Carbon-A-1.2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HuggingFaceBio/Carbon-A-1.2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="HuggingFaceBio/Carbon-A-1.2B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForTokenClassification model = AutoModelForTokenClassification.from_pretrained("HuggingFaceBio/Carbon-A-1.2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Fix flash-attn install
Browse filesFixes the FlashAttention install. As documented, `pip install --no-build-isolation flash-attn` fails:
1. `psutil` is missing (`ModuleNotFoundError` within seconds).
2. With `psutil`, it compiles from source, because `torch>=2.7,<3` resolves to the latest PyTorch (2.14 + cu130), for which FlashAttention has no wheel. The compile then fails: PyTorch 2.14 headers need C++20 (`std::strong_ordering`), and flash-attn builds with C++17.
Changes:
- `requirements.txt`: `torch>=2.7,<2.9` and `psutil`. flash-attn 2.8.3 has prebuilt wheels for PyTorch 2.7 and 2.8 on Python 3.9–3.13; for 2.9, only on Python 3.12.
- Install command: `pip install --no-build-isolation --no-cache-dir "flash-attn==2.8.3"`. Pinning keeps pip from picking 2.8.3.post1, which has almost no wheels. `--no-cache-dir` avoids a flash-attn installer error (`Invalid cross-device link`) when `/tmp` and `~/.cache` are on different filesystems.
- Both READMEs explain the cap, note that the default CUDA 12.8 build of PyTorch runs with CUDA 13 drivers, and give `--attn-implementation sdpa` for newer PyTorch, with its measured effect.
Tested on an RTX 3090 Ti (driver CUDA 13.4), following the README in a fresh environment:
- Python 3.11 → torch 2.8.0+cu128, transformers 4.57.6; flash-attn 2.8.3 installed from a prebuilt wheel in 18 s.
- Yeast benchmark: nucleotide/exon/gene F1 0.9984 / 0.9429 / 0.9531, matching the card. Raw per-base probabilities are **bit-identical** to a torch 2.7 + flash-attn 2.8.3 run, and also to torch 2.9.1 cu128/cu130 runs.
- For comparison: PyTorch 2.14 + SDPA gave 0.9984 / 0.9428 / 0.9525, and the `kernels-community/flash-attn2` Hub kernel (torch 2.12, Transformers 5) gave 0.9984 / 0.9425 / 0.9527. Neither reproduces the reported probabilities.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
- README.md +3 -1
- annotation_pipeline/README.md +3 -1
- requirements.txt +6 -2
|
@@ -46,9 +46,11 @@ Then download this repository and install its requirements:
|
|
| 46 |
pip install -U huggingface_hub
|
| 47 |
hf download HuggingFaceBio/Carbon-A-1.2B --exclude model.safetensors --local-dir Carbon-A-1.2B
|
| 48 |
pip install -r Carbon-A-1.2B/requirements.txt
|
| 49 |
-
pip install --no-build-isolation flash-attn
|
| 50 |
```
|
| 51 |
|
|
|
|
|
|
|
| 52 |
The weights (4.6 GB) are downloaded to the Hugging Face cache on first use.
|
| 53 |
|
| 54 |
### Annotate a genome
|
|
|
|
| 46 |
pip install -U huggingface_hub
|
| 47 |
hf download HuggingFaceBio/Carbon-A-1.2B --exclude model.safetensors --local-dir Carbon-A-1.2B
|
| 48 |
pip install -r Carbon-A-1.2B/requirements.txt
|
| 49 |
+
pip install --no-build-isolation --no-cache-dir "flash-attn==2.8.3"
|
| 50 |
```
|
| 51 |
|
| 52 |
+
The requirements keep PyTorch below 2.9 because FlashAttention 2.8.3 has prebuilt wheels for these versions on Python 3.9–3.13; without a wheel, it compiles from source, which fails with recent PyTorch. PyTorch's default CUDA 12.8 build also runs with CUDA 13 drivers. To use a newer PyTorch, run without FlashAttention with `--attn-implementation sdpa`. Its probabilities differ slightly: on the yeast benchmark below, PyTorch 2.14 with SDPA gave a gene F1 of 0.9525 instead of 0.953.
|
| 53 |
+
|
| 54 |
The weights (4.6 GB) are downloaded to the Hugging Face cache on first use.
|
| 55 |
|
| 56 |
### Annotate a genome
|
|
@@ -57,9 +57,11 @@ FlashAttention:
|
|
| 57 |
pip install -U "huggingface_hub>=0.34"
|
| 58 |
hf download HuggingFaceBio/Carbon-A-1.2B --exclude model.safetensors --local-dir Carbon-A-1.2B
|
| 59 |
pip install -r Carbon-A-1.2B/requirements.txt
|
| 60 |
-
pip install --no-build-isolation flash-attn
|
| 61 |
```
|
| 62 |
|
|
|
|
|
|
|
| 63 |
Model inference loads Carbon-A with `from_pretrained`, which downloads the
|
| 64 |
weights (4.6 GB) to the Hugging Face cache on first use. It runs in bfloat16
|
| 65 |
with FlashAttention-2, the setting of all reported results. The requirements
|
|
|
|
| 57 |
pip install -U "huggingface_hub>=0.34"
|
| 58 |
hf download HuggingFaceBio/Carbon-A-1.2B --exclude model.safetensors --local-dir Carbon-A-1.2B
|
| 59 |
pip install -r Carbon-A-1.2B/requirements.txt
|
| 60 |
+
pip install --no-build-isolation --no-cache-dir "flash-attn==2.8.3"
|
| 61 |
```
|
| 62 |
|
| 63 |
+
The requirements keep PyTorch below 2.9 because FlashAttention 2.8.3 has prebuilt wheels for these versions on Python 3.9–3.13; without a wheel, it compiles from source, which fails with recent PyTorch. PyTorch's default CUDA 12.8 build also runs with CUDA 13 drivers. To use a newer PyTorch, run without FlashAttention with `--attn-implementation sdpa`. Its probabilities differ slightly: on the yeast benchmark of the model card, PyTorch 2.14 with SDPA gave a gene F1 of 0.9525 instead of 0.953.
|
| 64 |
+
|
| 65 |
Model inference loads Carbon-A with `from_pretrained`, which downloads the
|
| 66 |
weights (4.6 GB) to the Hugging Face cache on first use. It runs in bfloat16
|
| 67 |
with FlashAttention-2, the setting of all reported results. The requirements
|
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
| 2 |
# Below 5: Transformers 5 does not load this model with flash_attention_2, the
|
| 3 |
# annotation pipeline's default attention implementation.
|
| 4 |
transformers>=4.56,<5
|
|
@@ -14,7 +16,9 @@ tqdm
|
|
| 14 |
numba
|
| 15 |
ninja
|
| 16 |
# Its default attention implementation, flash_attention_2, also needs FlashAttention:
|
| 17 |
-
# pip install --no-build-isolation flash-attn
|
| 18 |
# (--attn-implementation sdpa runs without it.) The native Viterbi backends are
|
| 19 |
# compiled on first use: the CPU backend needs a C++17 compiler with OpenMP and
|
| 20 |
# the GPU backend a CUDA toolkit.
|
|
|
|
|
|
|
|
|
| 1 |
+
# Below 2.9: flash-attn 2.8.3 ships prebuilt wheels for these PyTorch versions
|
| 2 |
+
# on Python 3.9-3.13.
|
| 3 |
+
torch>=2.7,<2.9
|
| 4 |
# Below 5: Transformers 5 does not load this model with flash_attention_2, the
|
| 5 |
# annotation pipeline's default attention implementation.
|
| 6 |
transformers>=4.56,<5
|
|
|
|
| 16 |
numba
|
| 17 |
ninja
|
| 18 |
# Its default attention implementation, flash_attention_2, also needs FlashAttention:
|
| 19 |
+
# pip install --no-build-isolation --no-cache-dir "flash-attn==2.8.3"
|
| 20 |
# (--attn-implementation sdpa runs without it.) The native Viterbi backends are
|
| 21 |
# compiled on first use: the CPU backend needs a C++17 compiler with OpenMP and
|
| 22 |
# the GPU backend a CUDA toolkit.
|
| 23 |
+
# Needed to install flash-attn:
|
| 24 |
+
psutil
|