Agent skill

Trainer Integration

by drawthingsai in drawthingsai/draw-things-community

Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint…

GPL-3.0Auto-check passedAI & LLM Engineering

Install Trainer Integration

skills CLI
$ npx skills add drawthingsai/draw-things-community --skill trainer-integration -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install drawthingsai/draw-things-community trainer-integration --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/drawthingsai/draw-things-community.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/trainer-integration .claude/skills/trainer-integration && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
trainer-integration
GitHub stars
579
Token cost
~2.6k tokens
SKILL.md length
1,422 words
Files
2
Skills in repo
8
Repo updated
First seen
Licence
GPL-3.0

At a glance

Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint…

  • Works in 10 steps: Add the LoRA model builders → Add trainer dispatch → Wire trainable keys in both entry points → …
  • Tasks that involve Fine-tuning
  • SKILL.md covers Goal, Primary Files, Integration Checklist and Model-Specific Lessons, plus 3 more sections
  • Calls bazel

What it does

Trainer Integration is an agent skill from drawthingsai/draw-things-community. Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint export, numerical debugging, and validation.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in AI & LLM Engineering, covering Fine-tuning. The repository describes itself as: The community repository for the Draw Things app. The licence is GPL-3.0.

When your agent uses it

  • Tasks that involve Fine-tuning

Example prompts

  • “/trainer-integration”

Workflow steps

10 steps, taken from the step headings in SKILL.md.

  1. Add the LoRA model builders
  2. Add trainer dispatch
  3. Wire trainable keys in both entry points
  4. Wire tokenizers cleanly
  5. Mirror the fixed encoder path, but keep it trainer-friendly
  6. Match weight loading exactly
  7. Handle rotary the training-safe way
  8. Choose scaler and attention backend intentionally
  9. Keep the fixed conditions simple
  10. Update checkpoint export

What it can do on your machine

Read from SKILL.md and the folder at commit 3cac075. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bazel

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Trainer Integration loads about 2.6k tokens when it runs. Until then it costs about 66 tokens; SKILL.md has 1,422 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from drawthingsai/draw-things-community at commit 3cac075, republished under its GPL-3.0 licence (© drawthingsai). 1,422 words, ~2,636 tokens.

Download SKILL.mdSave it as .claude/skills/trainer-integration/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
trainer-integration
description
Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint export, numerical debugging, and validation.

Trainer Integration Skill

Use this workflow when adding LoRA training support for generative models available in the Draw Things app / CLI or when tightening an existing trainer path. Follow Flux1 first, then copy only the model-specific pieces you actually need.

Goal

Add a new trainer path that:

  • compiles with DrawThingsCLI
  • writes real LoRA checkpoints
  • keeps loss finite
  • survives a real 100 to 500 step run
  • reproduces an obvious visual shift during generation

Primary Files

  • Libraries/Trainer/Sources/LoRATrainer.swift
  • Libraries/Trainer/Sources/LoRATrainerCheckpoint.swift
  • Libraries/SwiftDiffusion/Sources/Models/<Model>.swift
  • Apps/DrawThingsCLI/DrawThingsCLI.swift
  • Apps/DrawThings/Sources/LoRA/LoRATrainingWorkflow.swift

Use these references first:

  • trainFlux1(...) in LoRATrainer.swift
  • LoRAFlux1 and LoRAFlux1Fixed in Flux1.swift

Integration Checklist

1. Add the LoRA model builders
  • Add LoRA<Model> and, if needed, LoRA<Model>Fixed.
  • Keep changes local to the LoRA path whenever possible.
  • Do not rewrite the base runtime path unless training forces it.
  • Do not assume trainer-side LoRANetworkConfiguration is enough. The LoRA builders themselves may need changes to:
    • the outer Model(..., trainable:) setting
    • inner Model(..., trainable:) boundaries
    • gradient-checkpoint wiring on the relevant block builders
  • Follow Flux1 exactly here:
    • keep the outer LoRA model trainable: false
    • thread gradient-checkpoint flags through the LoRA-specific builders, not just the trainer call site
    • if a nested Model wrapper needs an explicit trainable: value to preserve the intended trainable surface, do that in the LoRA path instead of changing the base model path
  • Remember the rule: if a parent Model is trainable: false, submodules are effectively non-trainable unless the graph structure explicitly reintroduces the LoRA trainable surface the same way the working reference path does.
  • If the top-level runtime model is also wrapped by a LoRA builder, keep that wrapper trainable: false and rely on the individual LoRA layers for trainability. Accidentally making the parent trainable turns the path into a full fine-tune.
  • Mirror Flux1-style LoRANetworkConfiguration usage and checkpointing flags.
2. Add trainer dispatch
  • Add a train<Model>(...) entry in LoRATrainer.swift.
  • Dispatch to it from the main trainer switch.
  • Add the matching version handling in CLI and app workflow code.
3. Wire trainable keys in both entry points
  • Add trainable-key helpers in DrawThingsCLI.swift.
  • Mirror the same version handling in LoRATrainingWorkflow.swift.
  • Do not stop after CLI only; the app workflow needs the same version-specific key selection.
4. Wire tokenizers cleanly
  • Extend LoRATrainingDependency if the model needs a tokenizer that is not already injected.
  • Keep the dependency factory-based, like the existing tokenizer fields.
  • Mirror the version-specific tokenizer stack in both CLI and app workflow code.

Small but important example:

  • Qwen Image should use the Qwen 2.5 tokenizer, not Qwen 3.
  • Z Image uses Qwen 3.
5. Mirror the fixed encoder path, but keep it trainer-friendly
  • Start from the runtime fixed path, but do not copy disk-cache shortcuts from UNetFixedEncoder.swift.
  • Treat UNetFixedEncoder as a legacy-named integration boundary for the main diffusion model / DiT path, not as a literal UNet requirement.
  • Run the fixed model directly in the trainer.
  • Prefer batched fixed inference over per-sample loops when the fixed builder supports it.
  • Feed fixed outputs back into the main trainable graph as graph.constant(...).
  • Avoid per-sample toCPU()/toGPU() rebuilds when a batched constant path works.
  • Flush partial batches. If fixed inference batches at a fixed size, make the target batch size shrink near the end of training so the tail samples are actually trained.
  • Preserve output dtypes exactly:
    • context stays in the model float type
    • AdaLN chunks stay Float
    • shift/scale stays in the model float type
    • do not force every fixed condition to Float just because one condition needs it
6. Match weight loading exactly
  • Use the same model key and codec list that the runtime path needs.
  • Mapping is not used when loading trainer weights; mapping matters for import, not for read(...).
  • If the runtime model needs .i8x, the trainer needs .i8x too.

This was the difference between immediate nan and a finite first step for Qwen Image.

7. Handle rotary the training-safe way
  • If cmul backward cannot reduce broadcast semantics, fully expand rotary on the training path.
  • Keep the expanded rotary parity-preserving.
  • Do not trust [1, seq, 1, dim] rotary broadcasting into [batch, seq, heads, dim] just because forward compiles. The backward path can still be wrong or unstable.
  • If memory matters, cache compact one-head rotary constants, then expand them to the actual query/key head count before entering the trainable graph.
  • Prefer slicing query rotary from the shared rot tensor instead of inventing a separate query-rotary input when the slice is enough.
  • Do not let training-only rotary plumbing leak into the normal inference interface if you can avoid it.
8. Choose scaler and attention backend intentionally
  • Pick the initial GradScaler from the model's numeric contract, not by trial-and-error lowering.
  • If the model has no internal residual/projection scaling that already shrinks gradients, start from the high healthy scale used by the stable trainers, usually 32_768.
  • Never accept a scaler below 1 as a fix. That usually masks overflow and can make the trainer learn too slowly or not at all.
  • When validating attention backends, first prove a known-stable fallback can train, then run the intended backend for the full validation ladder.
  • Do not accidentally force the fallback path in trainer code. Use the model-appropriate default such as valueOr(.scale1) when the configured backend is supposed to participate in training.
Show full SKILL.md (574 more words)Show less
9. Keep the fixed conditions simple
  • Use graph.constant(...) for precomputed fixed conditions.
  • Use .copied() when slicing batched fixed outputs back into per-sample constants.
  • Do a dry-run forward before the first real step to allocate the largest graph state up front:
swift
let _ = dit((width: latentsWidth, height: latentsHeight), inputs: latents, cArr)
10. Update checkpoint export
  • Add the new version branch in LoRATrainerCheckpoint.swift.
  • Point it at the correct model key, usually dit.
  • Confirm the saved LoRA file is real:
    • nontrivial size
    • __up__ tensors present and nonempty

Model-Specific Lessons

Z Image
  • Follow the Flux1 trainer pattern closely.
  • Keep changes concentrated in LoRAZImage, LoRAZImageFixed, and trainZImage(...).
  • Do not add broad changes to base ZImage / ZImageFixed unless training truly needs them.
  • Use the shared rot path; slice from it instead of carrying a second query-rotary input.
  • Training currently uses fully expanded rotary because backward needs it.
  • Keep x_pad_token on the GPU if you cache it for trainer constants.
  • Current healthy trainer scale is 1024.
Qwen Image
  • Use the Qwen 2.5 tokenizer.
  • Use the real training token length, not a padded constant everywhere.
  • Batched encodeQwenFixed(...) is better than the old per-sample CPU/GPU rebuild path.
  • Feed fixed outputs back as constants.
  • Keep .i8x in both fixed and main trainer reads when the checkpoint needs it.
  • isBF16 on the fixed side is mostly about scaling math; do not assume the whole fixed contract becomes BF16.
  • The main LoRA model still owns the explicit BF16 conversion path.

First Debug Pass

If a new trainer is broken, check these in order:

  1. 1-step run: finite loss?
  2. checkpoint written?
  3. checkpoint nonempty?
  4. lora_up tensors nonzero?
  5. fixed conditions fed as constants, not variables?
  6. tokenizer stack correct?
  7. runtime and trainer codec lists match?
  8. rotary fully expanded only where backward needs it?
  9. scaler chosen from the model's numeric contract, not lowered below 1 to hide instability?
  10. optional attention backend selected intentionally, not accidentally through a global default?

Failure Patterns

Immediate nan at step 0
  • Wrong codec list, especially missing .i8x
  • Wrong tokenizer or token length
  • Broken fixed-condition path
  • Wrong dtype assumptions on BF16 models
lora_up stays zero almost everywhere
  • Gradient is being cut before most LoRA layers
  • Check the trainable surface first
  • Then check the fixed-condition boundary and backward-only branches
Dynamic scale steadily collapses
  • Treat this as a numerical stability issue first, especially when validating a new attention backend.
  • Do not lower the initial scale below 1; fix the overflow source instead.
  • Compare against the known-stable attention mode before changing optimizer hyperparameters.
  • If only the experimental attention mode collapses, suspect backward precision, scaling, or gradient staging rather than the dataset.
  • If collapse disappears after expanding rotary to full heads, the root cause was shape/broadcast semantics in backward, not optimizer settings.
Low timestep loss is higher than mid/high timestep loss
  • This is not automatically a bug for flow-style objectives.
  • If the training target includes a full noise or velocity term that is only weakly present in the low-timestep input, low timestep bins can have higher irreducible error.
  • Compare like-for-like timestep bins over time instead of expecting low timesteps to be easiest.
Generation ignores the LoRA
  • The LoRA may be loading with the wrong version
  • Use explicit loras[].version in CLI validation

Validation

After code integration, validate with the $train-lora workflow:

  1. bazel build --compilation_mode=opt //Apps:DrawThingsCLI
  2. 1-step smoke test
  3. 20-step stability probe
  4. 100-step run
  5. 500-step run on the intended attention backend
  6. base vs LoRA generation comparison

Do not call the trainer integrated until it survives the full ladder.

© drawthingsai, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in .agents/skills/trainer-integration of drawthingsai/draw-things-community.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit 3cac075

Compare with similar skills

Trainer Integration next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Trainer Integration compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Trainer Integration this skilldrawthingsai/draw-things-community579—~2.6kAutomated safety check: PassGPL-3.0
Peft Fine TuningOrchestra-Research/AI-Research-SKILLs13k9 repos~3.1kAutomated safety check: PassMIT
Hugging Face LLM Trainerhuggingface/skills11k3 repos~7.2kAutomated safety check: PassApache-2.0
Sentence-Transformers Training Routerhuggingface/skills11k1 repos~2.6kAutomated safety check: PassApache-2.0
Dataset Evaluationawslabs/agent-plugins9122 repos~1.3kAutomated safety check: PassApache-2.0
Train RlOpenPipe/ART11k—~2.4kAutomated safety check: PassApache-2.0

Similar skills

  • Peft Fine Tuning

    Orchestra-Research/AI-Research-SKILLs

    Parameter-efficient fine-tuning for LLMs using LoRA, QLoRA, and 25+ methods.

    13k GitHub starsUsed in 9 repos~3.1k tokens
    AI & LLM EngineeringAuto-check passed
  • Hugging Face LLM Trainer

    huggingface/skills

    Official

    Trains or fine-tunes language and vision models with TRL or Unsloth on Hugging Face Jobs cloud GPUs, then converts the results to GGUF.

    11k GitHub starsUsed in 3 repos~7.2k tokens
    AI & LLM EngineeringAuto-check passed
  • Official

    Routes a sentence-transformers training task to the right model type and required reference docs and example scripts, covering bi-encoders, rerankers, sparse and multi-vector models.

    11k GitHub starsUsed in 1 repo~2.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Dataset Evaluation

    awslabs/agent-plugins

    Official

    Validates dataset formatting and quality for SageMaker model fine-tuning (SFT, DPO, or RLVR).

    912 GitHub starsUsed in 2 repos~1.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Train Rl

    OpenPipe/ART

    RL training reference for the ART framework. An agent skill from OpenPipe/ART.

    11k GitHub stars~2.4k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Qwopus27b Rl Training

    R6410418/Jackrong-llm-finetuning-guide

    Prepare, validate, launch-plan, monitor, resume, and stop configurable Qwopus 27B reinforcement-learning workflows for GRPO or GSPO.

    1.7k GitHub stars~830 tokensUpdated 2 mo ago
    AI & LLM EngineeringAuto-check passed

More from drawthingsai/draw-things-community

All 8 skills in this repo
  • Run Longcat Avatar Video

    drawthingsai/draw-things-community

    Generate, benchmark, validate, and troubleshoot LongCat-Video-Avatar 1.5 videos with draw-things-cli.

    579 GitHub stars~2.8k tokensUpdated today
    Auto-check passed
  • Setup Cpu Proxy Server

    drawthingsai/draw-things-community

    Set up and verify a new Draw Things CPU proxy and Envoy server using the scripts in Scripts/ServerManagement/CPUScript.

    579 GitHub stars~3.8k tokensUpdated today
    Auto-check passed
  • Use Drawthings CLI

    drawthingsai/draw-things-community

    Use and troubleshoot an already installed Homebrew draw-things-cli for model discovery, authentication, local, cloud, or remote image generation, basic image-to-image and video generation, output…

    579 GitHub stars~3k tokensUpdated today
    Auto-check passed
  • Init GPU Server

    drawthingsai/draw-things-community

    Initialize a Draw Things GPU server with GPUScript, including script sync, Docker/CUDA/NVIDIA runtime setup, 7T data disk mounting, mergerfs, and end-to-end GPU verification.

    579 GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • New Model Integration

    drawthingsai/draw-things-community

    Add a new image or video generative model to the Draw Things app / CLI with a compile-first, end-to-end workflow across SwiftDiffusion, tokenizer plumbing, text encoder, fixed encoder, UNet / DiT…

    579 GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Train Lora

    drawthingsai/draw-things-community

    Validate Draw Things LoRA training end to end with draw-things-cli, including tiny-dataset training, loss and scaler checks, checkpoint sanity, and base-versus-LoRA generation comparison.

    579 GitHub stars~2k tokensUpdated today
    Auto-check passed

Questions about Trainer Integration

What does Trainer Integration do?

Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint…. Trainer Integration is an agent skill from drawthingsai/draw-things-community. Add or tighten Draw Things LoRA trainer support for generative models available in the Draw Things app / CLI, covering LoRA builders, trainer dispatch, tokenizer and fixed-encoder wiring, checkpoint export, numerical debugging, and validation.

When should I use Trainer Integration?

Trainer Integration fits situations like: tasks that involve Fine-tuning.

How do I install Trainer Integration in Claude Code?

Run `npx skills add drawthingsai/draw-things-community --skill trainer-integration -a claude-code`. Or copy the skill folder (.agents/skills/trainer-integration in drawthingsai/draw-things-community) into .claude/skills/trainer-integration in your project. Claude Code loads it when a task matches its description.

How do I install Trainer Integration in Codex?

Run `npx skills add drawthingsai/draw-things-community --skill trainer-integration -a codex`. Or copy the skill folder (.agents/skills/trainer-integration in drawthingsai/draw-things-community) into .agents/skills/trainer-integration in your project. Codex loads it when a task matches its description.

Can I use Trainer Integration in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add drawthingsai/draw-things-community --skill trainer-integration -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/trainer-integration, .gemini/skills/trainer-integration, .github/skills/trainer-integration and .opencode/skills/trainer-integration in your project.

What does Trainer Integration need to run?

Going by SKILL.md and its folder, Trainer Integration needs the command-line tools its instructions call (bazel).

Does Trainer Integration access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Trainer Integration safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Trainer Integration use?

Trainer Integration is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Trainer Integration use?

About 2.6k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Trainer Integration?

Skills that share tags, products or a category with Trainer Integration: Peft Fine Tuning (Orchestra-Research/AI-Research-SKILLs, 13k stars), Hugging Face LLM Trainer (huggingface/skills, 11k stars), Sentence-Transformers Training Router (huggingface/skills, 11k stars) and Dataset Evaluation (awslabs/agent-plugins, 912 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Trainer Integration?

drawthingsai (a GitHub organization) maintains it in drawthingsai/draw-things-community, which has 579 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on October 6, 2026.

Source: drawthingsai/draw-things-community on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.