Metadata-Version: 2.4
Name: qara-ml
Version: 0.1.0
Summary: ML plugin for qara — GPU metrics and loss tracking
License: MIT License
        
        Copyright (c) 2026 Yerassyl Kenes
        
        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.
License-File: LICENSE
Keywords: gpu,ml,monitor,nvidia,pynvml,qara,training
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.11
Requires-Dist: nvidia-ml-py>=12.0
Requires-Dist: qara>=0.1.0
Description-Content-Type: text/markdown

# qara-ml

GPU metrics and training loss tracking plugin for [qara](https://github.com/warptengood/qara).

## Install

```bash
pip install qara-ml
```

Requires an NVIDIA GPU and `nvidia-ml-py` (installed automatically).

## Setup

Enable the plugin in `~/.config/qara/config.toml`:

```toml
[plugins]
enabled = ["ml"]

[plugins.ml]
gpu_poll_interval_seconds = 5   # how often to sample GPU metrics
loss_pattern = ""               # custom regex, leave empty for default
```

## What it does

After each watched process finishes, qara sends an additional Telegram summary:

```
GPU summary:
  Peak VRAM: 18204 MB / 24576 MB
  Avg GPU util: 94%
  Peak temp: 78°C

Training summary:
  Final loss: 0.0342
  Best loss: 0.0298 (step 4200)
```

**GPU metrics** — polls all NVIDIA GPUs every `gpu_poll_interval_seconds` and reports peak VRAM usage, average utilisation, and peak temperature over the lifetime of the process.

**Loss tracking** — scans stdout for loss values matching common patterns like `loss=0.123`, `train_loss: 0.456`, `Loss = 0.789`. Reports the final loss and the best (lowest) loss with its step number.

### Custom loss regex

If your training framework uses a different format, set a custom pattern:

```toml
[plugins.ml]
loss_pattern = "val_loss: ([0-9.]+)"
```

## Requirements

- `qara >= 0.1.0`
- NVIDIA GPU with drivers installed
- `nvidia-ml-py >= 12.0` (installed automatically)

If no NVIDIA GPU is detected, the plugin loads silently and loss tracking still works — only GPU metrics are skipped.

## License

MIT — see [LICENSE](LICENSE)
