---
title: "clika_runtime.nn"
sidebar_label: "clika_runtime.nn"
description: "The clika_runtime.nn module, introspected from the installed wheel."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

clika_runtime.nn: build models as module trees.

Compose layers by attribute assignment inside a :class:`Module` subclass,
define ``forward``, and call the module like a function; ``state_dict`` /
``load_state_dict`` move checkpoints by dotted names, ``to`` places the
tree, forward hooks observe or rewrite a call, and ``print(module)`` shows
the tree. :class:`Parameter` and :class:`Buffer` are the tensors a module
registers by type; the containers (:class:`Sequential`,
:class:`ModuleList`, :class:`ModuleDict`, :class:`ParameterList`,
:class:`ParameterDict`) compose without a hand-written forward;
:mod:`clika_runtime.nn.init` fills weights in place. Stateless operations
(activations, losses, padding, attention) live in
:mod:`clika_runtime.nn.functional`.

The layer set covers both weight postures: dense (:class:`Linear`,
:class:`Conv` with :class:`Conv1d` / :class:`Conv2d` / :class:`Conv3d`,
:class:`ConvTranspose` with its 1d / 2d / 3d spellings, :class:`Embedding`,
:class:`LayerNorm`, :class:`RMSNorm`, :class:`BatchNorm1d` /
:class:`BatchNorm2d` / :class:`BatchNorm3d`, :class:`InstanceNorm1d` /
:class:`InstanceNorm2d` / :class:`InstanceNorm3d`, :class:`GroupNorm`,
:class:`MultiheadAttention`, :class:`MoE`) and quantized (:class:`QLinear`,
:class:`QLinearWoQ`, :class:`QConv`, :class:`QConvWoQ`, :class:`QMoEWoQ`);
:class:`Embedding` serves a quantized table through the same class. Every layer takes the
familiar constructor (``device=`` / ``dtype=`` tail, a mode such as
``activation="gelu"`` by name), and its weights read as
:class:`Parameter` views (``layer.weight``). :class:`Dropout` and its
channel-wise and alpha variants regularize under ``train()`` and pass
their input through under ``eval()``; :class:`RReLU` draws its negative slopes
under ``train()``; :class:`Identity` returns its input. :class:`KVCache` is the
serving-side key/value cache with its configuration vocabulary;
:func:`fuse_linears` and :func:`fuse_convs` name the layer-group fusions.

| Name | Kind |
| --- | --- |
| [`AdaptiveAvgPool1d`](./AdaptiveAvgPool1d.md) | class |
| [`AdaptiveAvgPool2d`](./AdaptiveAvgPool2d.md) | class |
| [`AdaptiveAvgPool3d`](./AdaptiveAvgPool3d.md) | class |
| [`AdaptiveMaxPool1d`](./AdaptiveMaxPool1d.md) | class |
| [`AdaptiveMaxPool2d`](./AdaptiveMaxPool2d.md) | class |
| [`AdaptiveMaxPool3d`](./AdaptiveMaxPool3d.md) | class |
| [`Add`](./Add.md) | class |
| [`AlphaDropout`](./AlphaDropout.md) | class |
| [`AvgPool1d`](./AvgPool1d.md) | class |
| [`AvgPool2d`](./AvgPool2d.md) | class |
| [`AvgPool3d`](./AvgPool3d.md) | class |
| [`BCELoss`](./BCELoss.md) | class |
| [`BCEWithLogitsLoss`](./BCEWithLogitsLoss.md) | class |
| [`BatchNorm1d`](./BatchNorm1d.md) | class |
| [`BatchNorm2d`](./BatchNorm2d.md) | class |
| [`BatchNorm3d`](./BatchNorm3d.md) | class |
| [`Buffer`](./Buffer.md) | class |
| [`CELU`](./CELU.md) | class |
| [`CircularPad`](./CircularPad.md) | class |
| [`CircularPad1d`](./CircularPad1d.md) | class |
| [`CircularPad2d`](./CircularPad2d.md) | class |
| [`CircularPad3d`](./CircularPad3d.md) | class |
| [`Clamp`](./Clamp.md) | class |
| [`ConstantPad`](./ConstantPad.md) | class |
| [`ConstantPad1d`](./ConstantPad1d.md) | class |
| [`ConstantPad2d`](./ConstantPad2d.md) | class |
| [`ConstantPad3d`](./ConstantPad3d.md) | class |
| [`Conv`](./Conv.md) | class |
| [`Conv1d`](./Conv1d.md) | class |
| [`Conv2d`](./Conv2d.md) | class |
| [`Conv3d`](./Conv3d.md) | class |
| [`ConvTranspose`](./ConvTranspose.md) | class |
| [`ConvTranspose1d`](./ConvTranspose1d.md) | class |
| [`ConvTranspose2d`](./ConvTranspose2d.md) | class |
| [`ConvTranspose3d`](./ConvTranspose3d.md) | class |
| [`CosineSimilarity`](./CosineSimilarity.md) | class |
| [`CrossEntropyLoss`](./CrossEntropyLoss.md) | class |
| [`Div`](./Div.md) | class |
| [`Dropout`](./Dropout.md) | class |
| [`Dropout1d`](./Dropout1d.md) | class |
| [`Dropout2d`](./Dropout2d.md) | class |
| [`Dropout3d`](./Dropout3d.md) | class |
| [`ELU`](./ELU.md) | class |
| [`Embedding`](./Embedding.md) | class |
| [`FeatureAlphaDropout`](./FeatureAlphaDropout.md) | class |
| [`Flatten`](./Flatten.md) | class |
| [`Fold`](./Fold.md) | class |
| [`GELU`](./GELU.md) | class |
| [`GLU`](./GLU.md) | class |
| [`GeGLU`](./GeGLU.md) | class |
| [`GroupNorm`](./GroupNorm.md) | class |
| [`Hardshrink`](./Hardshrink.md) | class |
| [`Hardsigmoid`](./Hardsigmoid.md) | class |
| [`Hardswish`](./Hardswish.md) | class |
| [`Hardtanh`](./Hardtanh.md) | class |
| [`HuberLoss`](./HuberLoss.md) | class |
| [`Identity`](./Identity.md) | class |
| [`InitSpec`](./InitSpec.md) | class |
| [`InstanceNorm1d`](./InstanceNorm1d.md) | class |
| [`InstanceNorm2d`](./InstanceNorm2d.md) | class |
| [`InstanceNorm3d`](./InstanceNorm3d.md) | class |
| [`KLDivLoss`](./KLDivLoss.md) | class |
| [`KVBlockScheme`](./KVBlockScheme.md) | class |
| [`KVCache`](./KVCache.md) | class |
| [`KVCacheConfig`](./KVCacheConfig.md) | class |
| [`KVCacheMode`](./KVCacheMode.md) | class |
| [`KVLayerSpec`](./KVLayerSpec.md) | class |
| [`KVQuantSpec`](./KVQuantSpec.md) | class |
| [`L1Loss`](./L1Loss.md) | class |
| [`LayerNorm`](./LayerNorm.md) | class |
| [`LeakyReLU`](./LeakyReLU.md) | class |
| [`Linear`](./Linear.md) | class |
| [`LogSigmoid`](./LogSigmoid.md) | class |
| [`LogSoftmax`](./LogSoftmax.md) | class |
| [`MSELoss`](./MSELoss.md) | class |
| [`MaxPool1d`](./MaxPool1d.md) | class |
| [`MaxPool2d`](./MaxPool2d.md) | class |
| [`MaxPool3d`](./MaxPool3d.md) | class |
| [`Maximum`](./Maximum.md) | class |
| [`Minimum`](./Minimum.md) | class |
| [`Mish`](./Mish.md) | class |
| [`MoE`](./MoE.md) | class |
| [`Module`](./Module.md) | class |
| [`ModuleDict`](./ModuleDict.md) | class |
| [`ModuleList`](./ModuleList.md) | class |
| [`Mul`](./Mul.md) | class |
| [`MultiheadAttention`](./MultiheadAttention.md) | class |
| [`NLLLoss`](./NLLLoss.md) | class |
| [`PagedParams`](./PagedParams.md) | class |
| [`PairwiseDistance`](./PairwiseDistance.md) | class |
| [`Parameter`](./Parameter.md) | class |
| [`ParameterDict`](./ParameterDict.md) | class |
| [`ParameterList`](./ParameterList.md) | class |
| [`PixelShuffle`](./PixelShuffle.md) | class |
| [`PixelUnshuffle`](./PixelUnshuffle.md) | class |
| [`Pow`](./Pow.md) | class |
| [`QConv`](./QConv.md) | class |
| [`QConvWoQ`](./QConvWoQ.md) | class |
| [`QLinear`](./QLinear.md) | class |
| [`QLinearWoQ`](./QLinearWoQ.md) | class |
| [`QMoEWoQ`](./QMoEWoQ.md) | class |
| [`RMSNorm`](./RMSNorm.md) | class |
| [`RReLU`](./RReLU.md) | class |
| [`ReGLU`](./ReGLU.md) | class |
| [`ReLU`](./ReLU.md) | class |
| [`ReLU6`](./ReLU6.md) | class |
| [`ReflectionPad`](./ReflectionPad.md) | class |
| [`ReflectionPad1d`](./ReflectionPad1d.md) | class |
| [`ReflectionPad2d`](./ReflectionPad2d.md) | class |
| [`ReflectionPad3d`](./ReflectionPad3d.md) | class |
| [`ReplicationPad`](./ReplicationPad.md) | class |
| [`ReplicationPad1d`](./ReplicationPad1d.md) | class |
| [`ReplicationPad2d`](./ReplicationPad2d.md) | class |
| [`ReplicationPad3d`](./ReplicationPad3d.md) | class |
| [`SELU`](./SELU.md) | class |
| [`Sequential`](./Sequential.md) | class |
| [`SiLU`](./SiLU.md) | class |
| [`Sigmoid`](./Sigmoid.md) | class |
| [`SmoothL1Loss`](./SmoothL1Loss.md) | class |
| [`Softmax`](./Softmax.md) | class |
| [`Softmin`](./Softmin.md) | class |
| [`Softplus`](./Softplus.md) | class |
| [`Softshrink`](./Softshrink.md) | class |
| [`Softsign`](./Softsign.md) | class |
| [`StepIndices`](./StepIndices.md) | class |
| [`Sub`](./Sub.md) | class |
| [`SwiGLU`](./SwiGLU.md) | class |
| [`Tanh`](./Tanh.md) | class |
| [`Threshold`](./Threshold.md) | class |
| [`Unflatten`](./Unflatten.md) | class |
| [`Unfold`](./Unfold.md) | class |
| [`Upsample`](./Upsample.md) | class |
| [`WeightResidency`](./WeightResidency.md) | class |
| [`Where`](./Where.md) | class |
| [`ZeroPad`](./ZeroPad.md) | class |
| [`ZeroPad1d`](./ZeroPad1d.md) | class |
| [`ZeroPad2d`](./ZeroPad2d.md) | class |
| [`ZeroPad3d`](./ZeroPad3d.md) | class |
| [functions](./functions.md) | module functions |