File size: 4,929 Bytes
ff4becd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Vendored libraries — local patches

This file enumerates every local modification on top of the upstream
`methods/_vendored/{tslib,moderntcn}/` source. Per plan §7b #6, additions
must be appended (not silently merged) so the diff against upstream is
auditable.

Source revisions:

- `tslib/`     — https://github.com/thuml/Time-Series-Library (main; MIT — see `LICENSE-tslib`)
- `moderntcn/` — https://github.com/luodhhh/ModernTCN          (main; MIT — see `LICENSE-moderntcn`)

> **License note:** Plan §7 lists ModernTCN as Apache 2.0; verification
> against the upstream `LICENSE` file (fetched 2026-05-04) confirms it
> is MIT. The MIT text is reproduced verbatim under
> `LICENSE-moderntcn`.

## Patches in `methods/_vendored/`

### TSLib (`tslib/`)

No source-level patches. The vendored snapshot is byte-identical to the
upstream `models/{DLinear,iTransformer,PatchTST}.py` and the supporting
`layers/`. The Method-contract glue — namespace-style configs, `(B, L, F)`
input shape, target-variate selection — lives in `methods/sequence.py`
inside the `_TSLibWrapper` class (a thin `nn.Module` adapter, **not** a
modification to the vendored source).

### ModernTCN (`moderntcn/`)

No source-level patches. The vendored snapshot is byte-identical to the
upstream `models/{ModernTCN,ModernTCN_Layer}.py` and `layers/RevIN.py`.
The Method-contract glue lives in `methods/sequence.py` inside the
`_ModernTCNWrapper` class (same pattern as `_TSLibWrapper`; constructs
the four-stage `dims`/`dw_dims` lists ModernTCN expects even when only
one stage is in use).

## Patches that live outside `methods/_vendored/` (referenced for completeness)

These patches operate against installed Python packages — not vendored
source — but are documented here because they are part of the same
"local modifications to upstream behaviour" surface the auditor cares
about.

### Moirai2 — gluonts 0.16 forward-shape wrap

- **Where:** `methods/tsfm.py`
- **What:** Wraps `Moirai2Forecast.forward` so it returns
  `((preds.transpose(1, 2),), None, None)`, the shape
  `gluonts==0.16.QuantileForecastGenerator` expects.
- **Why:** `uni2ts` ships a forward signature aligned with gluonts < 0.16;
  the runtime crash this papers over is a pure interface mismatch, not a
  semantic change.
- **Idempotency:** guarded by the
  `_macrolens_gluonts016_wrap_applied` sentinel attribute on the
  `Moirai2Forecast` class so repeated method instantiations do not stack
  wrappers.

### Sundial — not vendored, removed from the panel

- `transformers >= 4.45` is incompatible with the upstream Sundial
  checkpoint's custom forward; rather than maintain a deeper patch we
  removed Sundial from `experiments/panel.py` (see comment there).
- This entry is preserved as a trail for future re-evaluation against a
  newer upstream release.

## Method-contract wrappers (not modifications, but worth documenting)

- **`_TSLibWrapper`** — `methods/sequence.py`. Thin `nn.Module` adapter
  exposing the vendored TSLib models via the unified `Method` contract.
  Accepts `(B, L, F)` and emits the target variate at index
  `self.target_idx` (`close` price column for T1; index 0 for T4).
- **`_ModernTCNWrapper`** — `methods/sequence.py`. Same pattern for the
  vendored ModernTCN model. Constructs the four-stage `dims` and
  `dw_dims` lists ModernTCN expects even when only one stage is in
  active use.

## Append-only log

Future patches MUST be appended below this header (with date and a one-
line rationale). Silent merges into the sections above are prohibited
by plan §7b #6.

<!-- new patches go below -->

### 2026-05-05 — ITFormer (`itformer/`) — adapter for authors' CLI

Added `methods/_vendored/itformer/` with two files:

- `__init__.py` — re-exports `ITFormerEngine`.
- `engine.py` — Pythonic wrapper that drives the authors' `inference.py`
  CLI verbatim. Locates an existing clone at
  `baselines/_vendor/itformer/` (preferred; legacy clone, 3.5 MB) or
  `methods/_vendored/itformer/upstream/` (clones on demand). No
  source-level patches to the upstream tree — it is invoked as an opaque
  CLI per the authors' `accelerate launch ... inference.py --config
  ... --model_checkpoint ...` recipe.

Source revision:

- Upstream URL: `https://github.com/Pandalin98/ITFormer-ICML25` (`main`,
  MIT — see upstream `LICENSE`). Verified against
  `https://huggingface.co/Pandalin98/ITFormer-ICML25` model card on
  2026-05-05.

The Method-contract glue lives in `methods/llm_ts_reason.py::ITFormer`
(per-task `_predict_*` overrides that batch all prompts into one
HDF5+JSONL+YAML triple, subprocess-call `inference.py` once, and route
each generated `prediction` string through the same parsers the
chat-complete path uses). Documented protocol mismatch (zero-padded
time-series prefix for non-T1 tasks; all prompts tagged `stage='1'`) is
disclosed in DRAFT.md Family 6 and in the `ITFormer` class docstring.