MTST Forecasting
A configurable Multi-Resolution Time Series Transformer (MTST) implemented in PyTorch for forecasting. This is an independent implementation inspired by research on multi-resolution time-series Transformers, including work presented at AISTATS 2024. See the Citation and attribution section before publishing a research claim.
The package provides three parallel temporal-resolution branches, configurable forecasting output shapes, relative positional attention, and a simple training/inference API.
Installation
After publication to PyPI:
pip install mtst-forecasting
For local development from this repository:
python -m pip install -e ".[dev]"
Quick start
import torch
from mtst import MTSTForecaster
# User-prepared windows: samples x timesteps x features
X = torch.randn(100, 24, 8)
y = torch.randn(100, 24)
model = MTSTForecaster(
input_dim=8,
output_shape=(24,),
embed_dim=64,
heads=8,
n_layers=2,
dropout=0.1,
resolutions=(1, 2, 4),
positional_encoding="relative",
)
history = model.fit(
X, y,
epochs=10,
batch_size=16,
lr=5e-4,
loss="mse",
device="auto",
)
pred = model.predict(X[:5]) # torch.Tensor, shape (5, 24), on CPU
model.save("mtst_model.pt")
restored = MTSTForecaster.load("mtst_model.pt")
device="auto" chooses CUDA, Apple MPS, or CPU depending on availability.
Shapes and multi-resolution settings
- Input:
(batch, sequence_length, input_dim). - Output:
(batch, *output_shape); supported examples are(24,),(24, 3)and(24, 3, 2). resolutions=(1, 2, 4)selects every 1st, 2nd and 4th timestamp for separate encoder branches. These are sampling strides, not trainable token aggregators.positional_encoding="relative"or"both"(relative attention plus absolute position encoding).
Training losses
Available choices: "mse", "mae", "huber", and "r2boosted".
history = model.fit(
X, y,
loss="r2boosted",
loss_kwargs={"alpha": 1.0, "beta": 0.8, "gamma": 0.2, "time_dim": 1},
epochs=10,
)
r2boosted combines a level error term, differences along the chosen temporal axis, and a correlation-based term. time_dim=1 by default, where axis 0 is the batch dimension. You can optionally supply mask with the same shape as y to exclude invalid positions. Standard losses do not need time_dim.
Responsibilities and limitations
The library does not create features, perform scaling, select time windows, or split datasets. Prepare your training targets and inputs yourself, avoid look-ahead leakage, and save any preprocessing scalers separately. fit trains the model in mini-batches; predict is inference-only. The standard PyTorch interface model(X) is also available.
Saved checkpoints contain model configuration and learned weights, not the optimizer state or preprocessing transforms. Only load checkpoints from trusted sources.
Development and tests
python -m pip install -e ".[dev]"
python -m pytest -q
python -m build
python -m twine check dist/*
Citation and attribution
This library is an independent PyTorch implementation inspired by multi-resolution forecasting research. Add the exact bibliographic reference to the relevant AISTATS 2024 paper and clearly document differences before publication. The repository is not claimed to be the authors' official implementation.
Package Information
MTST Forecasting is an open-source PyTorch library for configurable multi-resolution time series forecasting.
You can retrieve the installed package version and author directly in Python:
import mtst
print(mtst.__version__)
print(mtst.__author__)
Additional package metadata can be accessed using:
from importlib.metadata import metadata
info = metadata("mtst-forecasting")
print("Package:", info["Name"])
print("Version:", info["Version"])
print("Author:", info["Author"])
For source code, documentation, and contributions, visit the GitHub repository linked in the package metadata.
License
MIT — see LICENSE.
Metadata
Release files for mtst-forecasting 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mtst_forecasting-0.1.1.tar.gz | 15.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mtst_forecasting-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.3 kB
Release files / mtst_forecasting-0.1.1.tar.gz
| Download URL | mtst_forecasting-0.1.1.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b3afcf31b9e9ef34f876bc574beea875db63cbb629c757476da385403d14318
|
|
BLAKE2b-256 checksum How to use checksums |
b16adf17695339260fbd7fcbde9f99b9c6b4f256447ad8055a9f953f32b95a5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / mtst_forecasting-0.1.1-py3-none-any.whl
| Download URL | mtst_forecasting-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f57e2907f6200d70509619cf52e50cc19edb85ed5843f59bb4618225b5d96a78
|
|
BLAKE2b-256 checksum How to use checksums |
c6ca8cc2ecc2ad98454232637b3aac130fa709015552cf5ca48604cded551022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for mtst-forecasting 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mtst_forecasting-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.