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

address review: drop reference images on the bf16 LoRA route, forward inflate errors

[._.]/ Adam Eivya9b368e07739
diff --git a/server/lib/zipStream.js b/server/lib/zipStream.js
index de676206a9..8a8c34e1fb 100644
--- a/server/lib/zipStream.js
+++ b/server/lib/zipStream.js
@@ -95,7 +95,11 @@ export function parseZip() {
pipe(dest) {
piped = true;
if (method === 8) {
- passThrough.pipe(createInflateRaw()).pipe(dest);
+ const inflate = createInflateRaw();
+ // Forward inflate failures (corrupt deflate stream) to dest so a
+ // consumer awaiting completion rejects/errors instead of hanging.
+ inflate.on('error', (err) => dest.destroy(err));
+ passThrough.pipe(inflate).pipe(dest);
} else {
passThrough.pipe(dest);
}
diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.js
index 6d5f633a49..6d16290100 100644
--- a/server/services/imageGen/local.js
+++ b/server/services/imageGen/local.js
@@ -140,11 +140,13 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, he
let repo = model.repo;
let quantization = model.quantization || 'sdnq';
let { tokenizerRepo, basePipelineRepo, kvRepo } = model;
+ let refImagePaths = referenceImagePaths;
+ let refImageStrengths = referenceImageStrengths;
// LoRA + quantized base is incompatible: PEFT can't inject an adapter into
// SDNQ/int8-quantized Linear layers, and the runner swallows the failure
// into a base render (lora_utils.apply_loras), so the LoRA silently does
// nothing. The adapter was trained against the bf16 base anyway — route the
- // render onto it. (kvRepo dropped: multi-ref editing + LoRA isn't auto-routed.)
+ // render onto it.
if (loraPaths?.length && quantization !== 'none') {
const bf16 = flux2Bf16BaseRepo(model);
if (!bf16) {
@@ -158,7 +160,17 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, he
quantization = 'none';
tokenizerRepo = null;
basePipelineRepo = null;
+ // Multi-reference editing needs the `-kv` sibling repo, which the bf16
+ // LoRA route doesn't load (and the 4B variant has none). Drop the refs so
+ // the LoRA render proceeds as txt2img/i2i instead of the runner hard-
+ // failing on the missing kv pipeline — the LoRA is the primary intent
+ // when one is attached. i2i (single init image) is unaffected.
kvRepo = null;
+ if (refImagePaths?.length) {
+ console.log(`⚠️ flux2 LoRA render dropped ${refImagePaths.length} reference image(s) — multi-ref editing isn't supported on the bf16 LoRA route`);
+ refImagePaths = [];
+ refImageStrengths = [];
+ }
}
if (quantization !== 'sdnq' && quantization !== 'int8' && quantization !== 'none') {
throw new ServerError(
@@ -221,10 +233,10 @@ export const buildArgs = ({ pythonPath, model, prompt, negativePrompt, width, he
// The route always emits parallel referenceImageStrengths (defaulting to
// 1.0 per ref); the runner honors them per-reference via a runtime patch
// on Flux2KVLayerCache.store + _flux2_kv_causal_attention.
- if (referenceImagePaths?.length) {
- args.push('--reference-images', ...referenceImagePaths);
- if (referenceImageStrengths?.length) {
- args.push('--reference-strengths', ...referenceImageStrengths.map(String));
+ if (refImagePaths?.length) {
+ args.push('--reference-images', ...refImagePaths);
+ if (refImageStrengths?.length) {
+ args.push('--reference-strengths', ...refImageStrengths.map(String));
}
}
if (stepwiseDir) args.push('--stepwise-image-output-dir', stepwiseDir);
diff --git a/server/services/imageGen/local.test.js b/server/services/imageGen/local.test.js
index 7eb1df556a..5074de7224 100644
--- a/server/services/imageGen/local.test.js
+++ b/server/services/imageGen/local.test.js
@@ -138,6 +138,32 @@ describe('imageGen local.buildArgs flux2 dispatch', () => {
expect(args[args.indexOf('--lora-paths') + 1]).toBe('/data/loras/lora-trained-adam-eivy-768ef285.safetensors');
});
+ it('drops reference images when a LoRA forces the bf16 route (no kv pipeline)', () => {
+ mockResolveFlux2Python.mockReturnValue('/fake/venv-flux2/bin/python3');
+ const { args } = buildArgs({
+ ...baseInput,
+ loraPaths: ['/data/loras/x.safetensors'],
+ loraScales: [1.0],
+ referenceImagePaths: ['/data/images/ref1.png', '/data/images/ref2.png'],
+ referenceImageStrengths: [1.0, 0.8],
+ model: {
+ id: 'flux2-klein-4b',
+ runner: 'flux2',
+ quantization: 'sdnq',
+ repo: 'Disty0/FLUX.2-klein-4B-SDNQ-4bit-dynamic',
+ tokenizerRepo: 'black-forest-labs/FLUX.2-klein-4B',
+ },
+ });
+ // bf16 route taken, and the multi-ref args are dropped so the runner
+ // doesn't hard-fail on the missing kv pipeline.
+ expect(args[args.indexOf('--quantization') + 1]).toBe('none');
+ expect(args).not.toContain('--reference-images');
+ expect(args).not.toContain('--reference-strengths');
+ expect(args).not.toContain('--kv-repo');
+ // The LoRA itself still threads through.
+ expect(args).toContain('--lora-paths');
+ });
+
it('leaves a LoRA render on a bf16 model untouched (already unquantized)', () => {
mockResolveFlux2Python.mockReturnValue('/fake/venv-flux2/bin/python3');
const { args } = buildArgs({