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([flux2-multi-reference-python-runner]): address codex review

[._.]/ Adam Eivyc9d9fd730de9
diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsx
index 28fcac63f9..7b33df7c57 100644
--- a/client/src/pages/ImageGen.jsx
+++ b/client/src/pages/ImageGen.jsx
@@ -1070,18 +1070,19 @@ export default function ImageGen() {
Reference images <span className="text-gray-500 font-normal">(up to 4 images for FLUX.2 multi-reference edit)</span>
</label>
{/*
- Experimental: the server contract (upload slots, packing, sidecar
- metadata, CLI flag emission) is wired end-to-end, but the bundled
- FLUX.2 Python runner currently accepts `--reference-images` /
- `--reference-strengths` as no-op argparse stubs — the references
- are NOT yet conditioned into the diffusion graph. Full multi-ref
- inference is tracked as `[flux2-multi-reference-python-runner]`
- in PLAN.md (gated on the FLUX.2-klein-9B-kv HF license).
+ FLUX.2 multi-reference editing — references are now conditioned
+ via diffusers' Flux2KleinKVPipeline (K/V-cache reference-token
+ attention). First-time use prompts the user to accept the
+ FLUX.2-klein-9B-kv license on Hugging Face. Per-reference
+ strengths are submitted but not honored — the KV pipeline
+ doesn't expose per-ref attention weighting today, so any
+ non-1.0 value logs a warning and is treated as 1.0.
*/}
<div className="mb-2 px-2 py-1.5 text-[11px] text-port-warning/90 bg-port-warning/10 border border-port-warning/30 rounded">
- <strong className="font-semibold">Experimental — no-op today:</strong> Uploads + strengths are
- staged and forwarded to the runner, but the FLUX.2 Python script ignores them. Final inference wiring
- is pending the multi-reference runner upgrade.
+ <strong className="font-semibold">Per-reference strengths not honored yet:</strong> uploads
+ condition the output via diffusers' KV-cache multi-reference pipeline, but the strength sliders
+ are advisory — the pipeline doesn't expose per-reference attention weighting in its current
+ release, so all references are applied at full influence.
</div>
<div className="grid grid-cols-2 sm:grid-cols-4 gap-2">
{referenceImages.map((slot, i) => {
diff --git a/scripts/flux2_macos.py b/scripts/flux2_macos.py
index 41144027e0..0d4316890e 100755
--- a/scripts/flux2_macos.py
+++ b/scripts/flux2_macos.py
@@ -82,10 +82,28 @@ def _resolve_pipeline_cls(use_kv: bool):
"""Pick the diffusers pipeline class. `Flux2KleinKVPipeline` uses K/V-cached
reference-token attention for multi-reference editing; both classes share
the same component init signature (scheduler/vae/text_encoder/tokenizer/
- transformer/is_distilled), so any flux2-klein repo loads into either."""
- from diffusers import Flux2KleinKVPipeline, Flux2KleinPipeline
+ transformer/is_distilled), so any flux2-klein repo loads into either.
- return Flux2KleinKVPipeline if use_kv else Flux2KleinPipeline
+ Imports are lazy + branch-specific so a venv whose diffusers pin predates
+ the KV pipeline (i.e. before `Flux2KleinKVPipeline` was added upstream)
+ still serves single-image renders. The KV branch fails loudly with a clear
+ upgrade hint instead of an opaque ImportError mid-load."""
+ if use_kv:
+ try:
+ from diffusers import Flux2KleinKVPipeline
+ except ImportError:
+ print(
+ "❌ Multi-reference editing requires diffusers with "
+ "Flux2KleinKVPipeline. Re-run "
+ "`INSTALL_FLUX2=1 FLUX2_FORCE_REINSTALL=1 bash scripts/setup-image-video.sh` "
+ "to pick up the latest diffusers HEAD.",
+ file=sys.stderr,
+ )
+ sys.exit(65)
+ return Flux2KleinKVPipeline
+ from diffusers import Flux2KleinPipeline
+
+ return Flux2KleinPipeline
def load_pipeline_bf16(repo: str, device: str, dtype, pipeline_cls):
diff --git a/server/services/imageGen/local.js b/server/services/imageGen/local.js
index acfe63288d..9b45b9994e 100644
--- a/server/services/imageGen/local.js
+++ b/server/services/imageGen/local.js
@@ -339,7 +339,13 @@ export async function generateImage({ pythonPath, prompt, negativePrompt = '', m
.filter(Boolean);
const validReferenceImagePaths = validReferences.map((r) => r.path);
const validReferenceImageStrengths = validReferences.map((r) => r.strength);
- const meta = { id: jobId, prompt, negativePrompt, modelId, seed: actualSeed, width: Number(width), height: Number(height), steps: actualSteps, guidance: actualGuidance, quantize, filename, loraFilenames: validLoraFilenames, loraPaths: validLoras, loraScales, initImageFilename: validInitImagePath ? basename(validInitImagePath) : null, initImageStrength: validInitImageStrength, referenceImageFilenames: validReferenceImagePaths.map((p) => basename(p)), referenceImageStrengths: validReferenceImageStrengths, createdAt: new Date().toISOString() };
+ // `referenceImageStrengthsRequested` (not `…Strengths`) because the KV
+ // pipeline doesn't yet expose per-reference attention weighting — non-1.0
+ // values come through the route but the runner only warns, so the sidecar
+ // must not claim they were applied. Mirror with the Python sidecar's
+ // `referenceStrengthsRequested` field. Rename to `…Strengths` when
+ // diffusers exposes a real per-ref knob.
+ const meta = { id: jobId, prompt, negativePrompt, modelId, seed: actualSeed, width: Number(width), height: Number(height), steps: actualSteps, guidance: actualGuidance, quantize, filename, loraFilenames: validLoraFilenames, loraPaths: validLoras, loraScales, initImageFilename: validInitImagePath ? basename(validInitImagePath) : null, initImageStrength: validInitImageStrength, referenceImageFilenames: validReferenceImagePaths.map((p) => basename(p)), referenceImageStrengthsRequested: validReferenceImageStrengths, createdAt: new Date().toISOString() };
const job = { ...meta, clients: [], status: 'running' };
jobs.set(jobId, job);