evo2-flash 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
evo2_flash/__init__.py ADDED
@@ -0,0 +1,75 @@
1
+ """Out-of-tree vLLM plugin for Evo 2 / StripedHyena2.
2
+
3
+ Drop-in replacement for `evo2.Evo2` (see evo2_flash/api.py and README.md):
4
+
5
+ from evo2_flash import Evo2
6
+ model = Evo2("evo2_7b")
7
+
8
+ Lower level:
9
+
10
+ import evo2_flash; evo2_flash.register()
11
+ from vllm import LLM
12
+ llm = LLM(model="ckpt/evo2_7b_hf", skip_tokenizer_init=True, ...)
13
+
14
+ If installed as a package, the same thing happens automatically via the
15
+ `vllm.general_plugins` entry point declared in pyproject.toml.
16
+
17
+ Ported from github.com/AlexYkHao/evo2-vllm at 5d6396e. Comments that cite
18
+ `tests/`, `scripts/`, `evo2_layers/`, `PLAN.md`, `MTP_DRAFTER.md`, `FP8_SURGERY.md`
19
+ or `docs/` refer to that repository.
20
+ """
21
+
22
+ from .config import StripedHyena2Config
23
+
24
+ __all__ = ["StripedHyena2Config", "register", "Evo2", "CharLevelTokenizer",
25
+ "GenerationOutput", "MODEL_NAMES"]
26
+
27
+ _API = {"Evo2", "CharLevelTokenizer", "GenerationOutput", "MODEL_NAMES",
28
+ "reverse_complement", "layer_name_table"}
29
+
30
+
31
+ def __getattr__(name):
32
+ # Lazy, so `import evo2_flash` (e.g. by the converter, in an env without
33
+ # vLLM) does not import vLLM.
34
+ if name in _API:
35
+ from . import api
36
+
37
+ return getattr(api, name)
38
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
39
+
40
+ _REGISTERED = False
41
+
42
+
43
+ def register() -> None:
44
+ """Register the config with transformers and the model with vLLM."""
45
+ global _REGISTERED
46
+ if _REGISTERED:
47
+ return
48
+
49
+ from transformers import AutoConfig
50
+
51
+ from .config import Evo2MTPConfig
52
+
53
+ for name, cls in (("striped_hyena2", StripedHyena2Config), ("evo2_mtp", Evo2MTPConfig)):
54
+ try:
55
+ AutoConfig.register(name, cls)
56
+ except ValueError:
57
+ pass # already registered
58
+
59
+ from vllm import ModelRegistry
60
+
61
+ ModelRegistry.register_model(
62
+ "StripedHyena2ForCausalLM",
63
+ "evo2_flash.model:StripedHyena2ForCausalLM",
64
+ )
65
+ # MTP draft head, run by vLLM's EAGLE proposer (speculative method "eagle").
66
+ ModelRegistry.register_model(
67
+ "EagleEvo2MTPModel",
68
+ "evo2_flash.mtp_draft:EagleEvo2MTPModel",
69
+ )
70
+ # ... and its EAGLE-3 form (multi-layer target features; method "eagle3").
71
+ ModelRegistry.register_model(
72
+ "Eagle3Evo2MTPModel",
73
+ "evo2_flash.mtp_draft:Eagle3Evo2MTPModel",
74
+ )
75
+ _REGISTERED = True