> ## Documentation Index
> Fetch the complete documentation index at: https://proto.evodesign.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CodonFM Fitness

> Optimize the upstream CodonFM/Encodon visible-token fitness proxy in either direction.

![CodonFM Fitness](https://proto-bio.github.io/proto-assets/images/constraint/codonfm-fitness/hero.png)

> [!NOTE]
>
> **License:** CodonFM (Encodon) uses Apache-2.0 for code and Custom (NVIDIA Open Model License) for model weights. Please refer to the [code license](https://github.com/NVIDIA-BioNeMo/CodonFM/blob/main/LICENSE) and [model weights license](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/) for full terms.

This constraint is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.

***

&#x20;Tools Used Tools Used  Source Source  Cite Cite

![](https://proto-bio.github.io/proto-assets/images/tool/codonfm/social.png)

&#x20;Go to Tool Page

[Open](https://proto.evodesign.org/docs/tools/masked-models/codonfm.md)

![Proto](https://mintcdn.com/bio-pro/cMLt8hAqaP9M3LKy/assets/logo/logo-light.svg?fit=max\&auto=format\&n=cMLt8hAqaP9M3LKy\&q=85\&s=f5e5dfd1b8f9b9db3a0be0e2eb01f678)

evo-design/proto-language

&#x20;View source

[Open](https://github.com/evo-design/proto-language/blob/0824a53b9c4ed4c3ed45d82d06d250a40b1c9e7a/proto_language/constraint/sequence_scoring/codonfm_fitness_constraint.py#L106)

@articlecodonfm2025

```bibtex theme={null}
@article{codonfm2025,
  title={Learning the language of codon translation with CodonFM},
  author={Darabi, Sajad and Cao, Fan and Naghipourfar, Mohsen and Rabi, Sara and Sethia, Ankit and Gion, Kyle and Grewal, Jasleen and Cohen, Jonathan and Greenleaf, William and Goodarzi, Hani and Sundaram, Laksshman},
  year={2025},
  publisher={NVIDIA},
  url={https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf}
}
```

&#x20;Copy citation

Constraint contributors[![](https://avatars.githubusercontent.com/u/21143637?v=4\&s=64)bviggiano](https://github.com/bviggiano)
Score proposals by Encodon's upstream non-padding-token mean log-likelihood.

This follows `predict_fitness` exactly: the mean includes visible codons and the CLS/SEP
special tokens, while excluding padding.

## API Reference

ConfigCodonFMFitnessConstraintConfig[ Source](https://github.com/evo-design/proto-language/blob/0824a53b9c4ed4c3ed45d82d06d250a40b1c9e7a/proto_language/constraint/sequence_scoring/codonfm_fitness_constraint.py#L44)

Configuration for the CodonFM coding-sequence fitness constraint.

**model\_checkpoint** `enum` (default: encodon\_80m)

Encodon checkpoint: encodon\_80m | encodon\_600m | encodon\_1b | encodon\_1b\_cdwt.

Options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`

**direction** `enum` (default: max)

Whether to maximize ('max') or minimize ('min') the coding-sequence fitness.

Options: `max`, `min`

**sigmoid\_center** `number` (default: -2.0)

Upstream non-padding-token mean log-likelihood mapped to energy 0.5 (tunable; negative).

**sigmoid\_scale** `number` (default: 1.0)

Positive float32-safe width of the sigmoid transform; larger is gentler.

**device** `string` (default: cuda)

CUDA device used for CodonFM inference; the upstream xFormers path is GPU-only.

**batch\_size** `integer` (default: 1)

Number of sequences scored per CodonFM GPU batch.

ReturnsConstraintOutput

One result per proposal. `score` is in `[0.0, 1.0]` (lower
is better in the requested direction); `metadata` carries the raw `fitness`.

## Usage

```python python icon="python" theme={null}
from proto_language.core import Constraint
from proto_language.constraint import codonfm_fitness_constraint, CodonFMFitnessConstraintConfig

constraint = Constraint(
    inputs=[segment],
    function=codonfm_fitness_constraint,
    function_config=CodonFMFitnessConstraintConfig(
        # Configure parameters here
    ),
)

scores = constraint.evaluate()
```

## Metadata

| Property | Value |
| - | - |
| Key | `codonfm-fitness` |
| Function | `codonfm_fitness_constraint` |
| Category | `sequence_scoring` |
| Mode | `discrete` |
| Uses GPU | `True` |
| Supported Types | `dna`, `rna` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.