Run this model with HF Jobs
Run replicate/rmsnorm on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/replicate/rmsnorm. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/replicate/rmsnorm on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use replicate/rmsnorm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use replicate/rmsnorm with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("replicate/rmsnorm", version=1) - Notebooks
- Google Colab
- Kaggle
Build uploaded using `kernels`.
Browse filesFiles changed (19)
- .gitattributes+4
- build/torch210-cxx11-cpu-x86_64-linux/_ops.py+3-3
- build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so → build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.soRenamed+1-1
- build/torch210-cxx11-cpu-x86_64-linux/metadata.json+4-1
- build/torch210-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py+2-2
- build/torch210-cxx11-xpu20253-x86_64-linux/_ops.py+3-3
- build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so → build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.soRenamed+1-1
- build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json+4-1
- build/torch210-cxx11-xpu20253-x86_64-linux/rmsnorm/__init__.py+2-2
- build/torch211-cxx11-cpu-x86_64-linux/__init__.pyAdded+27
- build/torch211-cxx11-cpu-x86_64-linux/_ops.pyAdded+9
- build/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.soAdded+3
- build/torch211-cxx11-cpu-x86_64-linux/layers.pyAdded+59
- build/torch211-cxx11-cpu-x86_64-linux/metadata.jsonAdded+8
- build/torch211-cxx11-cpu-x86_64-linux/rmsnorm/__init__.pyAdded+26
- build/torch29-cxx11-xpu20252-x86_64-linux/_ops.py+3-3
- build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so → build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.soRenamed+1-1
- build/torch29-cxx11-xpu20252-x86_64-linux/metadata.json+4-1
- build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py+2-2
89 unmodified lines90919289 unmodified linesbuild/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -text89 unmodified lines9091929394959689 unmodified linesbuild/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch29-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.so filter=lfs diff=lfs merge=lfs -textbuild/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.so filter=lfs diff=lfs merge=lfs -text
123456789import torchfrom . import _rmsnorm_cpu_b3d66c6ops = torch.ops._rmsnorm_cpu_b3d66c6def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_cpu_b3d66c6::{op_name}"123456789import torchfrom . import _rmsnorm_cpu_cec90b8ops = torch.ops._rmsnorm_cpu_cec90b8def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_cpu_cec90b8::{op_name}"
123version https://git-lfs.github.com/spec/v1oid sha256:431ce18c385750f4047b80606977a6634475a66c10b6ae38ee4f4600be07f62esize 2006072123version https://git-lfs.github.com/spec/v1oid sha256:707454a1958381abde25f844df3a461c933df1c0f72a7f85916950df2d9efe77size 2006072
12345{"version": 1,"license": "Apache-2.0","python-depends": []}12345678{"version": 1,"license": "Apache-2.0","python-depends": [],"backend": {"type": "cpu"}}
12345678910import ctypesimport sysimport importlibfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that12345678910import ctypesimport importlib.utilimport sysfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that
123456789import torchfrom . import _rmsnorm_xpu_b3d66c6ops = torch.ops._rmsnorm_xpu_b3d66c6def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_xpu_b3d66c6::{op_name}"123456789import torchfrom . import _rmsnorm_xpu_cec90b8ops = torch.ops._rmsnorm_xpu_cec90b8def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_xpu_cec90b8::{op_name}"
123version https://git-lfs.github.com/spec/v1oid sha256:84f0c7d2e40714ef9721814d123b24e95119d01074f34af3fb21c45f36de2c00size 104793360123version https://git-lfs.github.com/spec/v1oid sha256:f189d83a1f1245edd0a35839df2686bc806d33a2a1f4c30fbeefe2dd58de55dfsize 104793360
12345{"version": 1,"license": "Apache-2.0","python-depends": []}12345678{"version": 1,"license": "Apache-2.0","python-depends": [],"backend": {"type": "xpu"}}
12345678910import ctypesimport sysimport importlibfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that12345678910import ctypesimport importlib.utilimport sysfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that
123456789101112131415161718192021222324252627from . import layers
from ._ops import ops
def apply_rms_norm(input, weight, eps): # ops.apply_rms_norm returns [output, rstd] return ops.apply_rms_norm( input, weight, eps, )[0]
def apply_rms_norm_backward(grad_output, input, weight, output, rstd, eps, input_requires_grad=True, weight_requires_grad=True): return ops.apply_rms_norm_backward( grad_output, input, weight, output, rstd, eps, input_requires_grad, weight_requires_grad )
__all__ = ["layers", "apply_rms_norm_forward", "apply_rms_norm_backward"]
123456789import torchfrom . import _rmsnorm_cpu_cec90b8ops = torch.ops._rmsnorm_cpu_cec90b8
def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ return f"_rmsnorm_cpu_cec90b8::{op_name}"123version https://git-lfs.github.com/spec/v1oid sha256:931baff3800b3e5bdfa223f3bc1149eb10013914437acc1ca88eec255f552c83size 20019761234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import torchfrom ._ops import ops
class RMSNormFunction(torch.autograd.Function): @staticmethod def forward(ctx, hidden_states, weight, variance_epsilon): ctx.variance_epsilon = variance_epsilon output, rstd = ops.apply_rms_norm(hidden_states, weight, variance_epsilon) ctx.save_for_backward(hidden_states, weight, output, rstd) return output
@staticmethod def backward(ctx, grad_output): hidden_states, weight, output, rstd = ctx.saved_tensors grads = ops.apply_rms_norm_backward( grad_output, hidden_states, weight, output, rstd, ctx.variance_epsilon, ctx.needs_input_grad[0], ctx.needs_input_grad[1] ) return grads[0], grads[1], None
class RMSNorm(torch.nn.Module): """ RMSNorm module that uses the optimized LigerRMSNormFunction. Args: hidden_size (int): The size of the hidden dimension. eps (float, optional): The epsilon value for numerical stability. Defaults to 1e-6. offset (float, optional): Offset value to shift the weight tensor. Defaults to 0.0. casting_mode (str, optional): The casting mode to use. Defaults to "llama". in_place (bool, optional): Whether to modify dY in-place to store dX during backward. Defaults to True. """
weight: torch.Tensor variance_epsilon: float def forward(self, hidden_states): """ Apply RMS normalization to the input tensor. Args: hidden_states (torch.Tensor): Input tensor of shape (B, T, H) or (BxT, H) Returns: torch.Tensor: Normalized tensor of the same shape as input """ return RMSNormFunction.apply( hidden_states, self.weight, self.variance_epsilon, ) __all__ = ["RMSNorm"]12345678{ "version": 1, "license": "Apache-2.0", "python-depends": [], "backend": { "type": "cpu" }}1234567891011121314151617181920212223242526import ctypesimport importlib.utilimport sysfrom pathlib import Pathfrom types import ModuleType
def _import_from_path(file_path: Path) -> ModuleType: # We cannot use the module name as-is, after adding it to `sys.modules`, # it would also be used for other imports. So, we make a module name that # depends on the path for it to be unique using the hex-encoded hash of # the path. path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) module_name = path_hash spec = importlib.util.spec_from_file_location(module_name, file_path) if spec is None: raise ImportError(f"Cannot load spec for {module_name} from {file_path}") module = importlib.util.module_from_spec(spec) if module is None: raise ImportError(f"Cannot load module {module_name} from spec") sys.modules[module_name] = module spec.loader.exec_module(module) # type: ignore return module
globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py")))123456789import torchfrom . import _rmsnorm_xpu_b3d66c6ops = torch.ops._rmsnorm_xpu_b3d66c6def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_xpu_b3d66c6::{op_name}"123456789import torchfrom . import _rmsnorm_xpu_cec90b8ops = torch.ops._rmsnorm_xpu_cec90b8def add_op_namespace_prefix(op_name: str):"""Prefix op by namespace."""return f"_rmsnorm_xpu_cec90b8::{op_name}"
123version https://git-lfs.github.com/spec/v1oid sha256:5cc02cc9de540ade79427f1ff59624932eecae1154fc245bec1eb6797c8cf170size 102179544123version https://git-lfs.github.com/spec/v1oid sha256:b5fb0e95d3b6be17bd03833abcf461bb10d9c62fbf1336d9226dce0950dce1fasize 102179544
12345{"version": 1,"license": "Apache-2.0","python-depends": []}12345678{"version": 1,"license": "Apache-2.0","python-depends": [],"backend": {"type": "xpu"}}
12345678910import ctypesimport sysimport importlibfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that12345678910import ctypesimport importlib.utilimport sysfrom pathlib import Pathfrom types import ModuleTypedef _import_from_path(file_path: Path) -> ModuleType:# We cannot use the module name as-is, after adding it to `sys.modules`,# it would also be used for other imports. So, we make a module name that
.gitattributes+4
build/torch210-cxx11-cpu-x86_64-linux/_ops.py+3-3
build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_b3d66c6.abi3.so → build/torch210-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.soRenamed+1-1
build/torch210-cxx11-cpu-x86_64-linux/metadata.json+4-1
build/torch210-cxx11-cpu-x86_64-linux/rmsnorm/__init__.py+2-2
build/torch210-cxx11-xpu20253-x86_64-linux/_ops.py+3-3
build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so → build/torch210-cxx11-xpu20253-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.soRenamed+1-1
build/torch210-cxx11-xpu20253-x86_64-linux/metadata.json+4-1
build/torch210-cxx11-xpu20253-x86_64-linux/rmsnorm/__init__.py+2-2
build/torch211-cxx11-cpu-x86_64-linux/__init__.pyAdded+27
build/torch211-cxx11-cpu-x86_64-linux/_ops.pyAdded+9
build/torch211-cxx11-cpu-x86_64-linux/_rmsnorm_cpu_cec90b8.abi3.soAdded+3
build/torch211-cxx11-cpu-x86_64-linux/layers.pyAdded+59
build/torch211-cxx11-cpu-x86_64-linux/metadata.jsonAdded+8
build/torch211-cxx11-cpu-x86_64-linux/rmsnorm/__init__.pyAdded+26
build/torch29-cxx11-xpu20252-x86_64-linux/_ops.py+3-3
build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_b3d66c6.abi3.so → build/torch29-cxx11-xpu20252-x86_64-linux/_rmsnorm_xpu_cec90b8.abi3.soRenamed+1-1
build/torch29-cxx11-xpu20252-x86_64-linux/metadata.json+4-1
build/torch29-cxx11-xpu20252-x86_64-linux/rmsnorm/__init__.py+2-2