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

Uploaded Python 3

File details

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

File metadata

  • Download URL: decant_dsl-0.1.2.tar.gz
  • Upload date:
  • Size: 17.0 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.2.tar.gz
Algorithm Hash digest
SHA256 3fc76f77d66719dd4e42bcabd4de7c1d023d499ed4b00179a9890763712d54ae
MD5 2770348b772851d30cc61ee3ed975c5c
BLAKE2b-256 5eaf2386cb2d2067e99b5a741ae7e5ecfce29bd19865974ee0e58b9a3b61a0ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: decant_dsl-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8591dc59037da107774ab65cbb9d2019c81202200d32b0e5017c05803352607d
MD5 0db3c13e1032fcc860d626628b12cbc7
BLAKE2b-256 42c3c005702e999f9e87968fbd4ba899d515ed2d222aaf25755efe539c7b3339

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