---
title: "ClikaRT::nn::QLinearWoQ"
sidebar_label: "QLinearWoQ"
description: "Weight-only-quantized linear module: the weight rests quantized (a QTensor) and decodes inside the matmul kernels; compute runs at the activation dtype, Linear's weight-only sibling (same forward surf…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**Header:** `ClikaRT/nn/qlinear_woq.h`  
**Inherits:** [`ClikaRT::nn::Linear`](./Linear.md)

`QLinearWoQ`: the weight-only-quantization PIN of the `Linear` family: a `Linear` whose weight MUST be quantized-at-rest. The activation stays floating point and the weight stays quantized for the module's lifetime; it is never materialized dense at load. The first forward packs the quantized payload once into the backend's kernel layout (the packed form is then the single resident copy); every later forward runs the quantized-weight matmul off it. This is the path that serves a block-quantized checkpoint at its on-disk footprint.

A plain `Linear` already SERVES a quantized payload that binds onto its declared slot (the base routes at pack time; see [linear.h](./index.md#linear-h)); this subclass exists to make the posture a CONTRACT: a dense payload is refused with a clean error, at `set_weights` and at the pack gate alike, instead of being silently dense-packed. `kind()` reports `WeightQuantized` constantly. Construct through `Linear::make` (which returns this class for a quantized weight) or pin explicitly through the factories here; the lifecycle, movement, and forward are the family's ([linear.h](./index.md#linear-h)).

The weight's orientation is the PAYLOAD's own, read by the family's one quantized-orientation law ([linear.h](./index.md#linear-h)): a grouped scheme is oriented by its group axis and a plain code tensor by its per-channel scale axis (one scale per output feature); past those, the declared counts decide a non-square shape, a `load_gguf` block stream reads in the loader's `[in_features, out_features]` order, and a per-tensor code tensor reads the dense `[out, in]` from the tensor alone, a square one included; a payload whose factory fixes its orientation (`make_quantized_fp8`: `[in, out]`) carries that statement and is read by it first. The registry slot declares `[in_features, out_features]` (the loader order), and a payload in either logical order binds onto it; the pack serves the resolved orientation. A dtype `to` is `Unsupported`: the weight stays quantized at rest; dequantize explicitly for a dense copy.

Weight-only-quantized linear module: the weight rests quantized (a [`QTensor`](../QTensor.md)) and decodes inside the matmul kernels; compute runs at the activation dtype, [`Linear`](./Linear.md)'s weight-only sibling (same forward surface).

The module owns its weights: construct with `make(...)`, or declare shapes and bind a checkpoint via [`load_state_dict`](./Module.md#load_state_dict). The first forward packs the weight (or [`LoadOptions::pack_on_load`](./LoadOptions.md#pack_on_load) packs it at the end of the load); the pack is the one resident copy, and [`named_parameters()`](./Module.md#named_parameters) / [`state_dict()`](./Module.md#state_dict) read the weight back from it; `to(dtype)` restores, casts, and re-packs on the next forward.

## Static member functions

### make(Tensor, OptionalTensor, LinearOptions) {#make}

<div class="api-signature">

`static` `std::shared_ptr<QLinearWoQ>` **`make`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `weight`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`LinearOptions`](./LinearOptions.md) `options` `=` `{}`<br />
)

</div>

Construct FROM a quantized weight (a static factory, so a bad config is a clean error): geometry (the payload's own orientation, by the law in [linear.h](./index.md#linear-h)), dtype and device all read off the payload; declared AND bound in one call (an optional float `bias` `[out]` binds beside it; a bias slot exists exactly when `bias` is passed). The [`QTensor`](../QTensor.md) overload is the typed convenience over the same factory. Raises [`ClikaRT::Error`](../Error.md) on a dense payload; that is this class's whole contract.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 66

</div>

### make(QTensor, OptionalTensor, LinearOptions) {#make-2}

<div class="api-signature">

`static` `std::shared_ptr<QLinearWoQ>` **`make`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`QTensor`](../QTensor.md) `weight`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`LinearOptions`](./LinearOptions.md) `options` `=` `{}`<br />
)

</div>

Construct from a quantized weight in either logical order (its own orientation, by the law in [linear.h](./index.md#linear-h); + optional bias and the shared [`LinearOptions`](./LinearOptions.md)). Raises when the scheme cannot be served, or when the payload's evidence contradicts a declared geometry.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 75

</div>

### make(int64\_t, int64\_t, LinearOptions) {#make-3}

<div class="api-signature">

`static` `std::shared_ptr<QLinearWoQ>` **`make`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `in_features`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::int64_t` `out_features`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`LinearOptions`](./LinearOptions.md) `options` `=` `{}`<br />
)

</div>

Construct FROM a quantized weight (a static factory, so a bad config is a clean error): geometry (the payload's own orientation, by the law in [linear.h](./index.md#linear-h)), dtype and device all read off the payload; declared AND bound in one call (an optional float `bias` `[out]` binds beside it; a bias slot exists exactly when `bias` is passed). The [`QTensor`](../QTensor.md) overload is the typed convenience over the same factory. Raises [`ClikaRT::Error`](../Error.md) on a dense payload; that is this class's whole contract.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 92

</div>

## Member functions

### \~QLinearWoQ() {#QLinearWoQ}

<div class="api-signature">

**`~QLinearWoQ`**() `override`

</div>

Releases the module's packed weights.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 99

</div>

### kind() {#kind}

<div class="api-signature">

`virtual` [`LinearKind`](./index.md#LinearKind) **`kind`**() `const noexcept override`

</div>

`WeightQuantized`, constantly; this class IS the posture pin.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 102

</div>

### set\_weights(QTensor, OptionalTensor) {#set_weights}

<div class="api-signature">

`void` **`set_weights`**([`QTensor`](../QTensor.md) `weight`, [`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`)

</div>

Bind the declared slots positionally: the QUANTIZED `weight` (its logical shape in either orientation, read by the orientation law in [linear.h](./index.md#linear-h) and validated against the declared feature counts) and, when the module was declared with one, a floating-point `bias`. A DENSE weight is refused, the pin this class exists for. Re-binding after a pack drops the pack. The [`QTensor`](../QTensor.md) overload is the typed convenience (e.g. a `load_gguf` entry through [`quantized_view`](../../index.md#quantized_view)). Raises [`ClikaRT::Error`](../Error.md) on a dense payload, a geometry mismatch, or a bias without a declared bias slot.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 115

</div>

### set\_weights(Tensor, OptionalTensor) {#set_weights-2}

<div class="api-signature">

`void` **`set_weights`**([`Tensor`](../Tensor.md) `weight`, [`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`)

</div>

Bind the declared slots positionally: the QUANTIZED `weight` (its logical shape in either orientation, read by the orientation law in [linear.h](./index.md#linear-h) and validated against the declared feature counts) and, when the module was declared with one, a floating-point `bias`. A DENSE weight is refused, the pin this class exists for. Re-binding after a pack drops the pack. The [`QTensor`](../QTensor.md) overload is the typed convenience (e.g. a `load_gguf` entry through [`quantized_view`](../../index.md#quantized_view)). Raises [`ClikaRT::Error`](../Error.md) on a dense payload, a geometry mismatch, or a bias without a declared bias slot.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 114

</div>

## Protected member functions

### initialize\_impl() {#initialize_impl}

<div class="api-signature">

`virtual` [`Result`](../Result.md)`<void>` **`initialize_impl`**() `override`

</div>

The pack hook ([linear.h](./index.md#linear-h)), plus the pin at the pack gate: a DENSE payload that reached the slot by name ([`load_state_dict`](./Module.md#load_state_dict) binds without [`set_weights`](./QLinearWoQ.md#set_weights)) is refused here rather than dense-packed.

<div class="api-declared">

Declared in `ClikaRT/nn/qlinear_woq.h`, line 126

</div>
