Skip to content

Commit 26cf646

Browse files
committed
switch INT8 support to official flagos version
1 parent 58c779c commit 26cf646

6 files changed

Lines changed: 408 additions & 134 deletions

File tree

vllm_fl/dispatch/backends/vendor/sunrise/patch.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ def apply_sunrise_patches():
4444
patch_ptpu_trunc_normal_init()
4545
patch_minicpmo_resampler_device()
4646
patch_moe_force_config()
47+
patch_native_moe_ops()
48+
patch_native_int8_routing()
49+
50+
51+
def patch_native_moe_ops() -> None:
52+
"""Give vLLM's fused-MoE path implementations that exist on PTPU.
53+
54+
Deferred rather than import-time: the shims resolve through the FL dispatch
55+
registry, which is only populated once the backends have registered. Must
56+
precede ``patch_native_int8_routing``, which routes W8A8 MoE onto them.
57+
"""
58+
from .patches import patch_moe_native_ops
59+
60+
patch_moe_native_ops.apply_patch()
61+
62+
63+
def patch_native_int8_routing() -> None:
64+
"""Re-assert the INT8 routing that ``register_oot_ops`` can overwrite.
65+
66+
``register_oot_ops`` installs ``install_fl_w8a8_moe_selector`` and clones the
67+
CUDA linear kernels into the OOT slot before it calls us, so sunrise has to
68+
re-run the order-sensitive INT8 patches afterwards to be the last writer.
69+
"""
70+
from .patches import patch_int8_native
71+
72+
patch_int8_native.install_late_patches()
4773

4874

4975
def patch_moe_force_config() -> None:

vllm_fl/dispatch/backends/vendor/sunrise/patches/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
optional decode profiler, torch profiler PrivateUse1 bridge.
1414
* **Deferred** (``patch.apply_sunrise_patches``): CUDA stream shims, FlagCX
1515
comm/collectives, cudagraph, sampler/penalties, distributed runtime, OOT
16-
layer registration, and other worker-init hooks.
16+
layer registration, the ``_moe_C`` dispatch shims, and other worker-init
17+
hooks. INT8 also re-asserts its MoE routing there, because
18+
``register_oot_ops`` installs the generic FL W8A8 selector in between.
1719
"""
1820

1921
from . import patch_fla_ops

0 commit comments

Comments
 (0)