Draft
Conversation
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add LoRA loading feature to master branch
Port LoRA adapter loading from lora-patches into master
Mar 7, 2026
Copilot
AI
changed the title
Port LoRA adapter loading from lora-patches into master
feat: LoRA adapter support for dit-vae
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds runtime LoRA adapter loading to
dit-vaevia PEFT-formatadapter_model.safetensors, with deltas applied in-graph across all DiT self-attention, cross-attention, and MLP projections.New files
src/safetensors.h— zero-dependency safetensors reader (header length + JSON metadata + raw tensor reads by offset)src/dit-lora.cpp—dit_ggml_load_lora(): normalises all PEFT key-name variants, matches A/B pairs per slot, transposes PyTorch row-major → ggml column-major, uploads to backendCore changes
src/dit.h—DiTGGMLLayergains 22 LoRA tensor pointer slots (SA/CA Q/K/V/O + MLP gate/up/down);DiTGGMLgainslora_wctx(independent weight context) andlora_scalesrc/dit-graph.h— newdit_ggml_linear_lora()(W@x + scale·B@A@x); self-attn, cross-attn, and MLP builders apply deltas on both fused and separate weight pathssrc/request.h/request.cpp—custom_tag(trigger word auto-appended to caption before condition encoding) andgenrefields; parsing aliases forformatted_lyrics,language,is_instrumentaltools/dit-vae.cpp—--lora <path>and--lora-scale <float>(default1.0); adapter loaded once, reused across all requestsUsage
./build/dit-vae \ --request request0.json \ --text-encoder models/Qwen3-Embedding-0.6B-Q8_0.gguf \ --dit models/acestep-v15-turbo-Q8_0.gguf \ --vae models/vae-BF16.gguf \ --lora lora/adapter_model.safetensors \ --lora-scale 1.0{ "caption": "Nu-disco track with funky bassline", "custom_tag": "crydamoure", "inference_steps": 8, "shift": 3 }custom_tagis appended to the caption so the trigger word reaches the condition encoder. Seeexamples/lora.shandexamples/lora.jsonfor a full runnable example.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.