﻿# Moirai 2 migration: quantile projections and observed-mask embeddings replace older assumptions

Port Moirai 2 using its actual quantile projection and value-plus-observation embedding instead of borrowing distribution-head assumptions from original Moirai.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-moirai2-quantile-head-observed-mask-embedding-port/
Language: en

## Pin the generation before reading familiar names

The [Moirai 2 model card](https://huggingface.co/Salesforce/moirai-2.0-R-small/raw/main/README.md) describes a shift from distributional loss to quantile loss, multiple predicted tokens and missingness-aware patch embedding. Those are implementation changes, not simply a larger checkpoint behind an unchanged numerical interface. A migration should therefore specify the exact module and forecasting wrapper before reusing an older inference adapter or interpreting projected channels as parameters of the original predictive distribution.

## Follow numerical values and observation indicators together

The [module implementation](https://raw.githubusercontent.com/SalesforceAIResearch/uni2ts/main/src/uni2ts/model/moirai2/module.py) concatenates scaled target values with floating-point observation-mask values before input projection. The mask contributes information to the token representation in addition to participating in other controls. A port that preserves only the values loses a learned input channel. Filling a missing value does not automatically make its observation indicator true; storage repair and measurement availability remain separate properties.

## Inspect the real return path

The module projects representations into output dimensions determined by predicted tokens, quantile levels and patch size. Its current numerical return path differs from older distribution-output construction, even where inherited documentation wording may look familiar. Read executed operations and the matching wrapper rather than treating a descriptive return label as proof of type compatibility. A valid tensor width still needs its axis meaning and scaling rule to be preserved.

## Preserve the quantile consumer

The [forecasting wrapper](https://raw.githubusercontent.com/SalesforceAIResearch/uni2ts/main/src/uni2ts/model/moirai2/forecast.py) uses a quantile forecast generator with the module's configured levels. An adapter expecting sampled trajectories from the original family needs an explicit statistical translation, not a renamed variable. The [original Moirai distribution guide](/journal/fg2-moirai-distribution-object-sampled-forecast-boundary/) explains the earlier boundary. Do not create claims of calibrated tail probabilities merely by exposing additional labels around an existing output array.

## Validate missingness and output semantics independently

Use equal stored values with different observation indicators to test the embedding path, then verify selected quantile coordinates and inverse scaling. The [packed-input guide](/journal/fg2-moirai-packed-sample-variate-identity-scaling/) supplies related identity checks. Compare the pinned reference model before measuring task quality. A migration succeeds when its input information and output statistics match the chosen generation, preserving the distinction between a working checkpoint load, a faithful numerical implementation and an accurate forecast for a new application domain.
