Skip to main content

Decant — A minimal DSL for AI model training & hosting with VRAM optimization

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.1.1.tar.gz (16.9 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.1.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for decant_dsl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a46618ccd377f3b8798861be72145d0708f830945b57a85f610d907c27d0472a
MD5 a1fc4d7e1d78d298df4f087d7842cceb
BLAKE2b-256 dc9fbceac401aed4542a5eece769b8abdf3c186b1e466611abf5ba328255eb7f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for decant_dsl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a1a1bb2df268d48ad92b70373a553b167ad8c92b6eb7f8e84a70367c12547c0a
MD5 9723486b8216ce61b602cd502c09c68e
BLAKE2b-256 8f6624f37cd3364ce35f26182c5f8e9971be1c6e06765b87d4720dce265a167f

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