Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: route H3 LoRAs through runtime-aware layout checks

[._.]/ Adam Eivy40412347faad
diff --git a/scripts/minimax_h3_lora.py b/scripts/minimax_h3_lora.py
index 6e8b4cee46..a42d69bb55 100644
--- a/scripts/minimax_h3_lora.py
+++ b/scripts/minimax_h3_lora.py
@@ -152,8 +152,9 @@ def _normalize_target(target: str) -> tuple[str, str]:
def _parse_tensor_key(key: str) -> tuple[str, str, str] | None:
+ lowered = key.lower()
for suffix, kind in _LORA_SUFFIXES:
- if key.endswith(suffix):
+ if lowered.endswith(suffix.lower()):
target = key[:-len(suffix)]
target, source_layout = _normalize_target(target)
return target, kind, source_layout
diff --git a/scripts/minimax_h3_lora.test.js b/scripts/minimax_h3_lora.test.js
index f3c0d8de2d..8837980c6b 100644
--- a/scripts/minimax_h3_lora.test.js
+++ b/scripts/minimax_h3_lora.test.js
@@ -57,7 +57,7 @@ describe.skipIf(!pyBin)('minimax_h3_lora.py', () => {
' path = Path(temp) / "adapter_native.safetensors"',
' down = mx.arange(32, dtype=mx.float32).reshape(1, 32) / 32',
' up = mx.arange(24, dtype=mx.float32).reshape(24, 1) / 24',
- ' mx.save_safetensors(str(path), {"blocks.0.attn.qkv_proj.lora_A.weight": down, "blocks.0.attn.qkv_proj.lora_B.weight": up, "blocks.0.attn.qkv_proj.alpha": mx.array([1.0])})',
+ ' mx.save_safetensors(str(path), {"blocks.0.attn.qkv_proj.lora_a.weight": down, "blocks.0.attn.qkv_proj.lora_b.weight": up, "blocks.0.attn.qkv_proj.alpha": mx.array([1.0])})',
' apply_loras(model, [{"path": str(path), "scale": 0.5}])',
' after = model.blocks[0].attn.qkv_proj(x)',
' expected = before + ((x @ down.T) @ up.T) * 0.5',
diff --git a/server/services/videoGen/generateVideo.js b/server/services/videoGen/generateVideo.js
index fe29ff1801..d4c3c1966a 100644
--- a/server/services/videoGen/generateVideo.js
+++ b/server/services/videoGen/generateVideo.js
@@ -304,9 +304,9 @@ export async function generateVideo({ pythonPath, prompt, negativePrompt = '', m
// Resolve LoRA basenames → absolute { path, strength } pairs up-front so a
// missing/typo'd LoRA fails with a clean 400 before any GPU work. buildArgs
- // rejects LoRAs on non-ltx2 runtimes (the route also guards), so this is a
- // no-op there.
- const resolvedLoras = await resolveVideoLoras(loras, { probeEffect: true });
+ // rejects LoRAs on runtimes without a compatible loader (the route also
+ // guards), so this remains a no-op for those doomed jobs.
+ const resolvedLoras = await resolveVideoLoras(loras, { probeEffect: true, runtime: model.runtime });
// `model` was decorated from a SYNC cache read, which is false on a cold
// cache. Resolve the probe and re-decorate from the settled verdict before
// buildArgs reads it off the snapshot — otherwise the first LoRA render after
diff --git a/server/services/videoGen/local.test.js b/server/services/videoGen/local.test.js
index 8dca72b5ba..f7d7924407 100644
--- a/server/services/videoGen/local.test.js
+++ b/server/services/videoGen/local.test.js
@@ -4320,6 +4320,18 @@ describe('resolveVideoLoras — safetensors key-layout gate', () => {
}
});
+ it('lets the MiniMax H3 adapter handle Diffusers and kohya layouts', async () => {
+ for (const layout of ['diffusers', 'kohya']) {
+ loraLayoutState.layout = layout;
+ expect(await resolveVideoLoras(
+ [{ filename: 'style.safetensors', scale: 0.7 }],
+ { runtime: 'minimax_h3' },
+ )).toEqual([
+ { path: join(MOCK_PATHS.loras, 'style.safetensors'), strength: 0.7, filename: 'style.safetensors' },
+ ]);
+ }
+ });
+
it('rejects a kohya-layout LoRA with an actionable 400 naming the layout', async () => {
loraLayoutState.layout = 'kohya';
await expect(resolveVideoLoras([{ filename: 'style.safetensors', scale: 1.0 }]))
diff --git a/server/services/videoGen/renderArgs.js b/server/services/videoGen/renderArgs.js
index 4f17a5c65d..30d0d439d5 100644
--- a/server/services/videoGen/renderArgs.js
+++ b/server/services/videoGen/renderArgs.js
@@ -155,15 +155,15 @@ export const resolveT2vTwoStageOverride = ({
// basename can't escape PATHS.loras (assertSafeLoraFilename) and that the file
// exists — a typo or a deleted LoRA would otherwise surface as an opaque
// Python FileNotFoundError deep inside the render. Returns [] for no LoRAs.
-// Only the ltx2 runtime consumes the result; buildArgs rejects LoRAs on the
-// other runtimes before this is even reached for a doomed job.
+// The ltx2 and MiniMax H3 MLX runtimes consume the result; buildArgs rejects
+// LoRAs on the other runtimes before this is even reached for a doomed job.
//
// Also gates on the safetensors KEY LAYOUT. The loader fuses `lora_A`/`lora_B`
-// pairs after stripping a leading `diffusion_model.`, so a kohya (lora_down/
-// lora_up) or diffusers/PEFT-prefixed file matches nothing: the render burns
-// minutes of GPU time and comes back as an un-LoRA'd (or noisy) clip with no
-// error anywhere. Refuse it up front with the layout named.
-export const resolveVideoLoras = async (loras, { probeEffect = false } = {}) => {
+// pairs after stripping a leading `diffusion_model.`. The MiniMax H3 adapter
+// also normalizes kohya (lora_down/lora_up) and Diffusers/PEFT-prefixed files,
+// so only the LTX loader keeps the older layout restriction. Refuse an
+// unsupported LTX layout up front with the layout named.
+export const resolveVideoLoras = async (loras, { probeEffect = false, runtime = null } = {}) => {
if (!Array.isArray(loras) || loras.length === 0) return [];
const out = [];
// ONE budget for every selected adapter, not one each. This runs before
@@ -177,7 +177,7 @@ export const resolveVideoLoras = async (loras, { probeEffect = false } = {}) =>
throw new ServerError(`LoRA not found: ${l.filename}`, { status: 400, code: 'LORA_NOT_FOUND' });
}
const layout = await getLoraKeyLayout(l.filename);
- const issue = videoLoraLayoutIssue(layout);
+ const issue = runtime === 'minimax_h3' ? null : videoLoraLayoutIssue(layout);
if (issue) {
throw new ServerError(
`LoRA "${l.filename}" can't be used for video: ${issue}.`,