Update import path for ops in liger_kernel/transformers/*

Signed-off-by: Tcc0403 <[email protected]>
This commit is contained in:
Tcc0403
2025-12-12 01:06:32 +08:00
parent 649f01ceaa
commit 8efda76b19
24 changed files with 44 additions and 47 deletions
-3
View File
@@ -1,6 +1,5 @@
import importlib
import inspect
import logging
from liger_kernel.ops.backends import VENDOR_REGISTRY
from liger_kernel.ops.cross_entropy import LigerCrossEntropyFunction
@@ -28,7 +27,6 @@ from liger_kernel.ops.tiled_mlp import LigerTiledMLPFunction
from liger_kernel.ops.tvd import LigerTVDLossFunction
from liger_kernel.utils import infer_device
logger = logging.getLogger(__name__)
device = infer_device()
__all__ = [
@@ -59,7 +57,6 @@ __all__ = [
_globals = globals()
if device in VENDOR_REGISTRY:
logger.debug(f"Loading Liger Kernel ops for device: {device}")
backend_module_path = VENDOR_REGISTRY[device].module_path
module = importlib.import_module(backend_module_path)
ops = []
@@ -2,7 +2,7 @@ from typing import Optional
import torch
from liger_kernel.ops.cross_entropy import LigerCrossEntropyFunction
from liger_kernel.ops import LigerCrossEntropyFunction
from liger_kernel.transformers.functional import CrossEntropyOutput
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.dyt import LigerDyTFunction
from liger_kernel.ops import LigerDyTFunction
class LigerDyT(nn.Module):
+20 -20
View File
@@ -3,26 +3,26 @@ from typing import Optional
import torch
from liger_kernel.ops.cross_entropy import LigerCrossEntropyFunction
from liger_kernel.ops.dyt import LigerDyTFunction
from liger_kernel.ops.fused_add_rms_norm import LigerFusedAddRMSNormFunction
from liger_kernel.ops.fused_linear_cross_entropy import LigerFusedLinearCrossEntropyFunction
from liger_kernel.ops.fused_linear_jsd import LigerFusedLinearJSDFunction
from liger_kernel.ops.fused_neighborhood_attention import LigerFusedNeighborhoodAttentionFunction
from liger_kernel.ops.geglu import LigerGELUMulFunction
from liger_kernel.ops.group_norm import LigerGroupNormFunction
from liger_kernel.ops.jsd import LigerJSDFunction
from liger_kernel.ops.kl_div import LigerKLDivLossFunction
from liger_kernel.ops.layer_norm import LigerLayerNormFunction
from liger_kernel.ops.multi_token_attention import LigerMultiTokenAttentionFunction
from liger_kernel.ops.poly_norm import LigerPolyNormFunction
from liger_kernel.ops.qwen2vl_mrope import LigerQwen2VLMRopeFunction
from liger_kernel.ops.rms_norm import LigerRMSNormFunction
from liger_kernel.ops.rope import LigerRopeFunction
from liger_kernel.ops.softmax import LigerSoftmaxFunction
from liger_kernel.ops.sparsemax import LigerSparsemaxFunction
from liger_kernel.ops.swiglu import LigerSiLUMulFunction
from liger_kernel.ops.tvd import LigerTVDLossFunction
from liger_kernel.ops import LigerCrossEntropyFunction
from liger_kernel.ops import LigerDyTFunction
from liger_kernel.ops import LigerFusedAddRMSNormFunction
from liger_kernel.ops import LigerFusedLinearCrossEntropyFunction
from liger_kernel.ops import LigerFusedLinearJSDFunction
from liger_kernel.ops import LigerFusedNeighborhoodAttentionFunction
from liger_kernel.ops import LigerGELUMulFunction
from liger_kernel.ops import LigerGroupNormFunction
from liger_kernel.ops import LigerJSDFunction
from liger_kernel.ops import LigerKLDivLossFunction
from liger_kernel.ops import LigerLayerNormFunction
from liger_kernel.ops import LigerMultiTokenAttentionFunction
from liger_kernel.ops import LigerPolyNormFunction
from liger_kernel.ops import LigerQwen2VLMRopeFunction
from liger_kernel.ops import LigerRMSNormFunction
from liger_kernel.ops import LigerRopeFunction
from liger_kernel.ops import LigerSiLUMulFunction
from liger_kernel.ops import LigerSoftmaxFunction
from liger_kernel.ops import LigerSparsemaxFunction
from liger_kernel.ops import LigerTVDLossFunction
@dataclass
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.fused_add_rms_norm import LigerFusedAddRMSNormFunction
from liger_kernel.ops import LigerFusedAddRMSNormFunction
class LigerFusedAddRMSNorm(nn.Module):
@@ -2,7 +2,7 @@ from typing import Optional
import torch
from liger_kernel.ops.fused_linear_cross_entropy import LigerFusedLinearCrossEntropyFunction
from liger_kernel.ops import LigerFusedLinearCrossEntropyFunction
from liger_kernel.transformers.functional import CrossEntropyOutput
@@ -2,7 +2,7 @@ from typing import Optional
import torch
from liger_kernel.ops.fused_linear_jsd import LigerFusedLinearJSDFunction
from liger_kernel.ops import LigerFusedLinearJSDFunction
class LigerFusedLinearJSD(torch.nn.Module):
@@ -5,7 +5,7 @@ from typing import Optional
import torch
import torch.nn as nn
from liger_kernel.ops.fused_neighborhood_attention import LigerFusedNeighborhoodAttentionFunction
from liger_kernel.ops import LigerFusedNeighborhoodAttentionFunction
class LigerFusedNeighborhoodAttention(nn.Module):
+1 -1
View File
@@ -1,6 +1,6 @@
import torch.nn as nn
from liger_kernel.ops.geglu import LigerGELUMulFunction
from liger_kernel.ops import LigerGELUMulFunction
class LigerGEGLUMLP(nn.Module):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.group_norm import LigerGroupNormFunction
from liger_kernel.ops import LigerGroupNormFunction
class LigerGroupNorm(nn.Module):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
from liger_kernel.chunked_loss.fused_linear_ppo import LigerFusedLinearPPOBase
from liger_kernel.ops.grpo_loss import GrpoLossFunction
from liger_kernel.ops import GrpoLossFunction
def triton_grpo_loss(
+1 -1
View File
@@ -2,7 +2,7 @@ from typing import Optional
import torch
from liger_kernel.ops.jsd import LigerJSDFunction
from liger_kernel.ops import LigerJSDFunction
class LigerJSD(torch.nn.Module):
+1 -1
View File
@@ -1,6 +1,6 @@
import torch.nn as nn
from liger_kernel.ops.kl_div import LigerKLDivLossFunction
from liger_kernel.ops import LigerKLDivLossFunction
class LigerKLDIVLoss(nn.KLDivLoss):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.layer_norm import LigerLayerNormFunction
from liger_kernel.ops import LigerLayerNormFunction
class LigerLayerNorm(nn.Module):
+1 -1
View File
@@ -5,7 +5,7 @@ Supports both text and vision RoPE variants with fused operations for optimal pe
import torch
from liger_kernel.ops.llama4_rope import LigerLlama4RopeFunction
from liger_kernel.ops import LigerLlama4RopeFunction
def liger_llama4_text_rotary_pos_emb(
@@ -5,7 +5,7 @@ import torch.nn as nn
from torch.nn.modules.utils import _pair
from liger_kernel.ops.multi_token_attention import LigerMultiTokenAttentionFunction
from liger_kernel.ops import LigerMultiTokenAttentionFunction
class LigerMultiTokenAttention(nn.Module):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.poly_norm import LigerPolyNormFunction
from liger_kernel.ops import LigerPolyNormFunction
class LigerPolyNorm(nn.Module):
@@ -1,4 +1,4 @@
from liger_kernel.ops.qwen2vl_mrope import LigerQwen2VLMRopeFunction
from liger_kernel.ops import LigerQwen2VLMRopeFunction
def liger_multimodal_rotary_pos_emb(q, k, cos, sin, mrope_section, unsqueeze_dim=1):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.rms_norm import LigerRMSNormFunction
from liger_kernel.ops import LigerRMSNormFunction
class LigerRMSNorm(nn.Module):
+1 -1
View File
@@ -2,7 +2,7 @@ from typing import Tuple
import torch
from liger_kernel.ops.rope import LigerRopeFunction
from liger_kernel.ops import LigerRopeFunction
def liger_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):
+1 -1
View File
@@ -1,7 +1,7 @@
import torch
import torch.nn as nn
from liger_kernel.ops.sparsemax import LigerSparsemaxFunction
from liger_kernel.ops import LigerSparsemaxFunction
class LigerSparsemax(nn.Module):
+1 -1
View File
@@ -1,6 +1,6 @@
import torch.nn as nn
from liger_kernel.ops.swiglu import LigerSiLUMulFunction
from liger_kernel.ops import LigerSiLUMulFunction
class LigerSwiGLUMLP(nn.Module):
+3 -3
View File
@@ -2,9 +2,9 @@ from typing import Optional
import torch.nn as nn
from liger_kernel.ops.geglu import LigerGELUMulFunction
from liger_kernel.ops.swiglu import LigerSiLUMulFunction
from liger_kernel.ops.tiled_mlp import apply_tiled_mlp
from liger_kernel.ops import LigerGELUMulFunction
from liger_kernel.ops import LigerSiLUMulFunction
from liger_kernel.ops import apply_tiled_mlp
class LigerTiledGEGLUMLP(nn.Module):
+1 -1
View File
@@ -1,6 +1,6 @@
import torch.nn as nn
from liger_kernel.ops.tvd import LigerTVDLossFunction
from liger_kernel.ops import LigerTVDLossFunction
class LigerTVDLoss(nn.Module):