Skip to main content

Decant — A minimal DSL for AI model training & hosting with multi-GPU QLoRA support

Project description

Decant DSL

A minimal language for AI model training & hosting. Turn 300+ lines of boilerplate into ~20 lines of code.

Decant is a domain-specific language that lets you specify everything needed to train, fine-tune, or host an LLM in a single readable file. It compiles to VRAM-optimized Python using Unsloth, QLoRA, and Hugging Face Transformers — so anyone with a GPU can train their own AI.

# Minimal example: fine-tune Llama 3.2 3B with QLoRA + YaRN
purpose = "fine-tune"
model.base = "unsloth/Llama-3.2-3B-Instruct-bnb-4bit"
train.precision = "4bit"
train.compression = "qlora"
train.lora.rank = 16
dataset.path = "databricks/databricks-dolly-15k"
model.context = 2048
model.context_extend = 4096
model.context_method = "yarn"
train.steps = 100
train.batch.size = 2
train.learning.rate = 2e-4

Quick Start

# Install
pip install decant-dsl

# Validate your config
decant check train.nx

# Generate Python training code (don't run it)
decant build train.nx -o train.py

# Generate and run training
decant run train.nx

Language Reference

Purpose

purpose = "train"       # Train from scratch
purpose = "fine-tune"   # Fine-tune an existing model (recommended)
purpose = "host"        # Load and optimize model for inference only

Model

model.base = "org/model-name"
model.source = "huggingface"  # or "local"
model.local_path = "/path/to/model"  # if source is local
model.context = 2048
model.context_extend = 4096
model.context_method = "yarn"  # yarn, ntk, linear, none
model.rope.theta = 1000000

Training

# Precision & Compression
train.precision = "4bit"        # 4bit, 8bit, 16bit, 32bit
train.compression = "qlora"     # qlora, lora, full, none

# LoRA / QLoRA
train.lora.rank = 16            # 1-512
train.lora.alpha = 16
train.lora.dropout = 0.0
train.lora.targets = "all"      # all, attention, mlp, custom

# Hyper-parameters
train.steps = 100
train.epochs = 0
train.batch.size = 2
train.gradient.accumulation = 4
train.learning.rate = 2e-4
train.warmup.steps = 5
train.optimizer = "adamw_8bit"
train.scheduler = "cosine"
train.weight.decay = 0.0
train.max.grad.norm = 1.0
train.seed = 42

Dataset

dataset.path = "org/dataset-name"
dataset.source = "huggingface"  # or "local"
dataset.format = "alpaca"       # alpaca, chat, text, sharegpt, json
dataset.split = "train"
dataset.text.field = "text"
dataset.local_path = "/path/to/data.json"

Output

output.dir = "./outputs"
output.name = "my-finetuned-model"
output.push.to.hub = false
output.hub.id = "my-org/my-model"

Examples

See the examples/ directory:

  • train-llama3-8b.nx — Fine-tune Llama 3.2 3B on Dolly-15k with QLoRA + YaRN
  • host-mistral.nx — Host Mistral 7B with 4-bit quantization and 32K context
  • train-local-dataset.nx — Train using a local dataset file

Error Messages

Decant translates cryptic Python/CUDA errors into plain English:

Error What You'll See
CUDA OOM "Your GPU ran out of VRAM — lower batch size or precision"
Module not found "Missing Python package — run pip install"
Network error "Could not download — check your internet connection"
File not found "Resource not found — check the path or model name"
Permission error "Access denied — you may need to log in to Hugging Face"

Architecture

.nx file → Lark Parser → Typed Config → Code Generator → Optimized Python → Execution
                  ↘                ↙
             Validation Engine  (with error translation)

Publishing to PyPI

pip install build twine
cd decant/
python -m build
python -m twine upload dist/*

Requirements

  • Python 3.10+
  • CUDA-capable GPU with 6+ GB VRAM (for 3B models with QLoRA)
  • 12+ GB VRAM recommended for 7B models with QLoRA
  • 24+ GB VRAM recommended for 13B+ models

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

decant_dsl-0.3.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decant_dsl-0.3.0-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file decant_dsl-0.3.0.tar.gz.

File metadata

  • Download URL: decant_dsl-0.3.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for decant_dsl-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c101f2bf187fab1cdd7d34882d5d2452b7695259ef028bcdc7e65c8b7373cd47
MD5 23cb082e0e3d323ef6594f4368d36664
BLAKE2b-256 90b765cd2b01f922148dcaa6b63eda310d4f39a34349065a3d50433be03252e6

See more details on using hashes here.

File details

Details for the file decant_dsl-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: decant_dsl-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for decant_dsl-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7a8bd1ed95b7e950b1c0eb822d06ea1ecb7b0e06ae9d97e72013374d9746950
MD5 47093e16eecafa65737adabb9f42faf2
BLAKE2b-256 f4e95c34e1af992759d3d46814c6ac143e7d102615e8c2cd458bdb0e8244b07c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page