AI media harness for planning, generating, and editing locally
TypeScript
Support DMAD LoRA
Bittife6fbe4e4f4b
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex f152121..1a976c3 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -4,6 +4,7 @@ This alpha update adds still image projects, new scene types, and a rebuilt Wind## What's new+- Downloadable DMAD 4-Step LoRA with its re-noising sampling recipe for MiniMax H3.- Image projects: compose a still image as a hierarchy of objects, text and groups on a canvas, generate it with MiniMax H3, then refine it with sequential edits on an opened or generated image. Generated images and drafts stay in an image bar, and each keeps the settings it was made with.- Image export as JPG or PNG, at the original size or a size from the project ladder, with adjustable JPG quality. Pick any image to export from the image bar under the preview.- New scene types: Pose, Character replace, Extend and Bridge, alongside First & last frame and Animate.diff --git a/docs/slopfab-compatibility.md b/docs/slopfab-compatibility.mdindex fbe053a..18919c9 100644--- a/docs/slopfab-compatibility.md+++ b/docs/slopfab-compatibility.md@@ -1,5 +1,36 @@# Slopfab compatibility+## API 1.16: DMAD++The bundled runtime comes from SlopFab commit `017d2b6`, built with+`SLOPFAB_WITH_FFMPEG=OFF`. The DMAD 4-Step LoRA preset downloads the full-critic+adapter and sends its recipe through `slopfab_request_set_sampling_settings`:+re-noising, video/audio sigma shifts 12/2, and base sigmas `[1, .75, .5, .25, 0]`.+The fixed grid takes precedence over scene and other LoRA step counts, and+Slopus disables MotionCache for this recipe. Preview and execution use the+same settings on CUDA and Vulkan. Older runtimes report that API 1.16 is needed.++The recipe is saved with the machine-local LoRA library, independent of the+downloaded filename. Local imports can select **DMAD 4-Step** under **Sampling+recipe**. Disabled and zero-strength adapters do not select the recipe.+The released adapter needs no companion timestep grid; Slopus checks the+adapter header and skips grid preparation for attention/MLP-only adapters.+The new runtime's preparation API requires its reserved argument to be zero.+For legacy AdaLN adapters, Slopus now handles the optional companion download,+using the same pinned revision, size and SHA-256 as the old runtime, then calls+local-only preparation. Custom grid metadata still requires local assets.++The [DMAD model card](https://huggingface.co/ZhengmingYu/DMAD/blob/main/README.md)+describes training on T2VA at 1344x768, 124 frames and 24 fps. SlopFab also+supports applying it to FL2VA; upstream quality results do not establish quality+for this base-model swap or quantized weights. Slopus preserves the project's+chosen dimensions and duration.++Regression tests cover recipe persistence, download discovery, inactive LoRAs,+fixed-grid precedence, and native preview/execution request construction on both+backends. Release checks probe the download URL without fetching the full file.+Full model inference was not rerun for this integration.+## API 1.14: Extend and BridgeThe bundled runtime now builds from SlopFab commit `103687a` withdiff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex ccf61a5..4ac8274 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -3369,6 +3369,7 @@ dependencies = ["reqwest 0.12.28","serde","serde_json",+ "sha2","tauri","tauri-build","tauri-plugin-dialog",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex e83de67..fe4f2b9 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -26,6 +26,7 @@ tauri-plugin-updater = "2"libloading = "0.8"getrandom = "0.3"reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }+sha2 = "0.10"jpeg-encoder = "0.6"# Keep image decoding compatible with the package's Rust 1.87 minimum.image = { version = "=0.25.8", default-features = false, features = ["jpeg", "png"] }diff --git a/src-tauri/src/slopfab/config.rs b/src-tauri/src/slopfab/config.rsindex f00d25b..5feff39 100644--- a/src-tauri/src/slopfab/config.rs+++ b/src-tauri/src/slopfab/config.rs@@ -9,6 +9,11 @@ pub(super) struct LoraAdapter {pub(super) strength: f32,}+#[derive(Debug, Clone, Copy, PartialEq)]+pub(super) enum SamplingPreset {+ Dmad4Step,+}+#[derive(Clone)]pub(super) struct Configuration {pub(super) dll_path: PathBuf,@@ -20,6 +25,7 @@ pub(super) struct Configuration {pub(super) models: [(i32, &'static str, Option<PathBuf>); 5],pub(super) loras: Result<Vec<LoraAdapter>, String>,pub(super) step_override: Result<Option<i32>, String>,+ pub(super) sampling_preset: Result<Option<SamplingPreset>, String>,}impl Configuration {@@ -83,6 +89,11 @@ impl Configuration {}_ => Err("LoRA step override must be a whole number from 2 to 2147483647.".into()),},+ sampling_preset: match slopfab.and_then(|setting| setting.options.get("samplingPreset")) {+ None => Ok(None),+ Some(ProviderOption::String(value)) if value == "dmad-4step" => Ok(Some(SamplingPreset::Dmad4Step)),+ _ => Err("Unsupported LoRA sampling recipe.".into()),+ },}}@@ -129,6 +140,9 @@ impl Configuration {}pub(super) fn generation_steps(&self, fallback: i32) -> Result<i32, String> {+ if self.sampling_preset.clone()? == Some(SamplingPreset::Dmad4Step) {+ return Ok(4);+ }self.step_override.clone().map(|steps| steps.unwrap_or(fallback))@@ -169,11 +183,12 @@ impl Configuration {}).unwrap_or_default();format!(- "slopfab={version}|platform={}|attention={}|motionCache={}|{models}|loras={adapters}|steps={:?}",+ "slopfab={version}|platform={}|attention={}|motionCache={}|{models}|loras={adapters}|steps={:?}|sampling={:?}",platform.label(),self.attention,self.motion_cache,- self.step_override+ self.step_override,+ self.sampling_preset)}}diff --git a/src-tauri/src/slopfab/ffi/mod.rs b/src-tauri/src/slopfab/ffi/mod.rsindex 0fed5cb..954b3d9 100644--- a/src-tauri/src/slopfab/ffi/mod.rs+++ b/src-tauri/src/slopfab/ffi/mod.rs@@ -127,6 +127,10 @@ impl Api {self.check(r)?;self.inner.set_seed(r.pointer.as_ptr(), v)}+ pub fn set_dmad_sampling(&self, r: &RequestHandle) -> Result<(), String> {+ self.check(r)?;+ self.inner.set_dmad_sampling(r.pointer.as_ptr())+ }pub fn set_verbose(&self, r: &RequestHandle, v: bool) -> Result<(), String> {self.check(r)?;self.inner.set_verbose(r.pointer.as_ptr(), v)diff --git a/src-tauri/src/slopfab/ffi/raw/mod.rs b/src-tauri/src/slopfab/ffi/raw/mod.rsindex b9825be..6176565 100644--- a/src-tauri/src/slopfab/ffi/raw/mod.rs+++ b/src-tauri/src/slopfab/ffi/raw/mod.rs@@ -85,6 +85,7 @@ pub struct Api {set_continuation_file: Option<unsafe extern "C" fn(*mut Request, *const c_char, i32) -> i32>,set_video_transition: Option<unsafe extern "C" fn(*mut Request, i32) -> i32>,set_steps: unsafe extern "C" fn(*mut Request, i32) -> i32,+ set_sampling_settings: Option<unsafe extern "C" fn(*mut Request, *const c_char) -> i32>,set_seed: unsafe extern "C" fn(*mut Request, u64) -> i32,set_model: unsafe extern "C" fn(*mut Request, i32, *const c_char) -> i32,add_lora: Option<unsafe extern "C" fn(*mut Request, *const c_char, f32) -> i32>,@@ -198,6 +199,9 @@ impl Api {"slopfab_request_set_steps",unsafe extern "C" fn(*mut Request, i32) -> i32),+ set_sampling_settings: library+ .get::<unsafe extern "C" fn(*mut Request, *const c_char) -> i32>(b"slopfab_request_set_sampling_settings\0")+ .ok().map(|symbol| *symbol),set_seed: symbol!("slopfab_request_set_seed",unsafe extern "C" fn(*mut Request, u64) -> i32@@ -316,6 +320,16 @@ impl Api {Ok(c_string((self.version_string)()))}}+ pub fn set_dmad_sampling(&self, r: *mut Request) -> Result<(), String> {+ const UPGRADE: &str = "DMAD requires slopfab.dll API 1.16 or later. Update the runtime.";+ if unsafe { (self.capi_version)() } < ((1 << 24) | (16 << 12)) {+ return Err(UPGRADE.into());+ }+ let set = self.set_sampling_settings.ok_or(UPGRADE)?;+ // Released DMAD adapters do not embed slopfab.sampling metadata.+ let settings = CString::new(r#"{"version":1,"sampler":"renoise","video_sigma_shift":12,"audio_sigma_shift":2,"base_sigmas":[1,0.75,0.5,0.25,0]}"#).unwrap();+ self.error(unsafe { set(r, settings.as_ptr()) })+ }fn error(&self, code: i32) -> Result<(), String> {if code == 0 {Ok(())diff --git a/src-tauri/src/slopfab/h3.rs b/src-tauri/src/slopfab/h3.rsindex 83dbfcd..f2cc227 100644--- a/src-tauri/src/slopfab/h3.rs+++ b/src-tauri/src/slopfab/h3.rs@@ -1,6 +1,6 @@//! H3 and Animate request recipes for the SlopFab backend.use super::{- config::Configuration,+ config::{Configuration, SamplingPreset},ffi::{self, RequestHandle},planning::{generation_seed, RequestPurpose},platform::ComputePlatform,@@ -53,6 +53,10 @@ pub(super) fn configure_request(api.set_still_image(handle)?;}api.set_steps(handle, configuration.generation_steps(request.steps)?)?;+ let dmad = configuration.sampling_preset.as_ref().map_err(Clone::clone)? == &Some(SamplingPreset::Dmad4Step);+ if dmad {+ api.set_dmad_sampling(handle)?;+ }api.set_seed(handle, generation_seed(request.seed)?)?;if let Some(edit) = &request.image_edit {let step = edit.edits.first().ok_or("Add an image edit before generating.")?;@@ -68,7 +72,7 @@ pub(super) fn configure_request(}api.set_inference_backend(handle, platform.backend())?;api.set_attention(handle, configuration.attention)?;- api.set_motion_cache(handle, configuration.motion_cache && request.image_edit.is_none())?;+ api.set_motion_cache(handle, configuration.motion_cache && !dmad && request.image_edit.is_none())?;api.set_verbose(handle, false)?;if let Some(mode) = request.video_transition.as_deref() {api.set_video_transition(handle, if mode == "bridge" { 2 } else { 1 })?;diff --git a/src-tauri/src/slopfab/icons.rs b/src-tauri/src/slopfab/icons.rsindex dcb2553..041393d 100644--- a/src-tauri/src/slopfab/icons.rs+++ b/src-tauri/src/slopfab/icons.rs@@ -111,6 +111,7 @@ pub fn generate_reference_icon_batch(dll_path: batch.dll_path.clone(),loras: Ok(Vec::new()),step_override: Ok(None),+ sampling_preset: Ok(None),vulkan: backend == ComputePlatform::Vulkan,attention: "sage2",motion_cache: false,diff --git a/src-tauri/src/slopfab/tests.rs b/src-tauri/src/slopfab/tests.rsindex 32bf424..abf4cc1 100644--- a/src-tauri/src/slopfab/tests.rs+++ b/src-tauri/src/slopfab/tests.rs@@ -5,6 +5,46 @@ use super::{use crate::project::{ProviderOption, ProviderSetting};use std::collections::BTreeMap;+#[test]+fn dmad_recipe_reaches_preview_and_execution_on_both_backends() {+ let root = tempfile::tempdir().unwrap();+ let adapter = root.path().join("renamed-adapter.safetensors");+ metadata_checkpoint(&adapter, serde_json::json!({}));+ let settings = BTreeMap::from([("slopfab".into(), ProviderSetting {+ enabled: true, model: None,+ options: BTreeMap::from([+ ("samplingPreset".into(), ProviderOption::String("dmad-4step".into())),+ ("motionCache".into(), ProviderOption::Boolean(true)),+ ("stepOverride".into(), ProviderOption::Number(12.0)),+ ("loras".into(), ProviderOption::String(serde_json::json!([+ { "path": adapter, "strength": 1.0 }+ ]).to_string())),+ ]),+ })]);+ let configuration = Configuration::from_settings(&settings);+ assert_eq!(configuration.generation_steps(30).unwrap(), 4);+ let api = ffi::Api::load(&configuration.dll_path).unwrap();+ let request = GenerationRequest {+ prompt: "A polar bear plays the violin in the snow.".into(),+ frames: 124, steps: 30, seed: 42, canvas_width: 1344, canvas_height: 768,+ ..Default::default()+ };+ for platform in [ComputePlatform::Cuda13, ComputePlatform::Vulkan] {+ for purpose in [RequestPurpose::Plan, RequestPurpose::Generate] {+ let handle = RequestHandle::new(&api).unwrap();+ configure_request(&api, &handle, &request, &configuration, platform, purpose, &ReferenceVideos::default()).unwrap();+ let plan = api.resolve(&handle).unwrap();+ assert_eq!(plan.num_model_evaluations, 4);+ let description = api.describe(&handle).unwrap();+ assert!(description.contains("renoise"), "{description}");+ assert!(description.contains("shift 12"), "{description}");+ assert!(description.contains("shift 2"), "{description}");+ }+ }+ let ordinary = Configuration::from_settings(&BTreeMap::new());+ assert_ne!(configuration.timing_profile("1.16.0", ComputePlatform::Vulkan), ordinary.timing_profile("1.16.0", ComputePlatform::Vulkan));+}+#[test]fn image_edit_recipe_disables_motion_cache_and_keeps_source_geometry() {let references = ReferenceVideos::default();diff --git a/src-tauri/src/weights/lora.rs b/src-tauri/src/weights/lora.rsindex 687a985..c259eb9 100644--- a/src-tauri/src/weights/lora.rs+++ b/src-tauri/src/weights/lora.rs@@ -1,4 +1,36 @@use super::*;+use std::io::Read;+use sha2::{Digest, Sha256};++const GRID_URL: &str = "https://huggingface.co/deAPI-ai/minimax-h3-33b-int8/resolve/ee696877efb4553214cb8d920d5617fd3309b910/loras/h3_silu_temb_grid.safetensors";+const GRID_SIZE: u64 = 5_510_600;++fn adapter_header(path: &Path) -> Result<serde_json::Map<String, serde_json::Value>, String> {+ let mut file = fs::File::open(path).map_err(|e| e.to_string())?;+ let mut length = [0u8; 8];+ file.read_exact(&mut length).map_err(|e| e.to_string())?;+ let length = u64::from_le_bytes(length);+ if length == 0 || length > 16 * 1024 * 1024 || length + 8 > file.metadata().map_err(|e| e.to_string())?.len() {+ return Err("Invalid LoRA SafeTensors header length.".into());+ }+ let mut header = vec![0u8; length as usize];+ file.read_exact(&mut header).map_err(|e| e.to_string())?;+ serde_json::from_slice(&header).map_err(|e| format!("Invalid LoRA SafeTensors header: {e}"))+}++fn download_legacy_grid(directory: &Path) -> Result<(), String> {+ let url = download_url(GRID_URL)?;+ let cached = transfer(&url, directory, &AtomicBool::new(false), |_, _| {})?;+ if fs::metadata(&cached).map_err(|e| e.to_string())?.len() != GRID_SIZE {+ return Err("Downloaded timestep grid has an unexpected size.".into());+ }+ let bytes = fs::read(&cached).map_err(|e| e.to_string())?;+ if format!("{:x}", Sha256::digest(&bytes)) != "30eb3c2cc7fb6b470d9717ff840d359313ac27cd64b705e32da1baa10f72d6a8" {+ return Err("Downloaded timestep grid failed SHA-256 verification.".into());+ }+ // A hard link publishes the verified file without overwriting a local companion.+ fs::hard_link(cached, directory.join("h3_silu_temb_grid.safetensors")).map_err(|e| e.to_string())+}/// Runs before inference, while no model reader can hold the adapter open.fn prepare(@@ -10,7 +42,14 @@ fn prepare(let _models = model_access.try_write().map_err(|_| "Model files are in use. Prepare the LoRA after generation finishes.")?;- // Slopfab owns format validation, asset selection and atomic embedding.+ let header = adapter_header(path)?;+ // DMAD only targets attention/MLP projections. The explicit grid API always+ // expects a grid, even for adapters whose inference never needs one.+ if !header.keys().any(|key| key.contains("adaln_proj"))+ && header.keys().any(|key| key.contains(".lora.") || key.contains(".lora_")) {+ return Ok(());+ }+ // Slopfab owns grid validation, asset selection and atomic embedding.// Preserve the URL record even on an idempotent retry after a record-write error.let record_path = path.with_extension("complete.json");let record = fs::read(&record_path)@@ -22,7 +61,17 @@ fn prepare(== Some(destination_name(&url).as_str())})});- crate::slopfab::prepare_lora_grid(path, width, allow_download)?;+ if let Err(error) = crate::slopfab::prepare_lora_grid(path, width, false) {+ let directory = path.parent().ok_or("LoRA has no parent directory.")?;+ let custom_grid = header.get("__metadata__").and_then(|m| m.get("slopfab.lora_grid")).is_some();+ if !allow_download || width != 2688 || custom_grid+ || directory.join("h3_silu_temb_grid.safetensors").exists()+ || !(error.contains("local companion file:") || error.contains("no matching embedded AdaLN grid")) {+ return Err(error);+ }+ download_legacy_grid(directory)?;+ crate::slopfab::prepare_lora_grid(path, width, false)?;+ }if let Some(mut record) = record {record.bytes = fs::metadata(path).map_err(|error| error.to_string())?.len();fs::write(@@ -63,6 +112,40 @@ mod tests {fs::write(path, data).unwrap();}+ #[test]+ fn dmad_projections_need_no_companion_or_rewrite() {+ let folder = tempfile::tempdir().unwrap();+ let path = folder.path().join("dmad.safetensors");+ fixture(&path, "transformer_blocks.0.attn.to_q.lora.down.weight", &[2, 2]);+ let original = fs::read(&path).unwrap();+ for allow_download in [false, true] {+ prepare(&path, 2688, allow_download, &std::sync::RwLock::new(())).unwrap();+ assert_eq!(fs::read(&path).unwrap(), original);+ assert_eq!(fs::read_dir(folder.path()).unwrap().count(), 1);+ }+ }++ #[test]+ fn malformed_adapter_headers_fail_without_allocating_from_untrusted_length() {+ let folder = tempfile::tempdir().unwrap();+ let path = folder.path().join("bad.safetensors");+ fs::write(&path, u64::MAX.to_le_bytes()).unwrap();+ assert!(adapter_header(&path).unwrap_err().contains("header length"));+ }++ #[test]+ fn cached_grid_must_match_pinned_bytes_before_publication() {+ let folder = tempfile::tempdir().unwrap();+ let url = download_url(GRID_URL).unwrap();+ let cached = folder.path().join(destination_name(&url));+ fs::write(&cached, vec![0u8; GRID_SIZE as usize]).unwrap();+ fs::write(cached.with_extension("complete.json"), serde_json::to_vec(&CompletedFile {+ url: url.to_string(), bytes: GRID_SIZE,+ }).unwrap()).unwrap();+ assert!(download_legacy_grid(folder.path()).unwrap_err().contains("SHA-256"));+ assert!(!folder.path().join("h3_silu_temb_grid.safetensors").exists());+ }+#[test]fn preparation_preserves_download_discovery_and_is_idempotent() {let model_access = std::sync::RwLock::new(());@@ -85,7 +168,7 @@ mod tests {assert!(cached_file(&path, &url));let companion = folder.path().join("h3_silu_temb_grid.safetensors");fixture(&companion, "silu_t_emb_grid", &[1025, 2]);- prepare(&path, 2, false, &model_access).unwrap();+ prepare(&path, 2, true, &model_access).unwrap();let embedded = fs::read(&path).unwrap();assert!(embedded.len() > original.len());assert!(cached_file(&path, &url));diff --git a/src/components/LoraSettings.tsx b/src/components/LoraSettings.tsxindex a22cd47..a9b1162 100644--- a/src/components/LoraSettings.tsx+++ b/src/components/LoraSettings.tsx@@ -58,6 +58,7 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => vconst [path, setPath] = useState(existing?.path ?? "");const [override, setOverride] = useState(existing?.stepOverride !== undefined);const [steps, setSteps] = useState(String(existing?.stepOverride ?? 3));+ const [samplingPreset, setSamplingPreset] = useState(existing?.samplingPreset);const [error, setError] = useState<string | null>(null);const [saving, setSaving] = useState(false);const [allowDownload, setAllowDownload] = useState(true);@@ -72,7 +73,7 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => vif (!name.trim()) setName(picked.split(/[\\/]/).pop()!.replace(/\.safetensors$/i, ""));} catch (reason) { setError(String(reason)); }};- const invalid = !name.trim() || (!path.trim() && !existing?.url) || (override && !isLoraStepOverride(Number(steps)));+ const invalid = !name.trim() || (!path.trim() && !existing?.url) || (!samplingPreset && override && !isLoraStepOverride(Number(steps)));const save = async () => {if (invalid) return;if (path.trim() && (!/^(?:[a-z]:[\\/]|\\\\|\/)/i.test(path.trim()) || path.includes("\0"))) {@@ -84,7 +85,7 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => vawait prepareLora({ id: loraId, name: name.trim(), path: path.trim() }, allowDownload);}const library = loadLoras();- const entry: Lora = { ...library.find(({ id }) => id === loraId), id: loraId, name: name.trim(), path: path.trim(), stepOverride: override ? Number(steps) : undefined,+ const entry: Lora = { ...library.find(({ id }) => id === loraId), id: loraId, name: name.trim(), path: path.trim(), samplingPreset, stepOverride: !samplingPreset && override ? Number(steps) : undefined,...(path.trim() !== existing?.path ? { needsPreparation: undefined } : {}) };saveLoras(existing ? library.map((lora) => lora.id === loraId ? entry : lora) : [...library, entry]);if (mounted.current) onDone();@@ -98,9 +99,13 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => v<label>Name<input className="text-field" aria-label="LoRA name" value={name} onChange={(event) => setName(event.target.value)} /></label><label>Local file<span className="lora-manual__path"><input className="text-field" aria-label="LoRA path" value={path} spellCheck={false} onChange={(event) => setPath(event.target.value)} placeholder="Absolute path to a .safetensors file" /><button className="secondary-button" type="button" disabled={!isTauri()} onClick={() => void browse()}>Browse…</button></span></label>- <Checkbox aria-label="Override step count" checked={override} onChange={setOverride} label="Override step count"- description="The highest override among active LoRAs replaces the scene's step count." />- {override && <label>Step count<input className="text-field" aria-label="LoRA step override" type="number" min={2} max={MAX_GENERATION_STEPS} step={1} value={steps} onChange={(event) => setSteps(event.target.value)} /></label>}+ <label>Sampling recipe<ComboBox aria-label="LoRA sampling recipe" value={samplingPreset ?? "default"}+ onChange={(value) => setSamplingPreset(value === "dmad-4step" ? value : undefined)}+ options={[{ value: "default", label: "Default" }, { value: "dmad-4step", label: "DMAD 4-Step" }]} /></label>+ {samplingPreset && <InfoBar severity="informational" message="DMAD uses four re-noising evaluations with video/audio shifts of 12/2. Its fixed schedule overrides step counts and turns off MotionCache." />}+ {!samplingPreset && <Checkbox aria-label="Override step count" checked={override} onChange={setOverride} label="Override step count"+ description="The highest override among active LoRAs replaces the scene's step count." />}+ {!samplingPreset && override && <label>Step count<input className="text-field" aria-label="LoRA step override" type="number" min={2} max={MAX_GENERATION_STEPS} step={1} value={steps} onChange={(event) => setSteps(event.target.value)} /></label>}<Checkbox aria-label="Download missing timestep grid" checked={allowDownload} onChange={setAllowDownload} label="Download missing timestep grid"description="New files are prepared in place before use, which may embed a timestep grid." />{error && <InfoBar severity="error" message={error} />}@@ -111,6 +116,7 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => vexport function TemplateLorasEditor({ value, onChange }: { value: TemplateLora[]; onChange: (value: TemplateLora[]) => void }) {const library = useLoras();const active = value.filter((entry) => entry.enabled && entry.strength !== 0);+ const dmad = active.some((entry) => library.find(({ id }) => id === entry.loraId)?.samplingPreset === "dmad-4step");const stepOverride = highestLoraStepOverride(active.flatMap((entry) => library.filter(({ id }) => id === entry.loraId)));const available = library.filter((entry) => (entry.path || entry.url) && !value.some(({ loraId }) => loraId === entry.id));@@ -139,6 +145,7 @@ export function TemplateLorasEditor({ value, onChange }: { value: TemplateLora[]onChange={(loraId) => { if (loraId) onChange([...value, { loraId, enabled: true, strength: 1 }]); }}options={available.map((lora) => ({ value: lora.id, label: lora.name }))} /></SettingsCard>- {stepOverride !== undefined && <InfoBar severity="informational" message={`Active LoRAs set the scene's step count to ${stepOverride}, the highest selected override.`} />}+ {dmad ? <InfoBar severity="informational" message="DMAD fixes generation to four re-noising evaluations and turns off MotionCache." />+ : stepOverride !== undefined && <InfoBar severity="informational" message={`Active LoRAs set the scene's step count to ${stepOverride}, the highest selected override.`} />}</SettingsGroup>;}diff --git a/src/components/SettingsView.downloads.test.tsx b/src/components/SettingsView.downloads.test.tsxindex 8cda651..b199ace 100644--- a/src/components/SettingsView.downloads.test.tsx+++ b/src/components/SettingsView.downloads.test.tsx@@ -9,7 +9,7 @@ import { loadGeneratorTemplateSettings, minimaxSingularityTemplate } from "../liimport { getWeightDownloadState } from "../lib/weightDownloads";import { WorkQueuePanel } from "./WorkQueuePanel";import { WorkQueue } from "../lib/workQueue";-import { loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA } from "../lib/loras";+import { DMAD_LORA, loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA } from "../lib/loras";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));@@ -20,6 +20,23 @@ const pick = (name: string, option: string) => {};const card = (openLabel: string) => screen.getByRole("button", { name: openLabel }).closest(".settings-open-card") as HTMLElement;+it("downloads DMAD, preserves its sampling recipe when edited, and explains its fixed grid", async () => {+ render(<SettingsView onClose={() => undefined} />);+ fireEvent.click(screen.getByRole("button", { name: "Edit DMAD 4-Step LoRA" }));+ expect(screen.getByRole("combobox", { name: "LoRA sampling recipe" })).toHaveTextContent("DMAD 4-Step");+ expect(screen.queryByLabelText("Override step count")).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Save" }));+ await waitFor(() => expect(screen.queryByRole("dialog")).not.toBeInTheDocument());+ expect(loadLoras().find(({ id }) => id === DMAD_LORA.id)?.samplingPreset).toBe("dmad-4step");+ fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));+ pick("Add LoRA to generator", DMAD_LORA.name);+ expect(screen.getByText(/DMAD fixes generation to four/)).toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Download weights" }));+ await waitFor(() => expect(getWeightDownloadState()).toMatchObject({ active: false, completed: 1, error: null }));+ expect(invoke).toHaveBeenCalledWith("download_weight", expect.objectContaining({ url: DMAD_LORA.url }));+ expect(loadLoras().find(({ id }) => id === DMAD_LORA.id)).toMatchObject({ samplingPreset: "dmad-4step", path: expect.stringContaining("dmad_minimax_h3") });+});+it("keeps a failed local import editable and supports local-only preparation", async () => {const normal = vi.mocked(invoke).getMockImplementation()!;vi.mocked(invoke).mockImplementation(async (command, args) => {diff --git a/src/lib/loras.test.ts b/src/lib/loras.test.tsindex e855c1f..ed0b0fd 100644--- a/src/lib/loras.test.ts+++ b/src/lib/loras.test.ts@@ -1,6 +1,6 @@// @vitest-environment jsdomimport { beforeEach, expect, it } from "vitest";-import { downloadableTemplateLoras, LIGHTX2V_TURBO_LORA, loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA } from "./loras";+import { DMAD_LORA, downloadableTemplateLoras, LIGHTX2V_TURBO_LORA, loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA } from "./loras";import { createGeneratorTemplate, engineProviderSetting, generationStepsWithLoras, loadGeneratorTemplateSettings, saveGeneratorTemplateSettings, withEngineSettings } from "./settings";import { createProjectConfig } from "./project";@@ -66,9 +66,28 @@ it.each([0, 1, -3, 2.5, NaN, Infinity, 2147483648])("rejects invalid step overri});it("starts with the bundled adapters and preserves the local library", () => {- expect(loadLoras()).toEqual([TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA, LIGHTX2V_TURBO_LORA]);+ expect(loadLoras()).toEqual([TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA, LIGHTX2V_TURBO_LORA, DMAD_LORA]);saveLoras([{ ...TAOMATE_LORA, path: "C:/weights/TaoMate.safetensors" }, { id: "style", name: "Style", path: "D:/style.safetensors" }]);- expect(loadLoras().map(({ name }) => name)).toEqual(["TaoMate 3-Step", "Style", "Turbo", "Viggle Animate Distillation", "LightX2V Turbo"]);+ expect(loadLoras().map(({ name }) => name)).toEqual(["TaoMate 3-Step", "Style", "Turbo", "Viggle Animate Distillation", "LightX2V Turbo", "DMAD 4-Step"]);+});++it("preserves DMAD's recipe and local path and gives its fixed grid priority over step overrides", () => {+ saveLoras([{ ...DMAD_LORA, path: "D:/renamed.safetensors" }, { ...LIGHTX2V_TURBO_LORA, path: "D:/style.safetensors" }]);+ expect(loadLoras().find(({ id }) => id === DMAD_LORA.id)).toMatchObject({ path: "D:/renamed.safetensors", samplingPreset: "dmad-4step" });+ const paths = createGeneratorTemplate().paths;+ const selection = [+ { loraId: DMAD_LORA.id, enabled: true, strength: 1 },+ { loraId: LIGHTX2V_TURBO_LORA.id, enabled: true, strength: 0.5 },+ ];+ const provider = engineProviderSetting(paths, undefined, "sage2", selection, "prompt", [], true);+ expect(provider.options).toMatchObject({ samplingPreset: "dmad-4step", stepOverride: 4 });+ expect(provider.options).not.toHaveProperty("motionCache");+ expect(engineProviderSetting(paths, provider, "sage2", [...selection].reverse()).options.stepOverride).toBe(4);+ for (const inactive of [{ enabled: false, strength: 1 }, { enabled: true, strength: 0 }]) {+ const without = engineProviderSetting(paths, provider, "sage2", [{ ...selection[0], ...inactive }, selection[1]], "prompt", [], true);+ expect(without.options).not.toHaveProperty("samplingPreset");+ expect(without.options).toMatchObject({ stepOverride: 6, motionCache: true });+ }});it("round-trips template order, enabled flags and strengths, and sends only active adapters", () => {diff --git a/src/lib/loras.ts b/src/lib/loras.tsindex d36f5d8..3f08ed2 100644--- a/src/lib/loras.ts+++ b/src/lib/loras.ts@@ -7,6 +7,7 @@ export interface Lora {path: string;url?: string;stepOverride?: number;+ samplingPreset?: "dmad-4step";needsPreparation?: boolean;}export interface TemplateLora { loraId: string; enabled: boolean; strength: number }@@ -30,6 +31,11 @@ export const LIGHTX2V_TURBO_LORA: Lora = {url: "https://huggingface.co/silveroxides/MiniMax-H3_tests/resolve/main/experimental/minimax_h3_fl2v_lightx2v_turbo_4to8step_v0.1-v1.0_768p_v4_step600_dareties.safetensors",stepOverride: 6,};+export const DMAD_LORA: Lora = {+ id: "dmad-4step", name: "DMAD 4-Step", path: "",+ url: "https://huggingface.co/ZhengmingYu/DMAD/resolve/main/minimax_h3/dmad_minimax_h3_4step_full_critic.safetensors",+ samplingPreset: "dmad-4step",+};const KEY = "slopus.loras.v1";const EVENT = "slopus:loras-changed";export function loadLoras(): Lora[] {@@ -41,6 +47,7 @@ export function loadLoras(): Lora[] {|| typeof entry.name !== "string" || !entry.name.trim() || typeof entry.path !== "string") return [];ids.add(entry.id);return [{ id: entry.id, name: entry.name, path: entry.path,+ ...(entry.samplingPreset === "dmad-4step" ? { samplingPreset: "dmad-4step" as const } : {}),...(entry.needsPreparation === true ? { needsPreparation: true } : {}),...(typeof entry.url === "string" && /^https?:\/\//i.test(entry.url) ? { url: entry.url } : {}),...(isLoraStepOverride(entry.stepOverride) ? { stepOverride: entry.stepOverride }@@ -50,8 +57,9 @@ export function loadLoras(): Lora[] {if (!ids.has(TURBO_LORA.id)) entries.push({ ...TURBO_LORA });if (!ids.has(VIGGLE_ANIMATE_LORA.id)) entries.push({ ...VIGGLE_ANIMATE_LORA });if (!ids.has(LIGHTX2V_TURBO_LORA.id)) entries.push({ ...LIGHTX2V_TURBO_LORA });+ if (!ids.has(DMAD_LORA.id)) entries.push({ ...DMAD_LORA });return entries;- } catch { return [{ ...TAOMATE_LORA }, { ...TURBO_LORA }, { ...VIGGLE_ANIMATE_LORA }, { ...LIGHTX2V_TURBO_LORA }]; }+ } catch { return [{ ...TAOMATE_LORA }, { ...TURBO_LORA }, { ...VIGGLE_ANIMATE_LORA }, { ...LIGHTX2V_TURBO_LORA }, { ...DMAD_LORA }]; }}export function saveLoras(loras: Lora[]): void {if (loras.some((lora) => lora.stepOverride !== undefined && !isLoraStepOverride(lora.stepOverride))) {@@ -92,7 +100,7 @@ export function resolveTemplateLoras(selection: TemplateLora[] = []) {if (!lora?.path.trim() || /^https?:\/\//i.test(lora.path)) {throw new Error(`Download or locate LoRA ${lora?.name ?? entry.loraId}, or disable it in the generator template.`);}- return [{ path: lora.path.trim(), strength, stepOverride: lora.stepOverride }];+ return [{ path: lora.path.trim(), strength, stepOverride: lora.stepOverride, samplingPreset: lora.samplingPreset }];});}diff --git a/src/lib/settings.ts b/src/lib/settings.tsindex 1634c74..e944ced 100644--- a/src/lib/settings.ts+++ b/src/lib/settings.ts@@ -473,6 +473,7 @@ export function engineProviderSetting(settings: EngineSettings, base?: ProviderSdelete options.loras;delete options.schedule;delete options.stepOverride;+ delete options.samplingPreset;delete options.generationMode;delete options.promptEmbedding;delete options.motionCache;@@ -486,6 +487,12 @@ export function engineProviderSetting(settings: EngineSettings, base?: ProviderSif (loras.length) options.loras = JSON.stringify(loras.map(({ path, strength }) => ({ path, strength })));const stepOverride = highestLoraStepOverride(loras);if (stepOverride !== undefined) options.stepOverride = stepOverride;+ if (loras.some((lora) => lora.samplingPreset === "dmad-4step")) {+ options.samplingPreset = "dmad-4step";+ // The fixed sigma grid defines four evaluations and forbids approximate caches.+ options.stepOverride = 4;+ delete options.motionCache;+ }for (const field of ENGINE_PATH_FIELDS) {if (mode === "animate" && (field.id === "textEncoder" || field.id === "tokenizer")) {delete options[field.id];diff --git a/src/lib/weightDownloads.test.ts b/src/lib/weightDownloads.test.tsindex 92af09a..df51318 100644--- a/src/lib/weightDownloads.test.ts+++ b/src/lib/weightDownloads.test.ts@@ -1,7 +1,7 @@// @vitest-environment jsdomimport { invoke } from "@tauri-apps/api/core";import { cancelWeightDownload, downloadLora, prepareLora, removeLora, refreshDownloadedLoras, retryWeightDownload } from "./weightDownloads";-import { LIGHTX2V_TURBO_LORA, loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA } from "./loras";+import { DMAD_LORA, LIGHTX2V_TURBO_LORA, loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA } from "./loras";import { beforeEach, expect, it, vi } from "vitest";import { chooseWeightSource, downloadTemplateWeights, getWeightDownloadState, refreshDownloadedWeights, removeTemplateWeights, updateWeightPath, weightDownloadProgress, type DownloadState } from "./weightDownloads";import { ANIMATE_CONDITIONING_URL, engineProviderSetting, createGeneratorTemplate, defaultGeneratorTemplate, isDownloadUrl, loadGeneratorTemplateSettings, minimaxOriginalTemplate, minimaxSingularityTemplate, saveGeneratorTemplateSettings, templateNeedsDownload, type WeightSource } from "./settings";@@ -134,14 +134,15 @@ it("preserves additional file edits while a download is in flight and retries faexpect(getWeightDownloadState()).toMatchObject({ active: false, completed: 1, error: null });});-it.each([TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA, LIGHTX2V_TURBO_LORA])("downloads $name through the weight transfer and restores missing downloads", async (lora) => {+it.each([TAOMATE_LORA, TURBO_LORA, VIGGLE_ANIMATE_LORA, LIGHTX2V_TURBO_LORA, DMAD_LORA])("downloads $name through the weight transfer and restores missing downloads", async (lora) => {const savedLora = () => loadLoras().find(({ id }) => id === lora.id)!;await downloadLora(lora.id);expect(invoke).toHaveBeenCalledWith("download_weight", { requestId: expect.any(String), url: lora.url });const path = `C:/Slopus/weights/${lora.url!.split('/').at(-1)}`;- expect(savedLora()).toMatchObject({ path, stepOverride: lora.stepOverride });+ expect(savedLora()).toMatchObject({ ...lora, path });const options = engineProviderSetting(createGeneratorTemplate().paths, undefined, "sage2", [{ loraId: lora.id, enabled: true, strength: 1 }]).options;- expect(options.stepOverride).toBe(lora.stepOverride);+ expect(options.stepOverride).toBe(lora.samplingPreset === "dmad-4step" ? 4 : lora.stepOverride);+ expect(options.samplingPreset).toBe(lora.samplingPreset);expect(JSON.parse(options.loras as string)).toEqual([{ path, strength: 1 }]);expect(getWeightDownloadState()).toMatchObject({ loraId: lora.id, active: false, completed: 1, error: null });files.clear();