Metadata-Version: 2.1
Name: q-timesfm
Version: 0.1.0
Summary: Tools for testing quantum and classical adapter heads in time-series forecasting experiments
Author: Adi
License: MIT License
        
        Copyright (c) 2026 Adi
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/aidsuu/q-timesfm
Project-URL: Repository, https://github.com/aidsuu/q-timesfm
Project-URL: Issues, https://github.com/aidsuu/q-timesfm/issues
Keywords: time-series,forecasting,quantum-machine-learning,timesfm,pennylane
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.0
Requires-Dist: torch>=2.0
Requires-Dist: matplotlib>=3.8
Requires-Dist: pennylane>=0.40
Requires-Dist: safetensors>=0.5.3
Requires-Dist: huggingface_hub>=0.23.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Requires-Dist: pyyaml>=6; extra == "dev"
Provides-Extra: lightning
Requires-Dist: pennylane-lightning>=0.40; extra == "lightning"
Provides-Extra: yaml
Requires-Dist: pyyaml>=6; extra == "yaml"

# Q-TimesFM

Q-TimesFM is a small research package for testing hybrid quantum-classical
adapter heads on top of frozen time-series forecasting backbones.

The current code focuses on practical experiments: loading a CSV, building
sliding windows, training a lightweight adapter head, and comparing it with a
matched classical bottleneck. It is not a replacement for TimesFM, and it does
not make any claim of quantum advantage.

## Status

This is an alpha research prototype. APIs may change while the experiments are
being tightened up.

## Installation

After the package is published:

```bash
pip install q-timesfm
```

For local development:

```bash
pip install -e ".[dev,lightning,yaml]"
```

The `lightning` extra installs PennyLane Lightning support. GPU execution still
depends on a compatible NVIDIA driver, CUDA, and cuQuantum stack.

## Draw the Quantum Circuit

```bash
q-timesfm-draw-circuit \
  --n-qubits 6 \
  --quantum-depth 2 \
  --output circuit.png
```

Use `--pennylane-device lightning.qubit` when PennyLane Lightning is available.

## Train on a CSV File

Single-series example:

```bash
q-timesfm-train \
  --data-source generic_csv \
  --csv-path your.csv \
  --target-col value \
  --time-col date \
  --context 32 \
  --horizon 8 \
  --head-type classical_bottleneck \
  --epochs 1 \
  --batch-size 8 \
  --backend torch
```

Grouped time series are supported with `--group-col`. Windows are built within
each group and never cross group boundaries:

```bash
q-timesfm-train \
  --data-source generic_csv \
  --csv-path your.csv \
  --target-col value \
  --time-col date \
  --group-col series_id \
  --context 32 \
  --horizon 8 \
  --head-type quantum \
  --backend pennylane \
  --pennylane-device lightning.qubit
```

## CSV Format

Minimum single-series format:

```csv
date,value
2020-01-01,1.0
2020-01-02,1.2
```

Grouped format:

```csv
series_id,date,value
A,2020-01-01,1.0
A,2020-01-02,1.2
B,2020-01-01,5.0
```

## TimesFM Checkpoints

Pretrained TimesFM checkpoints are not bundled with this package. If you use the
TimesFM adapter wrapper, point the code to a local checkpoint and make sure the
upstream TimesFM package or source tree is available in your environment.

## Python API

```python
from q_timesfm import make_generic_dataset, train_adapter

X, y, meta, info = make_generic_dataset(
    "your.csv",
    target_col="value",
    time_col="date",
    context=32,
    horizon=8,
)

result = train_adapter(
    data_source="generic_csv",
    csv_path="your.csv",
    target_col="value",
    time_col="date",
    head_type="classical_bottleneck",
    context=32,
    horizon=8,
    epochs=1,
    backend="torch",
)
```

## Notes

- The package is intended for controlled experiments, not production forecasts.
- Quantum results should be compared against matched classical baselines.
- Report negative results; they are useful for this line of work.
- Do not interpret early runs as evidence of quantum advantage.
