개요
TimesFM은 Google 연구팀이 개발한 디코더 기반의 사전 학습된 시계열 파운데이션 모델로, 긴 컨텍스트와 연속 분위수 예측을 지원하며 PyTorch 및 Flax 버전을 제공합니다.
README 미리보기
# TimesFM\n\nTimesFM (Time Series Foundation Model) is a pretrained time-series foundation\nmodel developed by Google Research for time-series forecasting.\n\n* Paper:\n [A decoder-only foundation model for time-series forecasting](https://arxiv.org/abs/2310.10688),\n ICML 2024.\n* All checkpoints:\n [TimesFM Hugging Face Collection](https://huggingface.co/collections/google/timesfm-release-66e4be5fdb56e960c1e482a6).\n* [Google Research blog](https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/).\n* TimesFM in Google 1P Products:\n * [BigQuery ML](https://cloud.google.com/bigquery/docs/timesfm-model): Enterprise level SQL queries for scalability and reliability.\n * [Google Sheets](https://workspaceupdates.googleblog.com/2026/02/forecast-data-in-connected-sheets-BigQueryML-TimesFM.html): For your daily spreadsheet. \n * [Vertex Model Garden](https://pantheon.corp.google.com/vertex-ai/publishers/google/model-garden/timesfm): Dockerized endpoint for agentic calling.\n\nThis open version is not an officially supported Google product.\n\n**Latest Model Version:** TimesFM 2.5\n\n**Archived Model Versions:**\n\n- 1.0 and 2.0: relevant code archived in the sub directory `v1`. You can `pip\n install timesfm==1.3.0` to install an older version of this package to load\n them.\n## Update - June 5, 2026\n\nUpdated PyPI to `timesfm=2.0.0`. See [Install](https://github.com/google-research/timesfm#from-pypi).\n\n## Update - Apr. 9, 2026\n\nAdded fine-tuning example using HuggingFace Transformers + PEFT (LoRA) — see\n[`timesfm-forecasting/examples/finetuning/`](timesfm-forecasting/examples/finetuning/).\nAlso added unit tests (`tests/`) and incorporated several community fixes.\n\nShoutout to [@kashif](https://github.com/kashif) and [@darkpowerxo](https://github.com/darkpowerxo). \n\n## Update - Mar. 19, 2026\n\nHuge shoutout to [@borealBytes](https://github.com/borealBytes) for adding the support for [AGE
FAQ (4)
문제 해결왜 TimesFM PyTorch에서 torch_compile=True가 아무런 효과가 없으며, torch.compile이 추론 속도를 높이도록 하려면 어떻게 해야 하나요?
이 no-op은 load_checkpoint 내부의 self = torch.compile(self) 때문에 발생합니다: self는 지역 변수이므로, 이를 재바인딩해도 from_pretrained가 반환하는 모델 객체는 변경되지 않습니다.
PR #459의 수정 사항을 적용하거나, 로딩 후 forward를 직접 컴파일하세요:
model = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
"google/timesfm-2.5-200m-pytorch"
)
model.model.forward = torch.compile(model.model.forward)
마찬가지로, timesfm_2p5_torch.py에서 효과가 없는 줄을 다음으로 교체하세요:
self.model.forward = torch.compile(self.model.forward)
KV-cache 슬라이스 할당은 여전히 그래프 브레이크를 유발하지만, attention과 MLP matmul이 컴파일되므로 추론이 더 빨라집니다. A100에서 batch=64, context=512, horizon=128 조건에서 레이턴시가 108.8 ms에서 73.7 ms로 감소했습니다 (1.48x). 재바인딩을 수정한 후 전체 모듈을 컴파일해도 보고된 벤치마크에서는 측정 가능한 속도 향상이 없었습니다.
문제 해결왜 TimesFM의 `xreg_mode`가 `xreg + timesfm`와 `timesfm + xreg`에 대해 docstring과 반대로 동작하나요?
해당 구현에서는 docstring이 반대로 되어 있습니다. 문서가 아닌 코드에 따라 모드를 사용하세요:
- 먼저 타깃에 xreg를 피팅한 다음 TimesFM으로 잔차를 예측하려면 다음을 사용하세요:
xreg_mode="xreg + timesfm"- 먼저 TimesFM 예측을 생성한 다음 그 잔차에 xreg를 피팅하려면 다음을 사용하세요:
xreg_mode="timesfm + xreg"
이는 L488–L494 부근의 분기에서 확인할 수 있습니다. timesfm + xreg는 max(0, input_len - self.input_patch_len)을 사용하며 "For fitting residuals"라는 주석이 달려 있는 반면, xreg + timesfm은 input_len을 사용합니다. docstring이 수정될 때까지 문서에 기재된 설명은 서로 바뀐 것으로 간주하세요.
문제 해결TimesFM 2.5 PyTorch from_pretrained 오류 수정 방법: unexpected keyword argument 'proxies' 및 load_checkpoint NotImplementedError?
이 문제는 timesfm PR #435에서 수정되었습니다. 해당 수정 사항이 포함된 릴리스로 업그레이드하거나 최신 소스를 설치하세요:
pip install -U git+https://github.com/google-research/timesfm.git
그런 다음 다시 시도하세요:
import timesfm
tfm = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
"google/timesfm-2.5-200m-pytorch"
)
업그레이드할 수 없는 경우, 이전 버전의 Hub 클라이언트로 임시 고정하세요:
pip install "huggingface_hub<0.34"
# 예를 들어:
pip install huggingface_hub==0.33.5
이는 최신 transformers/accelerate 릴리스와 충돌할 수 있습니다. 영향을 받는 timesfm 버전에서는 PyTorch 서브클래스가 NotImplementedError를 발생시키므로 해결 방법으로 load_checkpoint(local_path)를 사용하지 마세요. 대신 패치가 적용된 timesfm 빌드를 사용하세요. 소스 수준의 수정 방법은 모델 생성자가 새로운 Mixin kwargs를 받아들이고 무시하도록 하는 것입니다. 예: def __init__(self, config, **_ignored):.
how_toPyTorch 없이 Apple Silicon에서 TimesFM 3.0을 실행하려면 어떻게 해야 하나요?
MLX 백엔드를 사용하세요. 이 백엔드는 PR #476에서 src/timesfm3/mlx/ 아래에 제공되며, 기존 PyTorch 백엔드는 src/timesfm3/torch/ 아래에 그대로 유지됩니다. MLX 버전은 동일한 timesfm3_forecaster 인터페이스를 노출하고, 동일한 체크포인트를 로드하며, PyTorch 출력과 최대 절대 오차 약 1e-6 수준으로 일치합니다. 독립 실행형 구현은 https://github.com/rachittshah/mlx-tsfm에서 확인할 수 있습니다.
빠른 설정:
python -m pip install -U mlx
git clone https://github.com/rachittshah/mlx-tsfm.git
cd mlx-tsfm
pytest tests/test_timesfm.py
PR #476이 적용된 TimesFM 리포지토리를 사용할 때는 Torch 모듈 대신 timesfm3.mlx.timesfm3_forecaster에서 forecaster를 임포트하고, 동일한 초기화 및 예측 호출을 사용하세요. M4 Max에서는 330M 모델이 단일 예측당 약 20 ms가 소요되며, 배치 처리 시 약 475 forecasts/second에 도달한다고 보고되었습니다.