---
title: 'HSTMixer: Hierarchical Spatio-Temporal MLP'
url: https://www.emergentmind.com/topics/hierarchical-spatio-temporal-mixer-hstmixer
type: topic
---

# HSTMixer: Hierarchical Spatio-Temporal MLP

The Hierarchical Spatio-Temporal Mixer (HSTMixer) is an all-MLP architecture for large-scale traffic forecasting, designed to efficiently and effectively capture multi-resolution dynamics over spatiotemporal graphs with up to tens of thousands of sensor nodes. HSTMixer’s architecture is built around the hierarchical composition of spatiotemporal mixing blocks and adaptive region-specific MLP parameterizations, enabling state-of-the-art predictive accuracy at linear computational complexity in both node and time dimensions [2512.07854].

## 1. Architectural Overview

HSTMixer is structured to address the prohibitive computational cost common to transformer and GNN-based spatiotemporal forecasting methods, replacing self-attention or message-passing with MLP-based mixing. Its design centers on two pillars:

- **Hierarchical Spatio-Temporal Mixing Blocks (ST-blocks):**
  - Each ST-block performs bottom-up (aggregative) compression of temporal and spatial features to coarser (macro) representations, followed by top-down propagation that reincorporates these macro features into finer (micro) resolutions.
  - The bottom-up path groups temporal input into windows and aggregates node-level features into regions at multiple spatial scales. The top-down path disseminates information from coarse to fine spatial and temporal resolutions.

- **Adaptive Region Mixer:**
  - At each spatial scale, an adaptive region mixer generates region-specific MLP weights from a small parameter pool, allowing semantically similar regions to share transformation matrices while preserving distinct treatments for dissimilar regions.

By stacking $L$ such ST-blocks, HSTMixer constructs a spatiotemporal feature pyramid over both time and space. Final forecast outputs are obtained by fusing all levels of the hierarchy.

## 2. Mathematical Formulation and Model Components

### Key Notation

- $N$: Number of nodes (sensors)
- $T$: Input history length
- $T'$: Forecast horizon
- $d$: Hidden feature dimension
- $L$: Number of ST-blocks
- $p$: Temporal window length
- $K$: Number of spatial scales
- $S_k < N$: Number of regions at scale $k$ ($k=1\ldots K$)

### Data Embedding

The raw time series $X \in \mathbb{R}^{N \times T}$ is embedded via
$$
E_{\rm tr} = \mathrm{FC}_{\rm tr}(X) \in \mathbb{R}^{N \times T \times d},
$$
accompanied by static spatial embeddings $E_{\rm static} \in \mathbb{R}^{N\times d}$ (Node2Vec) and learnable dynamic embeddings $E_{\rm dynamic} \in \mathbb{R}^{N\times d}$, summed to give $E_{\rm sp} = E_{\rm static} + E_{\rm dynamic}$. Temporal embeddings $E_{\rm day}$ and $E_{\rm week} \in \mathbb{R}^{T\times d}$ are aggregated as $E_{\rm te} = E_{\rm day} + E_{\rm week}$.

The input to the first ST-block is
$$
E_1 = E_{\rm tr} + \mathrm{broadcast}(E_{\rm sp}, T) + \mathrm{broadcast}(E_{\rm te}, N) \in \mathbb{R}^{N \times T \times d}.
$$

### Bottom-Up Aggregation

An ST-block’s input $E_l \in \mathbb{R}^{N \times T_{l-1} \times d}$ undergoes:

- **Temporal Aggregation Mixer:** Temporal frames are grouped into windows of length $p$. For block $l$,
$$
T_l = \lceil T_{l-1}/p \rceil, \qquad \widetilde E_l \in \mathbb{R}^{N \times T_l \times p \times d}.
$$
Two parallel window-mixing MLPs, each structured as FC$_1 \rightarrow$ activation $\rightarrow$ FC$_2$ with a positional embedding $E_{\rm pe}$, produce gated outputs:
$$
\widehat H_l^{(i)} = \mathrm{FC}_2^{(i)} \bigl(\phi(\mathrm{FC}_1^{(i)} (\widetilde E_l) + E_{\rm pe})\bigr), \qquad i=1,2,
$$
$$
H_l = \tanh\bigl(\widehat H_l^{(1)}\bigr) \odot \sigma\bigl(\widehat H_l^{(2)}\bigr) \in \mathbb{R}^{N \times T_l \times d}.
$$

- **Spatial Aggregation Path:** For each scale $k$, a learned FC aggregates node (spatial) features to coarser regions:
$$
H_{l,k} = \mathrm{FC}^{\mathrm{agg}}_k(H_l) \in \mathbb{R}^{S_k \times T_l \times d}, \qquad S_1 > S_2 > \ldots > S_K.
$$
Original (fine) node features $H_{l,g}=H_l$ are retained for node-level mixing.

### Adaptive Region Mixer

For $H_{l,k}$, region-scale features are transformed by region-specific MLPs whose weights are generated adaptively:

- Parameter pool (per scale $k$):
  - Keys: $K_{l,k} \in \mathbb{R}^{M_k \times T_l}$
  - Base weights: $V_{l,k} \in \mathbb{R}^{M_k \times T_l \times h}$

- Region-to-key similarity (over time):
$$
\mathrm{Sim} = \mathrm{Softmax}\bigl(H_{l,k} * K_{l,k}^\top\bigr) \in \mathbb{R}^{S_k \times d \times M_k},
$$
- Transformation matrices:
$$
W_{l,k} = \sum_{i=1}^{d} \mathrm{Sim}^{(i)} * V_{l,k}
$$
Per-region features $H_{l,k}^{(j)}$ are transformed using $W_{l,k}$ as the weights of a region-specific MLP:
$$
R_{l,k}^{(j)} = \bigl(H_{l,k}^{(j)}\bigr)^\top * W_{l,k,1}^{(j)},
$$
$$
H_{l,k}^{(j)} \coloneqq W_{l,k,2}^{(j)} * (R_{l,k}^{(j)})^\top.
$$
Outputs: $O_{l,k} \in \mathbb{R}^{S_k \times T_l \times d}$. Node-level outputs $O_{l,g}$ are produced by a standard (non-adaptive) MLP.

### Top-Down Propagation

Spatially, coarse region outputs $\{O_{l,k}\}$ are progressively merged into finer representations via:
$$
\widehat O_{l,K+1} = 0, \qquad \widehat O_{l,k} = \mathrm{FC}_k^{\mathrm{sp}}(O_{l,k} + \widehat O_{l,k+1}).
$$
Input to the next ST-block:
$$
E_{l+1} = \mathrm{FC}^{\mathrm{merge}}(O_{l,g}+\widehat O_{l,1}) + E_l.
$$

Temporally, final representations at multiple resolutions are successively upsampled:
$$
P_{L+1} = \mathrm{FC}^T(E_{L+1}), \qquad P_l = \mathrm{FC}^T(E_l + P_{l+1}), \qquad P = \mathrm{FC}^T(E_1 + P_2).
$$
Prediction is produced from $P$ and $E_{L+1}$ by a final stack of FC and activation layers.

## 3. Forward Pass Workflow

The following summarizes the complete forward computation:

```python
# Input X[N,T], forecast horizon T'
E_tr = FC_tr(X)
E_sp = E_static + E_dynamic      # Broadcasted to N×T×d
E_te = E_day + E_week            # Broadcasted to N×T×d
E1 = E_tr + broadcast(E_sp) + broadcast(E_te)
for l in 1...L:
    T_l = ceil(time_len(E_l)/p)
    H_l = TemporalMixer(E_l, p)
    for k in 1...K:
        H_l_k = FC_agg_k(H_l)
    H_l_g = H_l
    O_l_g = NodeMix(H_l_g)
    for k in 1...K:
        O_l_k = RegionMixAdapt(H_l_k, Kpool_k, Vpool_k)
    widehat_O_l_K+1 = 0
    for k = K...1:
        widehat_O_l_k = FC_sp_k(O_l_k + widehat_O_l_k+1)
    E_{l+1} = FC_merge(O_l_g + widehat_O_l_1) + E_l
P_{L+1} = FC_time(E_{L+1})
for l = L...1:
    P_l = FC_time(E_l + P_{l+1})
P = FC_time(E1 + P_2)
Y_hat = FC3(phi(FC2(P + FC1(E_{L+1}))))
# Output: Y_hat[N, T']
```
This structure allows efficient and scalable spatiotemporal forecasting aligned with the O(N·T) computational goal.

## 4. Computational Complexity and Scalability

Each fully connected operation within the mixing MLPs requires either $O(N \cdot T \cdot d \cdot h)$ or $O(N \cdot T \cdot h \cdot d)$ per block, where $h$ is the intermediate hidden dimension. The adaptive region mixer introduces an additional cost of $O(M_k \cdot d \cdot S_k \cdot T_l)$ per scale $k$ for the similarity computation and $O(d \cdot h \cdot S_k \cdot T_l)$ for application of transformation weights.

Summed over all blocks and scales, total complexity is
$$
O(L \cdot K \cdot M \cdot d \cdot h \cdot N \cdot T),
$$
assuming uniform $M_k = M$ and $\sum_k S_k \lesssim N$. This scaling is strictly linear in the number of nodes $N$ and input length $T$, in contrast to the quadratic $O(N^2T^2)$ complexity characteristic of transformer attention or $O(E \cdot d)$ in full-graph GNN propagation. On the large-scale CA dataset ($N \approx 8600$), HSTMixer completed training within hours on a 48 GB GPU, whereas transformer or GNN methods failed due to either memory or time constraints.

## 5. Experimental Evaluation and Ablative Insights

HSTMixer was evaluated on four real-world large-scale datasets: SD ($N=716$), GBA ($N=2352$), GLA ($N=3834$), and CA ($N=8600$), all with 15-minute intervals, using a 12-interval input for a 12-interval forecast.

### Comparative Performance

| Dataset | HSTMixer (MAE / RMSE / MAPE) | Next Best Method           | Metrics             |
|---------|------------------------------|----------------------------|---------------------|
| SD      | 14.80 / 25.06 / 9.22         | DGCRN                      | 15.50 / 25.90 / 9.93|
| GBA     | 17.73 / 30.67 / 12.71        | LSTNN                      | 18.28 / 31.59 / 12.99|
| GLA     | 16.45 / 28.03 / 9.53         | LSTNN                      | 17.22 / 29.11 / 9.65|
| CA      | 15.55 / 27.05 / 10.55        | LSTNN                      | 16.48 / 28.24 / 10.90|

Average improvements over previous best were MAE ↓4.41%, RMSE ↓3.15%, and MAPE ↓2.03%. Ablation studies indicate that removing any primary component (adaptive mixer, temporal or spatial hierarchies, or top-down propagations) leads to significant increases in MAE. On GBA: disabling the adaptive mixer, temporal hierarchy, spatial hierarchy, temporal propagation, or spatial propagation increased MAE by 1.2%, 2.8%, 3.1%, 2.5%, and 2.9% respectively.

Regarding efficiency, HSTMixer trained on GBA in approximately 4.5 hours (compared to 2–3 hours for smaller MLP baselines), with inference requiring ≈30 seconds per epoch.

## 6. Significance and Practical Implications

HSTMixer demonstrates that scalable, all-MLP methods with hierarchical and adaptive mixing mechanisms can achieve SOTA accuracy for large-scale traffic forecasting under real-world constraints of graph size and temporal range. Its linear computational profile and memory footprint enable deployment on infrastructure unattainable by transformer or traditional GNN approaches, suggesting practical utility for urban-scale traffic systems where computational efficiency is critical. The hierarchical bidirectional fusion of temporal and spatial context, along with adaptive region parametrization, is empirically validated as essential for accurate forecasting at scale [2512.07854].

Source: https://www.emergentmind.com/topics/hierarchical-spatio-temporal-mixer-hstmixer