| """ |
| fast_decode_enable.py — PERMANENT harness-side switch for FastGenerator decode. |
| |
| One line at the top of serve_emoe.py (or any eval script), after other imports: |
| |
| import fast_decode_enable # noqa: F401 |
| |
| Every HyperExpertRunner constructed afterwards decodes through FastGenerator |
| (sliding anchor) automatically. No edits to runtime_adapters.py; base and |
| hyper weights untouched. |
| |
| Kill switch (instant native A/B, no code change): |
| FAST_DECODE=0 python serve_emoe.py ... -> native decode |
| python serve_emoe.py ... -> fast decode (default on) |
| |
| Every generation logs "generate[FAST]" when active. If you don't see that |
| tag, you are measuring native. |
| """ |
| import os |
|
|
| import runtime_adapters as RA |
| from runner_patch import install |
|
|
| _ENABLED = os.environ.get("FAST_DECODE", "1") != "0" |
| _orig_init = RA.HyperExpertRunner.__init__ |
|
|
|
|
| def _patched_init(self, *a, **k): |
| _orig_init(self, *a, **k) |
| if _ENABLED: |
| install(self) |
| print("fast_decode_enable: FastGenerator decode ON " |
| "(FAST_DECODE=0 to disable)") |
| else: |
| print("fast_decode_enable: DISABLED via FAST_DECODE=0 (native decode)") |
|
|
|
|
| RA.HyperExpertRunner.__init__ = _patched_init |
|
|