﻿# Moirai automatic patch size: historical validation is an inference-time selection procedure

Explain original Moirai automatic patch selection through its historical validation window, per-item loss comparison and multiple candidate computations.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-moirai-auto-patch-size-historical-selection-cost/
Language: en

## Define what automatic selection chooses

Original Moirai supports several patch sizes in one model configuration. The [project examples](https://raw.githubusercontent.com/SalesforceAIResearch/uni2ts/main/README.md) expose an automatic option alongside fixed choices. That option should be recorded as a procedure, not replaced in documentation by whichever fixed patch size seems typical. It selects a representation granularity using available historical evidence, so the forecasting input and inference workload differ from a single fixed-patch invocation.

## Follow the extra historical window

The [forecasting wrapper](https://raw.githubusercontent.com/SalesforceAIResearch/uni2ts/main/src/uni2ts/model/moirai/forecast.py) requests a past window containing context plus a prediction-length segment in automatic mode. It uses the earlier portion as context and the following historical segment for validation. This is an internal selection window within supplied past data, not permission to inspect the actual future forecast labels. Preserve the as-of availability cut so the wrapper cannot receive observations unavailable at the experiment's forecast origin.

## Inspect per-item candidate scoring

The wrapper evaluates losses for the model's supported patch sizes and chooses the minimum-loss candidate for each item. The [module implementation](https://raw.githubusercontent.com/SalesforceAIResearch/uni2ts/main/src/uni2ts/model/moirai/module.py) defines the patch-size-aware projections used by those candidates. A single request can therefore select different granularities across items. Treat the supported candidate set and loss definition as part of the experiment; changing them changes the selection rule even if the checkpoint weights remain identical.

## Account for multiple candidate computations

The implementation constructs candidate predictions alongside validation losses. Timing automatic mode as though it were one fixed-size forward pass can misrepresent deployment cost. The [artifact-manifest guide](/journal/tokenizer-artifact-release-manifest/) offers related release controls. Preserve mode, context, horizon and candidate configuration when comparing CPU or GPU execution, and distinguish the cost of selecting a patch size from the cost of forecasting with a predetermined choice.

## Evaluate selection on an outer forecast window

Compare automatic and fixed modes using the same outer forecast origins and labels, while respecting their distinct historical requirements. The [entity-split guide](/journal/data-guide-entity-group-split-design/) provides related evaluation context. Report both predictive behavior and runtime rather than assuming that minimizing a historical selection loss guarantees the best future forecast. A useful result explains which evidence chose the patch size and which independent observations measured the selected procedure's actual forecasting quality.
