Skip to main content
Merlina

Merlina

Magical Model Training

๐ŸŽฏ Step 1: Select Your Base Model

๐Ÿค– Model Configuration

Examples: meta-llama/Llama-3.2-3B-Instruct, mistralai/Mistral-7B-Instruct-v0.3, ./models/my-merged-model
Models from the HuggingFace cache and ./models โ€” no internet needed
Auto-detect works for most models. Pick VLM for vision-language models (Qwen-VL etc.) or Diffusion to train an image LoRA on Qwen-Image / SDXL.

๐Ÿ”‘ API Tokens (Optional)

Required for gated models like Llama
โœ“ Model Ready

๐ŸŽฎ GPU Selection

Click "Refresh GPU List" to see available GPUs
Hold Ctrl/Cmd to select multiple GPUs. Leave empty for auto-selection.
DDP: Each GPU processes different data batches in parallel — faster training, halves step count. Single: Spreads model layers across GPUs — for models too large for one GPU.

๐Ÿ“š Step 2: Configure Your Dataset

Determines which columns your dataset needs.

๐Ÿ”ฎ Datasets

Add one or more datasets. Each has its own source and column mapping. All datasets are concatenated, formatted, and split together.
โœจ Messages Format Detected!
One or more datasets use the common "messages" format. Enable auto-convert to transform into standard format (prompt, chosen, system).
When enabled: user โ†’ prompt, assistant โ†’ chosen, system โ†’ system

๐Ÿง™ System Prompt Override (Optional)

Inject a system prompt across all datasets.
"Fill empty" sets the system prompt only for rows without one. "Replace all" overwrites every row's system prompt.

๐Ÿ“ Dataset Format

How to format conversations for the model
When enabled, the model can use <think> tags to show its reasoning process before responding. When disabled, adds empty <think></think> tags to prevent thinking output.
Detect <think> per row: render with thinking enabled when the row has a reasoning column or embedded <think>โ€ฆ</think> in prompt/response, and disabled when it doesn't. This bakes the empty <think></think> wrapper into the prompt prefix on non-reasoning rows so the model never trains on emitting a closing </think> itself. Recommended for hybrid thinking/non-thinking corpora.
Use {system} and {prompt} as placeholders

๐Ÿ‘๏ธ Dataset Preview

Raw Dataset


                        

Formatted for Training

Prompt:
โœ“ Chosen Response:
โœ— Rejected Response:
๐Ÿ“ Format Type:

๐Ÿ“Š Dataset Statistics

โš™๏ธ Advanced Options

Fraction of data for evaluation
Limit dataset size for testing
Streams rows in batches instead of loading all at once. Recommended for 100k+ row HuggingFace datasets.
Removes duplicates before training. Useful when combining multiple datasets.

โœจ Step 3: Configure Training Parameters

๐Ÿ’พ Configuration Management

Save your current settings or load from a previous job

๐ŸŽฏ What are you training?

Choose a training method โ€” this also determines which dataset columns are required.

๐ŸŽจ Diffusion Settings

๐Ÿช„โœจ
Drop your images here
...or click to pick a folder. PNG / JPG / WebP all work.
Captions default to the filename โ€” edit each one inline below, or leave blank to let the trainer infer from the image.
0 images selected
โš™๏ธ Advanced: paste a JSONL path or HF dataset name instead
JSONL with {prompt, image} (or {prompt, chosen, rejected}) rows. โš ๏ธ This is a path on the machine running Merlina, not your computer โ€” if the server is remote, use the drag-drop upload above (which sets this automatically) or an HF dataset name below. Click Preview to inspect + inline-edit captions before training.
Loadingโ€ฆ
Alternative to upload / JSONL. Dataset must have an `image` + `prompt` (or `caption`) column.
Square crop at this size for both VAE encoding + training. 1024 is Qwen-Image native.
32 is a safe default for diffusion. Higher rank = more capacity but more overfit risk on small datasets.
Attention modules. Default targets attention only; add ff.net.0.proj / ff.net.2 for higher-capacity finetunes.
Decomposes the LoRA update into magnitude + direction. ~5-10% slower step, meaningfully better quality on small aesthetic datasets where vanilla LoRA underfits the target style.
Generate preview images on every checkpoint, not just at the end. Watch the LoRA converge in near-real-time. Pauses training briefly while sampling (~30-60s per checkpoint). Untick for fastest wall-clock.
Name for your fine-tuned model

๐Ÿช„ LoRA Enchantments

When enabled, trains only LoRA adapters (faster, less VRAM). When disabled, trains the full model.
Detecting layers...
โ–ผ ๐ŸŽฏ Attention Layers
โ–ผ โšก MLP Layers
โ–ผ ๐Ÿ“š Embedding Layers
โ–ผ ๐Ÿ“ฆ Other Layers
7 layers selected
Enter a model name above and click "Detect Layers" to see available layers, or enter comma-separated layer names manually.
Modules to fully fine-tune (not LoRA-adapted) and save with adapter
Most models use CAUSAL_LM. Only change this if you know your model architecture requires a different task type.

โš—๏ธ Training Potions

Controls preference optimization strength
Target margin between chosen and rejected rewards
Smoothing coefficient for preference loss
For reproducibility
Gradient clipping threshold
Maximum length for prompts
Learning rate warmup proportion
How often to evaluate (0-1)
Checkpoint cadence. Blank = follow eval steps; 0 = final model only (use on unified-memory boards); <1 = ratio; ≥1 = steps
L2 regularization strength
Learning rate schedule
Log metrics every N steps
Randomize training data order
Save VRAM (slower training)

๐Ÿ”ง Optimizer Configuration

Paged optimizers swap memory to CPU when GPU is full. 8-bit uses less memory but may be slightly less precise. Muon applies orthogonalized updates to weight matrices โ€” great for LoRA.
First moment decay (momentum)
Second moment decay (variance)
Numerical stability (1e-8)
Use time-dependent LR instead of explicit learning rate
Scale LR by root-mean-square of parameter tensor
Time-dependent warmup (requires Relative Step)
Running average decay for squared gradients
Leave empty to disable momentum
Root-mean-square gradient clipping

๐Ÿฆ Grimoire Optimizations

Patch model with fused Triton kernels (RMSNorm, RoPE, SwiGLU). Faster training, lower VRAM.
Wrap model with torch.compile for fused kernels (PyTorch 2.x). May add startup overhead.
Embedding noise scale for regularization (try 5.0). Leave empty to disable.
Run a baseline eval before training begins.
๐Ÿ’ก Liger Kernel: Best on Llama, Mistral, Qwen, Gemma, and Phi family models. Requires pip install liger-kernel.

โšก Attention Implementation

Auto mode: Uses Flash Attention 2 on Ampere+ GPUs (RTX 30/40 series, A100, H100), falls back to SDPA or Eager for older GPUs.
๐Ÿ’ก Performance Guide:
โ€ข Flash Attention 2: Up to 2-3x faster, lowest memory usage
โ€ข SDPA: Good balance, works on most modern GPUs
โ€ข Eager: Slower but most compatible, use for debugging

๐ŸŒŸ Magical Options

๐Ÿค— HuggingFace Hub Configuration

Required to push models. Get your token from huggingface.co/settings/tokens
Click "Check Orgs" to list the organizations your token can publish to.
Private repositories are only visible to you. Uncheck to make your model public.
When checked, uploads full merged model (larger). When unchecked, uploads only LoRA adapter (much smaller, requires base model to use).
Embeds the (secret-stripped) training config in the model's README so others can reproduce your run with one click. Uncheck to keep your hyperparameters private. Uploads a merlina_config.png โ€” a scannable QR code that also carries the full (secret-stripped) config in its metadata. Others can reproduce your run by scanning it or loading it via Load Config โ†’ From Image, without the giant JSON block. Works with or without the README option above.

๐Ÿ“Š Weights & Biases Configuration

Get your API key from wandb.ai/authorize
W&B project to organize runs
Leave empty for auto-naming
Organize runs with tags
Describe the purpose of this run
๐Ÿ’ก Auto-naming format: [model]-[lr]-[batch]-[epochs]ep-[optimizer]-[attention]
Example: llama3-8b-5e-6LR-256B-2ep-adamw8bit-flash2-4bit

๐Ÿ”ฎ Active Spells

๐Ÿ”ฎ Step 5: Test Your Model

Pick chat for any text model, or diffusion to render images from a trained image LoRA.

๐Ÿค– Load a Model

HuggingFace model ID or absolute path to local model directory

โš™๏ธ Generation Settings

๐Ÿ’ฌ Chat

Pick a base diffusion model + one of your trained LoRAs, type a prompt, hit conjure. Runs in a fresh subprocess so it won't fight live training jobs for VRAM.

๐Ÿช„ Conjure

HF repo id or local path. Defaults to Qwen-Image.
Match the family the LoRA was trained against.
Picked from ./models/. Refresh after training new ones.

Result

generated

๐Ÿ“ฆ Export & Publish

Quantize trained models to GGUF, publish to HuggingFace Hub, and manage artifacts โ€” all against any model under ./models/.

๐Ÿ”ฎ GGUF Quantization

Merlina will merge the LoRA (if any) and brew one GGUF per selected quant. Larger quants keep more quality; smaller quants run on weaker hardware.

๐Ÿค— HuggingFace Hub Upload

Click "Check Orgs" to list the organizations your token can publish to.
Defaults to the model folder name. Picking an organization above publishes it as org/model-name; an explicit org/name here wins.
Advanced metadata

๐Ÿ—‚๏ธ Artifacts

Everything Merlina saved under ./models/{selected}/. Protected files (config, tokenizer) can't be deleted via the UI.

๐Ÿงน Step 7: Tidy the Workshop

Old training runs leave behind full-size checkpoints. Keep the latest of each finished run and reclaim the rest โ€” active jobs are always left untouched.

๐Ÿ’พ Disk Usage

โ€”
Results total โ€”
Reclaimable โ€”
Models total โ€”

โœ‚๏ธ Prune Checkpoints

๐Ÿ“Š Per-Job Breakdown

Loadingโ€ฆ

โš ๏ธ This cache is shared across your whole machine.

Other tools (ComfyUI, other trainers, scripts) pull models from this same cache. Everything here is re-downloadable from the Hub, but deleting a model another tool still needs will force a re-download. Only remove repos you're sure are unused.

๐Ÿค— Cached Repos

Cache total โ€”
Stale (reclaimable) โ€”
Selected 0 B

Click โ€œScanโ€ to inspect the cache.

โš ๏ธ Deleting a saved model is permanent.

These are your trained outputs under ./models/. Unlike the HuggingFace cache, a model that was never pushed to the Hub cannot be recovered. Models in use (an active job's output, or one loaded for inference) are locked ๐Ÿ”’.

๐Ÿ“ฆ Saved Models

Models total โ€”
Selected 0 B

Loadingโ€ฆ

๐ŸงŠ GGUF Exports

always regenerable from the model

Quantized GGUF files produced for llama.cpp inference. Safe to delete โ€” re-export anytime from the model. One loaded for inference is locked ๐Ÿ”’.

GGUF total โ€”
Selected 0 B

Loadingโ€ฆ

๐Ÿ“ˆ Weights & Biases Logs

Local mirrors of training run logs under wandb/. Metrics already live on the W&B server; the active run is kept.

Logs total โ€”
Runs โ€”
Clearable โ€”

Spell Progress

0%
Current Step -
Loss -
Status -
GPU Memory -

Training Loss

Waiting for training data...

๐ŸŽฎ GPU Monitoring

๐ŸŽจ Sample Renders

Test images generated by your freshly-trained LoRA on a default prompt set. (Override via sample_prompts in the API.)

No sample images yet โ€” they'll appear once training completes.

๐Ÿ“Š View in W&B

๐Ÿ“ค Upload Model to HuggingFace Hub

Push this job's trained model to HuggingFace Hub.

Optional if HF_TOKEN is set in the server's .env.
Click "Check Orgs" to list the organizations your token can publish to.

Save Configuration

Load Configuration

Loading configurations...

Load Configuration from Code

Paste the merlina-config-v1:โ€ฆ code from a Merlina model card (the "Reproduce this training run" section). Raw config JSON works too.

Load Configuration from Previous Job

Click a job to load its training configuration into the form.

Loading job history...

Manage Configurations

Loading configurations...

Loading version...
Made with โค๏ธ by Schneewolf Labs