Views
No views yet
trust_remote_code HF implementation but it has four gaps that force every downstream user to monkey-patch the model:output_hidden_states=True is hardcoded to None (intermediate embeddings require forward hooks).output_attentions=True is unsupported (flash-attn discards the (B, H, T, T) matrix; users must patch the attention module).attn_implementation cannot be switched at load time - flash_attn is mandatory at every attention layer.AutoModel.from_pretrained; only the LM-head wrapper exists.max_abs_diff = 0.000e+00 at every layer; see Parity Verification).| Parameter | Value |
|---|---|
| Total parameters | ~7B |
| Layers | 32 |
| Attention heads | 32 |
| Embedding dimension | 4096 |
| FFN hidden dimension | 10 928 (gated GELU) |
| Vocabulary size | 512 (UTF-8 byte-level) |
| Attention layer indices | [8, 16, 24] |
| Hyena layer indices | all others |
| Hyena state size | 8 |
| Positional encoding | RoPE (base = 10000, linearly scaled by 1/16) |
| Normalization | RMSNorm (eps = 1e-6) |
| Architecture | StripedHyena (29 Hyena blocks + 3 causal MHA blocks) |
| Max sequence length | 131 072 (training context) |
| Training dtype | bfloat16 (Hyena modal-form poles / residues kept in fp32) |
togethercomputer/evo-1-131k-base@1.1_fix.max_abs_diff = 0.000e+00) to the togethercomputer reference at all 34 representation levels (token embedding + each of the 32 hybrid blocks + final RMSNorm), using attn_implementation="flash_attention_2" in bf16 (matches the reference's backend choice and the trained dtype). Logits from Evo1ForCausalLM were also verified bit-exact (top-1 agreement: 128/128 positions). Verified on H100 with PyTorch 2.7.1 / CUDA 12.9.flash_attention_2 is bit-exact with the original togethercomputer / evo-design implementations (same CUDA kernel). The sdpa and eager backends use different kernels (PyTorch's bundled flash kernel and pure-PyTorch matmul, respectively); these compute mathematically equivalent attention but accumulate floating-point operations in slightly different orders, producing per-block diffs at the bf16 noise floor (relative error roughly 1e-4 to 1e-2).flash_attention_2 if you need to match the reference's activations bit-for-bit.| Model | Context | Notes |
|---|---|---|
| Taykhoom/Evo1-1-7B-8K | 8 192 | Original Evo 1 base model (8k context). |
| Taykhoom/Evo1-1-7B-131K | 131 072 | Long-context Evo 1 with linearly-scaled RoPE (131k context). |
| Taykhoom/Evo1-1.5-7B-8K | 8 192 | Evo 1.5: Evo 1 (8k) further trained on ~50% more pretraining tokens. |
Note on dtype. Evo1 was trained in bfloat16, with the Hyenapoles/residues(modal-form filter parameters) and rotaryinv_freqkept in fp32 for numerical stability.from_pretraineddefaults to bf16 and the bundled remote model code automatically restores these fp32 invariants after checkpoint loading and after later.to(...),.half(), or.bfloat16()calls; no manual repair call is needed.
Note on attention backend. By default,from_pretrainedselectsattn_implementation="sdpa"(PyTorch's bundled scaled-dot-product-attention) - this works out of the box withoutflash_attninstalled. The original togethercomputer / evo-design implementations useflash_attnunconditionally; for bit-exact reproduction of reference outputs, explicitly passattn_implementation="flash_attention_2"(andpip install flash-attn). See Numerical equivalence across attention backends for the magnitude of the difference.
1import torch
2from transformers import AutoTokenizer, AutoModel
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/Evo1-1-7B-131K", trust_remote_code=True)
5model = AutoModel.from_pretrained(
6 "Taykhoom/Evo1-1-7B-131K",
7 trust_remote_code=True,
8 attn_implementation="flash_attention_2", # strongly recommended for long context
9).cuda().eval()
10
11seqs = ["ACGTACGTACGT", "GGGTTTAAACCC"]
12inputs = tokenizer(seqs, return_tensors="pt", padding=True).to(model.device)
13
14with torch.no_grad():
15 out = model(**inputs, output_hidden_states=True)
16
17last_hidden = out.last_hidden_state # (B, T, 4096)
18all_layers = out.hidden_states # tuple of (B, T, 4096), len = 34 (embed + 32 blocks + post-norm)
19layer_12_emb = all_layers[12] # often used as a "middle" representation1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/Evo1-1-7B-131K", trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained(
6 "Taykhoom/Evo1-1-7B-131K",
7 trust_remote_code=True,
8 attn_implementation="flash_attention_2",
9).cuda().eval()
10
11inputs = tokenizer(["ACGT"], return_tensors="pt").to(model.device)
12with torch.no_grad():
13 logits = model(**inputs).logits # (1, T, 512)attn_implementation to use PyTorch SDPA, pass "eager" for
materialized attention probabilities, or pass "flash_attention_2" (with
flash-attn installed) for bit-exact parity with the upstream implementation.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/Evo1-1-7B-131K", trust_remote_code=True)
5model = AutoModelForCausalLM.from_pretrained(
6 "Taykhoom/Evo1-1-7B-131K",
7 trust_remote_code=True,
8 attn_implementation="flash_attention_2",
9).cuda().eval()
10
11inputs = tokenizer(["ACGT"], return_tensors="pt").to(model.device)
12out = model.generate(**inputs, max_new_tokens=128, do_sample=True, top_k=4, temperature=1.0)
13print(tokenizer.decode(out[0]))generation_config.json ships with eos_token_id = 0 (the EOD byte) and pad_token_id = 1 so model.generate() stops naturally at the trained end-of-document token without needing extra kwargs. Note that the tokenizer itself does not add an EOS at encoding time - this matches the original Evo1 inference pipeline (only generation stops on EOS; embedding/scoring uses raw byte input).Cache behavior: Unpadded single-sequence generation uses the recurrent cache. Padded requests automatically use full recomputation so batched outputs remain correct. Fresh caches consume the complete prompt, andEvo1Cache.reset()clears both attention and Hyena state.
1import torch
2from transformers import AutoTokenizer, AutoModel
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/Evo1-1-7B-131K", trust_remote_code=True)
5model = AutoModel.from_pretrained(
6 "Taykhoom/Evo1-1-7B-131K",
7 trust_remote_code=True,
8 attn_implementation="eager", # avoids the automatic eager fallback
9).cuda().eval()
10
11inputs = tokenizer(["ACGTACGT"], return_tensors="pt").to(model.device)
12with torch.no_grad():
13 out = model(**inputs, output_attentions=True)
14
15# out.attentions is a tuple of length 32. Entries at indices not in [8, 16, 24]
16# are None (Hyena blocks have no attention matrix). Entries at [8, 16, 24] are
17# (B, num_heads, T, T) tensors.
18attn_block_8 = out.attentions[8]accelerate's device_map is supported (_no_split_modules is set so each AttentionBlock / ParallelGatedConvBlock stays atomic on one device, with hidden state automatically transferred across device boundaries):1import torch
2from transformers import AutoTokenizer, AutoModel
3
4tokenizer = AutoTokenizer.from_pretrained("Taykhoom/Evo1-1-7B-131K", trust_remote_code=True)
5model = AutoModel.from_pretrained(
6 "Taykhoom/Evo1-1-7B-131K",
7 trust_remote_code=True,
8 attn_implementation="flash_attention_2",
9 device_map="auto", # auto-shard across all visible GPUs; falls back to single GPU if only one is present
10).eval()pip install accelerate.last_hidden_state (or any intermediate hidden_states[i]) and feed it into a downstream head.base_model_prefix = "backbone" exposes the raw StripedHyena module through .base_model. Its public forward accepts standard HF arguments (input_ids, attention_mask, past_key_values, use_cache, output_hidden_states, output_attentions, return_dict) and returns BaseModelOutputWithPast; AutoModel delegates to this same path.attention.py). Replaces flash_attn.modules.mha.MHA with a small in-repo MHA class that supports attn_implementation="eager" / "sdpa" / "flash_attention_2". Learned parameter names (Wqkv, out_proj) are preserved so existing checkpoints load unchanged. Attention masks are applied to keys in every backend. When output_attentions=True, the sdpa and flash paths automatically fall back to eager so the attention matrix is materialized.rotary.py). The 131k context window is achieved by linearly scaling RoPE position indices by 1/16 (equivalent to extending the 8k base model's effective context by 16x). Implemented in LinearlyScaledRotaryEmbedding, which subclasses either flash_attn.layers.rotary.RotaryEmbedding (when available) or our pure-PyTorch fallback.rotary.py). inv_freq is treated as non-persistent runtime state and reconstructed from base and dim in fp32 after checkpoint loading and whenever the RoPE cache is rebuilt. When flash_attn is installed we delegate application to its Triton kernel; the pure-PyTorch fallback likewise performs the rotary multiply in fp32 before casting back. This avoids the per-layer error caused by bf16 frequency or multiplication rounding.engine.py). Ported from the togethercomputer reference (FFT-based long convolution, modal-form prefill).cache.py). Evo1Cache(transformers.cache_utils.Cache) wraps the two block-type-specific inference param dataclasses (InferenceParams for attention KV cache, RecurrentInferenceParams for Hyena FIR window + IIR modal state). Exposes get_seq_length() / get_max_cache_shape() for generation and clears all KV, FIR, and recurrent Hyena state on reset.tokenization_evo1.py). Byte-level UTF-8 with vocab_size = 512. Pad token is byte \x01. No CLS, no EOS appended at encoding time (matches original Evo1 inference). Encoding and token-to-ID conversion both preserve byte \x00 as ID 0; decoding is NumPy-2.x compatible.torch, transformers, numpy, safetensors, huggingface_hub (only for from_pretrained downloads). flash_attn is only required if you pass attn_implementation="flash_attention_2".1@article{nguyen2024_evo,
2 title = {Sequence modeling and design from molecular to genome scale with {Evo}},
3 author = {Nguyen, Eric and Poli, Michael and Durrant, Matthew G. and Kang, Brian and Katrekar, Dhruva and Li, David B. and Bartie, Liam J. and Thomas, Armin W. and King, Samuel H. and Brixi, Garyk and Sullivan, Jeremy and Ng, Madelena Y. and Lewis, Ashley and Lou, Aaron and Ermon, Stefano and Baccus, Stephen A. and Hernandez-Boussard, Tina and {R{\'e}}, Christopher and Hsu, Patrick D. and Hie, Brian L.},
4 journal = {Science},
5 volume = {386},
6 number = {6723},
7 pages = {eado9336},
8 year = {2024},
9 doi = {10.1126/science.ado9336}
10}