dqntrain
Headless, config-driven fine-tuning for LLMs on cloud GPUs.
A programmatic fine-tuning toolkit inspired by Unsloth Studio's workflow, built for headless environments like Kaggle, Google Colab, and remote servers. No GUI required — just YAML/JSON recipes, clean Python APIs, and automatic GPU-aware defaults.
Quick Start (Kaggle / Colab Notebook)
1. Install
%%capture
!pip install dqntrain
2. Define a Config
from dqntrain import auto_config_for_model
config = auto_config_for_model("unsloth/Qwen2.5-7B-Instruct-bnb-4bit")
config.training.num_train_epochs = 1
config.dataset.path = "yahma/alpaca-cleaned"
config.export.formats = ["lora", "gguf"]
3. Train
from dqntrain import (
ModelLoader, DatasetBuilder, DQNTrainer,
TrainingMonitor, ModelExporter
)
loader = ModelLoader(config)
model, tokenizer = loader.load()
model = loader.apply_lora()
dataset = DatasetBuilder(config).build()
monitor = TrainingMonitor()
trainer = DQNTrainer(config, monitor=monitor)
trainer.create_trainer(model, tokenizer, dataset)
trainer.train()
monitor.plot()
ModelExporter(config).export(model, tokenizer)
That's it. The entire pipeline in ~15 lines.
Features
| Capability | Description |
|---|---|
| Model presets | auto_config_for_model() detects your GPU and sets 4-bit, batch size, seq length |
| LoRA / QLoRA | LoRAConfig dataclass or YAML recipes |
| Dataset formats | JSON, JSONL, CSV, HuggingFace datasets, conversations — auto-detected |
| Live monitoring | Loss/LR/GPU tracking with matplotlib plots + JSONL logs |
| Multi-format export | LoRA, merged 16-bit, GGUF, Ollama Modelfile — in one call |
| Headless-first | No browser, no desktop UI — built for notebooks and servers |
Project Structure
dqntrain/
├── dqntrain/
│ ├── config.py # YAML/JSON recipes + auto GPU presets
│ ├── models.py # Model loader + LoRA applier
│ ├── data.py # Dataset builder (JSON/CSV/HF/conversations)
│ ├── trainer.py # SFTTrainer wrapper with cloud paths
│ ├── observability.py # Live metrics, plots, JSONL logging
│ ├── export.py # GGUF, merged, Ollama, Hub push
│ └── utils.py # Environment detection + GPU info
├── configs/
│ ├── quick_lora.yaml # T4-optimized 4-bit recipe
│ └── full_finetune.yaml # P100+ 16-bit recipe
└── notebooks/
└── kaggle_template.ipynb # Ready-to-run Kaggle notebook
Config Recipes
Save a YAML file and pass it to load_config():
model:
name: "unsloth/Qwen2.5-7B-Instruct-bnb-4bit"
max_seq_length: 2048
load_in_4bit: true
lora:
r: 16
lora_alpha: 32
target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]
training:
num_train_epochs: 1
per_device_train_batch_size: 1
gradient_accumulation_steps: 4
learning_rate: 2.0e-4
output_dir: "./outputs"
dataset:
path: "yahma/alpaca-cleaned"
instruction_column: "instruction"
response_column: "output"
export:
formats: [lora, gguf]
quantization: "q4_k_m"
Supported Dataset Formats
DatasetBuilder auto-detects:
- HuggingFace datasets (
dataset.path = "yahma/alpaca-cleaned") - JSON / JSONL files with
instruction/responseorconversationsarrays - CSV files with text columns
- In-memory lists of dicts
GPU-Aware Defaults
auto_config_for_model() inspects your GPU and adjusts:
load_in_4bit— forced on for T4 (15 GB), optional on P100/V100per_device_train_batch_size— smaller for big modelsmax_seq_length— capped to fit VRAMgradient_accumulation_steps— scaled up to maintain effective batch size
Export Formats
ModelExporter can produce any combination of:
lora— LoRA adapter (smallest, fastest to save)merged/safetensors— Full 16-bit merged modelgguf— Quantized GGUF for llama.cpp / Ollamaollama—Modelfileready forollama create
CLI Usage
# Install deps
pip install dqntrain
# Run from a config file
dqntrain --config configs/quick_lora.yaml
# Override model and dataset
dqntrain --model unsloth/Phi-4 --dataset my_data.jsonl --epochs 2
Kaggle-Specific Tips
- Enable Internet in notebook settings for
pip installand HF downloads. - Persist outputs — everything in
/kaggle/workingsurvives the session. - Save Versions — click "Save Version" → "Run" to execute headlessly. Logs still write to
/kaggle/working. - Dataset inputs — upload custom JSON/CSV via Kaggle Datasets, then reference them with
config.dataset.path = "/kaggle/input/your-dataset/file.json".
License
MIT. This package depends on Unsloth (Apache 2.0 core), TRL, and Transformers.
Metadata
Release files for dqntrain 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dqntrain-0.1.3.tar.gz | 19.0 kB | Without provenance | Details for dqntrain-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dqntrain-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for dqntrain-0.1.3-py3-none-any.whl |
Total release size: 39.6 kB
Release files / dqntrain-0.1.3.tar.gz
| Download URL | dqntrain-0.1.3.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae47bf2b24fc2035c66775effa54cbf6df44087b25b1437d22ecf9821fc69a42
|
|
BLAKE2b-256 checksum How to use checksums |
8000f7d3a70f7482b68173764aaf38dd75f4e91ce9b3836435039ac158cff78b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / dqntrain-0.1.3-py3-none-any.whl
| Download URL | dqntrain-0.1.3-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b6e859b430102df5b76137239b33b4c793cb2f56769c095f77b498e9a1591e0
|
|
BLAKE2b-256 checksum How to use checksums |
7a7e102ec82dd79b72a321e17e1cfd23808c7a01b24000754b248ed52ec60e72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for dqntrain 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.