Commit Graph
15 Commits
Author SHA1 Message Date
darkpowerxo 18d5eb2d44 fix: improve PEFT device consistency and XReg output slicing
- Initialize LoRA parameters on the same device as the base linear layer
- Load adapter weights directly to the model device instead of hardcoded CPU
- Slice XReg linear regression outputs to match the specified sequence lengths

- Replace batch-wide covariate normalization with per-input normalization
  in create_covariate_matrix to prevent cross-input scale leakage.
- Refactor BatchedInContextXRegLinear.fit to solve ridge regression
  per instance rather than as a single global matrix solve, avoiding
  cross-contamination between batched inputs.
- Truncate JAX regression outputs to the actual train/test lengths
  after the padded matrix multiply, fixing shape mismatches for
  non-power-of-2 horizons (e.g. horizon=24 was returning 32 elements).
2026-04-08 21:43:52 -04:00
darkpowerxo ad192b7954 docs: update README — replace 'under construction' with completed status
- Add Apr. 2026 update entry for PEFT pipeline, unit tests, and community fixes
- Replace 'under construction' numbered list with checklist of completed items:
  Flax model, covariate support, docs/examples, PEFT pipeline, unit tests
2026-04-08 15:25:53 -04:00
darkpowerxo 54f5405b7d docs: fix swapped xreg_mode descriptions and typo in error message
Apply changes from PR #366 by @cj-wong:
- Correct xreg_mode docstring: descriptions for 'xreg + timesfm' and
  'timesfm + xreg' were swapped
- Fix 'covaraites' -> 'covariates' typo in error message
2026-04-08 14:20:40 -04:00
darkpowerxo 13a8eb2a25 ci: upgrade GitHub Actions to v6
Apply changes from PR #367 by @Copilot:
- actions/checkout v2 -> v6
- actions/setup-python v2 -> v6
2026-04-08 14:19:08 -04:00
darkpowerxo 30f28a1b1d fix: correct SKILL.md link in README
Apply changes from PR #390 by @amansinghbais:
- Fix link to point to the actual SKILL.md file instead of the directory
2026-04-08 14:18:15 -04:00
darkpowerxo 1bb44d5eef fix: respect batch_size in v1 data_loader when permute=False
Apply changes from PR #391 by @MarcoGorworworelli:
- Fix train_gen() to iterate in proper batch_size chunks instead of
  yielding all time series at once when permute=False
- Add test_data_loader.py to verify batch boundaries
2026-04-08 14:18:02 -04:00
darkpowerxo a63360a57c fix: per-input ridge regression to prevent data leakage in xreg
Apply changes from PR #393 by @MarcoGorworworelli:
- Normalize covariates per-input instead of batch-wide to prevent
  each input's result from depending on batch composition
- Fit separate ridge regressions per time series instead of a single
  batched regression, preventing cross-series data leakage
- Applied to both src/timesfm/utils/xreg_lib.py and v1/src/timesfm/xreg_lib.py
2026-04-08 14:15:44 -04:00
darkpowerxo c10494a4c5 test: add unit tests for configs, torch layers, utils, and base utils
Apply changes from PR #394 by @cj-wong:
- tests/__init__.py: package marker
- tests/test_base_utils.py: strip_leading_nans + linear_interpolation tests
- tests/test_configs.py: frozen dataclass, defaults, replace, equality tests
- tests/test_torch_layers.py: ResidualBlock, RMSNorm, RandomFourierFeatures
- tests/test_torch_utils.py: update_running_stats, revin, DecodeCache tests
2026-04-08 14:13:37 -04:00
darkpowerxo bc03b77e9e fix: correct 'complied' typo and replace print with logging
Apply changes from PR #396 by @shahrukhx01:
- Fix typo 'complied' -> 'compiled' in ForecastConfig docstrings
- Replace bare print() with logging.info() in load_checkpoint()
2026-04-08 14:09:14 -04:00
darkpowerxo b6ac2b3559 docs: add README for the PEFT fine-tuning pipeline
Covers quick start, Python API, CLI reference, adapter loading/merging,
architecture overview with parameter counts, and file layout.
2026-04-08 13:53:43 -04:00
darkpowerxo a67eeb2e7d feat: add CLI entry-point and launch script for PEFT fine-tuning
- finetune.py: argparse CLI with all config flags, CSV data loading,
  chronological train/val split, and full training pipeline
  Usage: python -m peft.finetune --data_path data.csv --value_col y
  Multi-GPU: torchrun --nproc_per_node=4 -m peft.finetune ...

- finetune.sh: env-var driven launch script for single/multi-GPU
  Usage: DATA_PATH=data.csv NUM_GPUS=4 bash peft/finetune.sh
2026-04-08 13:53:35 -04:00
darkpowerxo eca7ca3428 feat: add multi-GPU PEFT trainer for TimesFM 2.5
PEFTTrainer with production-grade training loop:
- PyTorch DDP multi-GPU via torchrun
- Mixed-precision training (fp16/bf16) with GradScaler
- Gradient checkpointing for long contexts
- Cosine-with-warmup LR schedule
- MSE loss + optional pinball quantile loss (9 channels)
- Early stopping on validation loss
- Adapter-only checkpointing (safetensors)
- W&B logging (rank-0 only)
- Differentiable training forward that replicates the 2.5
  patch -> RevIN -> transformer -> output-head -> un-RevIN path
2026-04-08 13:52:59 -04:00
darkpowerxo 9875d926fe feat: add TimeSeriesDataset for PEFT fine-tuning
Sliding-window dataset that produces (context, mask, target) tuples:
- Accepts list of arrays, long-format, or wide-format DataFrames
- Context length auto-rounded to multiple of patch_len (32)
- Left-pads short series with proper masking
- Configurable stride for window overlap
2026-04-08 13:52:19 -04:00
darkpowerxo 7357458e45 feat: add LoRA/DoRA adapter layers for TimesFM 2.5 (PyTorch)
Implement production-grade PEFT adapters targeting the 2.5 architecture:

- LoRALinear: low-rank A/B decomposition with scaling (alpha/rank)
- DoRALinear: weight-decomposed LoRA (magnitude + direction)
- inject_adapters(): freezes base weights, wraps target nn.Linear modules
  - Supports fused QKV (qkv_proj), attention output, and FFN layers
  - num_adapter_layers controls how many top layers get adapters (0=all)
  - target_modules selects 'all', 'attention', or 'ffn'
- merge_adapters(): folds adapter deltas back into base nn.Linear
- save/load_adapter_weights(): safetensors adapter-only checkpoints
- PEFTConfig dataclass with all hyperparameters

References:
  LoRA — https://arxiv.org/abs/2106.09685
  DoRA — https://arxiv.org/abs/2402.09353
2026-04-08 13:51:55 -04:00
darkpowerxo aa2b17f0b3 chore: update .gitignore for egg-info, uv.lock, peft_checkpoints
- Replace timesfm_jax.egg-info/ with generic *.egg-info/ glob
- Add uv.lock (lockfile is environment-specific)
- Add peft_checkpoints/ (training output directory)
2026-04-08 13:51:37 -04:00