chore(review): remove unused GeLU exports, dedupe fast_layernorm_inference import; minor cleanup
This commit is contained in:
parent
c505a060ca
commit
cd9cae3eda
3 changed files with 6 additions and 23 deletions
|
|
@ -29,7 +29,7 @@ from .layernorm import (
|
|||
)
|
||||
from .rope_embedding import fast_rope_embedding, inplace_rope_embedding
|
||||
from .dropout import DeterministicDropout, seeded_dropout
|
||||
from .gelu import fast_gelu, FastGELU
|
||||
# GeLU acceleration reserved; currently unused
|
||||
from .swiglu import swiglu_fg_kernel, swiglu_DWf_DW_dfg_kernel
|
||||
from .geglu import (
|
||||
geglu_exact_forward_kernel,
|
||||
|
|
|
|||
|
|
@ -12,27 +12,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import torch
|
||||
import torch.nn.functional as F
|
||||
|
||||
|
||||
@torch.compiler.disable
|
||||
def fast_gelu(x: torch.Tensor, approximate: str | None = None) -> torch.Tensor:
|
||||
"""Fast GeLU wrapper. Uses torch.nn.functional.gelu with optional approximation.
|
||||
|
||||
approximate: None | "tanh"
|
||||
"""
|
||||
if approximate is None:
|
||||
return F.gelu(x)
|
||||
return F.gelu(x, approximate=approximate)
|
||||
|
||||
|
||||
class FastGELU(torch.nn.Module):
|
||||
def __init__(self, approximate: str | None = None):
|
||||
super().__init__()
|
||||
self.approximate = approximate
|
||||
|
||||
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
||||
return fast_gelu(x, self.approximate)
|
||||
"""
|
||||
Reserved module for optional GeLU acceleration. Currently unused.
|
||||
Left intentionally minimal to address reviewer feedback.
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from .llama import *
|
||||
from ..kernels import fast_layernorm_inference
|
||||
from ._utils import __version__
|
||||
from unsloth_zoo.hf_utils import dtype_from_config
|
||||
from unsloth_zoo.utils import _get_dtype, Version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue