Training and fine-tuning
SharpMind has three training jobs. They share the data pipeline, checkpoints and export, but they train different things and use different devices.
Three modes
| Mode | Starts from | Trains | GPU |
|---|---|---|---|
| New model (pretrain) | Random weights | Every weight | No — CPU only |
| Improve (LoRA) | Packaged .smm | Small adapters | Yes, when the base fits |
| SFT | Packaged .smm + chat JSONL | LoRA adapters, assistant tokens only | Yes, same shape rules |
GPU support
The GPU training engine accepts a base model with all of these:
- RMSNorm (not LayerNorm) — both in the blocks and the final norm.
- RoPE or NoPE positional encoding.
- Gated FFN (SwiGLU/GeGLU-style), not MoE.
- An attention layout with q_proj, k_proj, v_proj, o_proj LoRA targets.
- A packaged .smm base. Convert a GGUF first.
LLaMA/Qwen-style bases satisfy this. GPT-2/BERT-style bases (LayerNorm, dense GELU) do not for training, although GPU inference now covers them.
On a supported base the log shows:
Fine-tune: 8 adapters (rank 8, alpha 16).
Engine: [Cuda] NVIDIA A16, 14962 MB, cuBLAS 12.6
Training 100 steps (float32) — full backprop (loss → gradients → AdamW)…
On an unsupported base it shows the refusal and falls back:
Accelerator 'ilgpu' declined: GPU engine (M1) does not support a
LayerNormLayer final norm — LayerNorm, only RMSNorm
Retrying on the CPU. Set SHARPMIND_ACCELERATOR_FALLBACK=false to fail instead.
The fallback is a host policy. Set SHARPMIND_ACCELERATOR_FALLBACK=false to fail the job instead of retrying.
Fine-tune a base
- Training → Improve.
- Base model: pick a packaged .smm. The model list is under Models; a GGUF must be converted first.
- Corpus: use Browse. With SFT off it filters *.txt; with SFT on, *.jsonl. A folder or glob also works.
- LoRA: rank 8–16, alpha 16–32, targets q_proj k_proj v_proj o_proj.
- Steps: 50–200 for a tiny test, 200–500+ for a real SFT run.
- Output: merged .smm, adapter .smlora, or both.
- Run on: This PC or a Compute host. The base and corpus upload with the job; the export downloads back.
- Start fine-tune and watch the engine line and loss curve.
SFT
Tick Instruction tuning (SFT) to train on chat JSONL with assistant-only loss. Each line is one record. Supported shapes:
{"messages":[{"role":"user","content":"…"},{"role":"assistant","content":"…"}]}
{"conversations":[{"from":"human","value":"…"},{"from":"gpt","value":"…"}]}
{"prompt":"…","response":"…"}
{"instruction":"…","input":"…","output":"…"}
The base supplies the tokenizer and chat template. Use Preview data before the run: it reports parsed, skipped, truncated and train/val/exam counts, plus sample rendered conversations.
- Blank lines, malformed JSON and records without an assistant turn are skipped.
- Long conversations are truncated to the SFT sequence length.
- FuseChat's original file is a root JSON array, not JSONL; convert one record per line first.
Choosing data
| Data | Use |
|---|---|
| Plain .txt | Plain LoRA fine-tune (SFT off). Shakespeare, stories, domain text. |
| Text JSONL ({"text":"…"}) | Not for SFT — no assistant turn. Use the text file in plain mode. |
| Chat JSONL | SFT. Use messages, conversations, prompt/response or instruction/output. |
| Parquet | Not read by Studio. Convert to JSONL first. |
For a quick test, a 1 MB text file is enough. For a useful instruction tune, a few thousand chat records are enough to see behaviour; 20k+ is a small real run. Prefer data that matches how you will use the model.
Remote runs
Select a Compute host in Run on. Studio uploads the source files and base, starts the job, polls its state and logs, then downloads the export back to the path shown on the form. The host needs no chat model for a fine-tune.
- If the base is large, upload time dominates the first poll; the card logs progress in 25% steps.
- The export is written under the host's /data/SharpMind/Training/jobs/…, then downloaded.
- Rehearse 30 steps runs locally and estimates step time; it is not the remote job.
- An interrupted run may leave the host job running; cancel it from the run record or the host API.
Progress and interrupt
The run panel follows the job: status, step, loss, validation loss, curve, log tail and an Interrupt button. Starting a run scrolls it into view. The panel repaints itself while the job is active, including remote jobs.
Accelerator errors
| Message | Meaning |
|---|---|
| only LoRA adapters are trainable in M1 | The job is a pretrain. Use Improve/SFT for GPU, or let it fall back to CPU. |
| LayerNorm, only RMSNorm | The base is GPT-2/BERT-style. Use a LLaMA/Qwen base for GPU training. |
| No CUDA or OpenCL device | The container has no GPU access. Check --gpus all, the driver and the toolkit. |
| MoE | MoE training is not supported by the GPU engine. |
| Val split produced no documents | The corpus is too small for a 64-token window; training continues without a validation curve. |