﻿# iTransformer attention axes: each variate history becomes a token

Trace original iTransformer history-to-token projection and attention over variates, preserving the fixed history-width projection instead of transposing arrays around an ordinary temporal transformer.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-itransformer-variate-token-attention-axis-fixed-history/
Language: en

## Start with the learned token definition

The [iTransformer paper](https://arxiv.org/abs/2310.06625) proposes representing each variate's history as a token. Attention then operates across variate representations rather than following the usual one-time-step-per-token arrangement. This changes what the network learns and how input dimensions map into parameters. An adapter cannot reproduce the architecture by transposing raw data around an already trained ordinary temporal transformer and leaving its embedding weights unchanged.

## Follow the history-width projection

The [inverted embedding implementation](https://raw.githubusercontent.com/thuml/iTransformer/main/layers/Embed.py) moves the time dimension into the feature axis and applies a linear projection to the historical vector. That projection is configured for a particular input width. Longer context is therefore not automatically a free extension accepted by any checkpoint. Preserve history length, normalization and embedding parameters together, rather than assuming that all sequence-length changes are handled solely by attention.

## Interpret attention over the actual token axis

The [model implementation](https://raw.githubusercontent.com/thuml/iTransformer/main/model/iTransformer.py) sends embedded variates through its encoder and projects each resulting representation into future time steps. An attention map at that stage describes relations among those embedded tokens. It should not be relabeled as a map of individual historical timestamps. Interpretability claims need the real token definition, particularly when extra encoder-side feature tokens are included in the same sequence.

## Keep output time separate from token count

The forecast projection maps representation width to the configured horizon and restores the application's time-by-variable layout. The number of variates and the number of future steps therefore govern different axes. The [PatchTST geometry guide](/journal/fg2-patchtst-patch-stride-end-padding-flatten-head-shape/) offers a contrasting history-to-token design. A consumer should preserve target identity and time coordinates through this projection rather than accepting any two-dimensional output with matching element count.

## Verify a port with labeled axes

Use an input where each variate and historical position has a recognizable value. Inspect projected token count, embedding width, output horizon and restored variable labels against the reference. The [Moirai packed-input guide](/journal/fg2-moirai-packed-sample-variate-identity-scaling/) provides related identity reasoning. Accept architecture equivalence before evaluating forecasting error. Correct tensor rank and a successful checkpoint load do not prove that the port preserved which axis represents historical evidence, which represents interacting variables and which represents future predictions.
