sgl-project/sglang · warning

MultiPlatformOp is deprecated; subclass sglang.kernels.fused

Error message

MultiPlatformOp is deprecated; subclass sglang.kernels.fused_op.BaseFusedOp instead (RFC #29630).

What it means

DeprecationWarning raised whenever a class subclasses MultiPlatformOp: the multi-platform operator base is being replaced by sglang.kernels.fused_op.BaseFusedOp (RFC #29630). Old per-platform methods (forward_hip→forward_cuda, forward_cpu→forward_native, etc.) remain callable for plugin compatibility.

Source

Thrown at python/sglang/srt/layers/utils/multi_platform.py:32

import warnings

from sglang.kernels.fused_op import BaseFusedOp


class MultiPlatformOp(BaseFusedOp):
    """Deprecated alias of :class:`sglang.kernels.fused_op.BaseFusedOp`.

    Kept attribute-compatible with the original class: ``forward_native`` is
    concrete here (raising ``NotImplementedError``) so existing plugin
    subclasses that only define platform forwards keep instantiating, and the
    old per-platform default methods (``forward_hip`` -> ``forward_cuda``,
    ``forward_cpu`` -> ``forward_native``, ...) remain callable for plugin
    code that invokes them directly.
    """

    def __init_subclass__(cls, **kwargs):
        warnings.warn(
            "MultiPlatformOp is deprecated; subclass "
            "sglang.kernels.fused_op.BaseFusedOp instead (RFC #29630).",
            DeprecationWarning,
            stacklevel=2,
        )
        super().__init_subclass__(**kwargs)

    def forward_native(self, *args, **kwargs):
        raise NotImplementedError

    def forward_cuda(self, *args, **kwargs):
        raise NotImplementedError

    def forward_hip(self, *args, **kwargs):
        return self.forward_cuda(*args, **kwargs)

    def forward_musa(self, *args, **kwargs):
        return self.forward_cuda(*args, **kwargs)

View on GitHub (pinned to 0132848349)

Solutions

  1. Rebase the subclass on sglang.kernels.fused_op.BaseFusedOp and rename platform forward methods to the new scheme
  2. If you invoke forward_hip/forward_cpu directly on other classes, keep callers but plan migration
  3. Check RFC #29630 for the full migration mapping

Example fix

# before
class MyFusedOp(MultiPlatformOp):
    def forward_hip(self, *args): ...
# after
from sglang.kernels.fused_op import BaseFusedOp
class MyFusedOp(BaseFusedOp):
    def forward_cuda(self, *args): ...
Defensive patterns

Strategy: validation

Validate before calling

from sglang.kernels.fused_op import BaseFusedOp  # fails fast if new API absent before subclassing

Prevention

When it happens

Trigger: Defining any `class MyOp(MultiPlatformOp)` — __init_subclass__ fires at class-definition (import) time and warns for every subclass.

Common situations: Plugin or downstream operator code subclassing MultiPlatformOp; SGLang's own internal ops until migration completes; upgrading SGLang where the base class was deprecated.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/b8c463dd6bd157a0. Report an issue: GitHub.