# Dtype and Quantization

A tensor's dtype is one of the fixed metadata fields covered in [Shape, Rank, Stride and Layout](/docs/core-concepts/shape-rank-stride-layout); this page focuses on the part of the dtype space that needs its own explanation - quantized dtypes, where the stored value isn't the real value.

## Ordinary vs. quantized dtypes

An ordinary floating-point dtype (float32, bfloat16, float16) stores something close enough to the real value directly - reading the number *is* using the number. A quantized dtype (int8, int4, and lower-bit packed formats) stores an integer that only approximates the real value once combined with extra parameters - a scale, and often a zero-point. Tensormorph's dtype metadata always distinguishes the two, and the [Scalar Inspector](/docs/editors/scalar-inspector) shows both the raw stored integer and the dequantized value for any quantized scalar, rather than picking one to display.

Dtype is orthogonal to shape and stride - two tensors with identical shape can differ only in dtype, and a single quantization pass typically leaves shape and stride completely untouched while changing dtype and adding scale/zero-point metadata.

## Granularity

Quantization parameters (scale and zero-point) can be shared at different granularities:

-   **Per-tensor** - one scale/zero-point pair for the whole tensor.
-   **Per-channel** - one pair per output channel, common for weight quantization since different channels often have meaningfully different value ranges.
-   **Per-group** - one pair per small run of adjacent values, common for aggressive low-bit weight-only quantization.

Finer granularity generally preserves more accuracy at the cost of more metadata; Tensormorph's quantization-boundary overlay (see the [Architecture view](/docs/editors/architecture-editor#the-overlay-system)) draws a line wherever this granularity changes, so a per-group scheme's boundaries are visible directly on the tensor.

## Where this shows up elsewhere

-   [Quantized Models](/docs/working-with-models/quantized-models) - the applied, format-level view of everything on this page.
-   [Quantization Diff](/docs/compare-and-morph/quantization-diff) - comparing a quantized tensor against its full-precision source.
-   [Sparsity](/docs/inspect-and-analyze/sparsity) - aggressive quantization can round small values to exactly zero as a side effect, which looks like pruning-induced sparsity but isn't.

## Related resources

-   [Shape, Rank, Stride and Layout](/docs/core-concepts/shape-rank-stride-layout) - the broader dtype/device/layout metadata model this page extends.
-   [GPU Backend Compatibility](/docs/reference/gpu-backend-compatibility) - low-bit quantized kernels aren't uniformly supported across every backend.
