SparseID · Technical Note Nov 2026

3-Subject Open Benchmark · Krea 2 int8 & MOSS Image · ZenTrainer

SparseID: CPU Latent-Crop Face Identity Supervision for Rectified-Flow LoRAs

Henry Lee · Brisbane, AU · Dataset: nynxz/OpenCharacters · Code: ZenTrainer
SparseID CPU latent-crop identity gradient diagram on Hana showing only the ~9% padded face latent crop decoded on CPU while ~91% of the latent is skipped
Figure 1 — Overview: Only the padded face patch of the active clean prediction x̂₀ transfers to CPU for VAE decode and frozen 5-point ArcFace loss; on wide in-the-wild shots like Hana above, ~91% of the latent is never decoded, keeping peak GPU VRAM unchanged while PyTorch autograd routes λ · ∂L_id / ∂x̂₀[face] straight back into the single LoRA backward pass.
0.612 → 0.755
Held-out portrait likeness
500-step AntelopeV2 · 24/24 wins (Hana, Sora, Kieran)
0.522 → 0.699
Changed-attribute overrides
500-step AntelopeV2 · 12/12 wins (blonde, glasses)
0.489 → 0.752
Trigger-only neutral probe
No gender cue in prompt · 6/6 wins (+0.263)
15.8 GB · +6.1%
Peak VRAM & CPU overhead
Matches control VRAM · +31–32 s over 500 steps (~0.44 s/crop)

00 Side-by-Side Visual Comparison (Matched Seeds)

Each row shows three uncut faces side by side: a strictly held-out reference photo never seen during training, standard flow matching (Control), and SparseID on the exact same seed. Comparing full faces side-by-side highlights four distinct failure modes where flow matching drifts and SparseID locks identity: trigger-only wrong-gender priors, hair-color eye/identity drift, harsh night lighting, and 250-step facial artifacts.

Held-out Reference · Hana
Held-out reference portrait of Hana
Control (flow matching)Av2 0.39
Control render on trigger-only neutral prompt defaulting to a male face
SparseID CPUAv2 0.71 (+0.32)
SparseID render cleanly locking Hana on the same trigger-only prompt
1. Trigger-only prompt without a gender noun (Hana, 500 steps, seed 42). Without writing "a woman", Control collapses to Krea 2's male studio prior (0.39); SparseID binds the trigger directly to Hana (0.71).
Held-out Reference · Hana
Held-out reference portrait of Hana
Control (flow matching)Av2 0.43
Control blonde hair render shifting Hana to green eyes and an older stranger face
SparseID CPUAv2 0.69 (+0.26)
SparseID blonde hair render keeping Hana's brown eyes and facial structure
2. Changed-attribute override — short blonde hair (Hana, 500 steps, seed 271). Changing hair color breaks Control's identity binding (green eyes, older stranger face, 0.43); SparseID preserves Hana's warm brown eyes, brows, and nose while following the blonde override (0.69).
Held-out Reference · Sora
Held-out reference portrait of Sora
Control (flow matching)Av2 0.59
Control night street flash render losing Sora's hazel-green eyes and bone structure
SparseID CPUAv2 0.79 (+0.20)
SparseID night street flash render locking Sora's hazel-green eyes and sharp cheekbones
3. Harsh night flash lighting (Sora, 500 steps, seed 271). Control reverts to dark brown eyes and a soft generic jaw (0.59); SparseID holds Sora's bright hazel-green eyes, arched brows, and cheekbones (0.79).
Held-out Reference · Mira
Held-out reference portrait of Mira
Control (250 steps)Av2 0.51
Control 250-step night flash render hallucinating facial hair on Mira
SparseID (43 updates)Av2 0.74 (+0.23)
SparseID 250-step night flash render cleanly matching Mira
4. Fast 250-step convergence under dark lighting (Mira, 43 updates). Control hallucinates a mustache and goatee under night flash (0.51); SparseID eliminates it completely and locks Mira's face in 43 sparse updates (0.74).

01 Method & Scope

Decoding x0_pred, scoring with frozen ArcFace, and backpropagating through the VAE is established in personalization literature (PortraitBooth, PuLID, ConsisID) and in ai-toolkit-perceptual. SparseID focuses on single-GPU quantized DiTs: slice only the padded face patch in latent space (~9–16% area), decode through the exact real VAE on CPU in bf16, warp via differentiable 5-point grid_sample, and fire sparsely (0.10 ≤ σ ≤ 0.65, every = 2).

STEP 01Offline
5-Point Landmarks & Centroid

Pure-PyTorch SCRFD/YuNet extracts upright-pixel landmarks and an outlier-filtered LOO ArcFace centroid per trigger.

STEP 02CPU · 0 VRAM
Latent-Space Face Crop

Slice face + 32 px context from x̂₀ (~9–16% area) and decode through the real VAE on CPU in bf16.

STEP 03Single Backward
5-Point Warp & Sparse Loss

Differentiable 112×112 grid_sample + frozen ArcFace on eligible steps (0.10 ≤ σ ≤ 0.65, every = 2).

python
# Map upright original-pixel 5-point landmarks into the active stage bucket (e.g. 512 or 768 px)
left, top, right, bottom, grid = crop_plan(orig_size, points, latent_hw, stride)

# Slice face + 32 px receptive-field border; autograd preserves the GPU -> CPU -> GPU edge
raw = model.process_latent_out(x0_pred[j : j + 1])
z_crop = raw[..., top:bottom, left:right].to("cpu", torch.bfloat16)

with torch.autocast("cpu", dtype=torch.bfloat16):
    rgb = vae_decoder.decode(z_crop)  # ~16x smaller spatial patch, 0 extra GPU VRAM

# Differentiable 5-point ArcFace warp (112x112) with black padding in [-1, 1] space
crop = F.grid_sample(rgb.float().clamp(-1, 1) + 1.0, grid, align_corners=True) - 1.0
emb = F.normalize(iresnet(crop), dim=1)
loss = weight * (1.0 - (emb * target_centroid).sum()).to(x0_pred.device)

02 500-Step 3-Subject Benchmark (Hana, Sora, Kieran)

Matched 500-step Krea 2 int8 runs (512 px steps 1–125, 768 px steps 126–500, offloading on, 15.8–16.0 GB peak VRAM) trained with buffalo_l only and evaluated against 6 strictly held-out photos per subject across three recognizers (antelopev2, buffalo_l, Apache-2.0 AuraFace-v1).

Figure 2: Pooled 500-step 3-subject held-out cosine similarity (Hana + Sora + Kieran)

Gray = Control (flow matching) · Lime = SparseID CPU (70–84 updates) · Amber = Untriggered same-gender bleed (preserve off, lower is better)

42/42 matched-render wins across Hana, Sora, and Kieran (24/24 portraits, 12/12 changed-attribute overrides, 6/6 gender-neutral trigger-only probes) with lower held-out validation MSE on every subject. Gains transfer identically to both unseen recognizers (antelopev2 +0.143, AuraFace-v1 +0.143).

Figure 3: Per-subject 500-step held-out AntelopeV2 cosine similarity

Every individual subject improves +0.127 to +0.206 on both portraits and attribute overrides (Gray = Control · Lime = SparseID)

Consistency check: pooled gains aren't driven by a single subject — Hana, Sora, and Kieran each win 100% of their portrait and attribute-override renders.

500-Step Arm Upd. Time¹ VRAM Val Av2 P Av2 O Neutral Same-G ↓ BL P Au P
Pooled 3-Subject Control 0 512 s¹ 15.9 GB — 0.612 0.522 0.489 0.568 0.605 0.580
Pooled 3-Subject SparseID CPU 75 544 s¹ 15.8 GB — 0.755 0.699 0.752 0.747 0.766 0.723
Sora · Control 0 513 s 15.8 GB 0.06731 0.614 0.552 0.420 0.632 0.602 0.635
Sora · SparseID CPU 72 545 s 15.8 GB 0.06668 0.792 0.722 0.805 0.808 0.791 0.758
Sora · Early iREPA + SparseID 72 546 s 15.8 GB 0.06693 0.785 0.737 0.630 0.793 0.787 0.770
Sora · Commercial AuraFace-v1 68 545 s 15.8 GB 0.06686 0.717 0.646 0.721 0.701 0.705 0.734
Kieran · Control 0 511 s 15.8 GB 0.06255 0.654 0.536 0.669 0.578 0.674 0.533
Kieran · SparseID CPU 70 542 s 15.8 GB 0.06251 0.779 0.742 0.821 0.750 0.801 0.706
Kieran · Commercial AuraFace-v1 66 543 s 15.8 GB 0.06248 0.702 0.657 0.754 0.636 0.699 0.746
Hana · Control 0 —¹ 16.0 GB 0.07679 0.568 0.477 0.379 0.495 0.540 0.573
Hana · SparseID CPU (λ=0.02, every=2) 84 —¹ 15.8 GB 0.07637 0.695 0.632 0.630 0.683 0.706 0.705
Hana · Early iREPA only (1–125) 0 —¹ 15.8 GB 0.07592 0.591 0.496 0.401 0.501 0.569 0.608
Hana · Early iREPA (1–125) + SparseID 84 —¹ 15.8 GB 0.07661 0.666 0.626 0.750 0.673 0.671 0.677
Hana · Noise-weighted + 50/50 hybrid 84 —¹ 15.8 GB 0.07570 0.684 0.617 0.480 0.633 0.685 0.672
Hana · SparseID + Prior-Latent DOP (every=4) 95 —¹ 15.9 GB 0.07726 0.649 0.621 0.606 0.592 0.659 0.669

¹ Wall-time note: Uncontended overhead is measured on the clean back-to-back Sora (513 → 545 s, +6.2%) and Kieran (511 → 542 s, +6.1%) sweeps: +31–32 s (+6.1%, ~0.44 s per CPU crop decode). The earlier Hana 500-step batch ran with intermittent background GPU contention (Control 719 s vs SparseID 626 s), so Hana wall times are omitted from the pooled timing comparison rather than skewing Control slower than SparseID.

Early DINOv3-L iREPA & Sparse Prior-Latent DOP

Two complementary techniques tested on Hana at 500 steps: (1) adding early DINOv3-L iREPA (steps 1–125) before SparseID flipped Hana's stuck gender-neutral seed cleanly (0.55 → 0.73; neutral mean 0.630 → 0.750), and (2) caching 8 generic base-model class latents (~2.3 MB) for Sparse Prior-Latent DOP (every = 4, w = 1.5) cut SparseID's extra untriggered "a woman" bleed roughly in half (0.683 → 0.592).

Control (seed 271)Av2 0.37
Control render on gender-neutral probe seed 271 drawing a man
SparseID aloneAv2 0.55
SparseID alone render pulling the face toward Hana while keeping short hair
Early iREPA + SparseIDAv2 0.73
Early iREPA plus SparseID flipping seed 271 cleanly into Hana
Early iREPA (steps 1–125) + SparseID on Hana's hardest neutral seed (seed 271). Control draws a man (0.37); SparseID pulls the face toward Hana (0.55); anchoring global layout early with DINOv3-L iREPA flips the seed completely into Hana (0.73). (Subject-dependent: on Sora, SparseID alone already hit 0.805.)
Held-out Reference · Hana
Held-out reference portrait of Hana
SparseID · untriggered "a woman"Av2 0.70 (bleed)
Untriggered woman prompt with SparseID alone bleeding Hana's face and bangs
+ Prior-Latent DOPAv2 0.61 ↓
Untriggered woman prompt with Prior-Latent DOP restoring a distinct generic woman
Controlling class bleed on untriggered "a woman" prompts (seed 42, lower is better). Without DOP, SparseID leaks Hana's bangs and face onto generic prompts (0.70); running DOP on 8 independent base-model prior latents restores a distinct generic woman (0.61; mean 0.683 → 0.592) while keeping attribute overrides intact (0.621 vs. 0.632).
Why Standard x_t-Anchored DOP Fails — and Why Independent Prior Latents Work

Standard DOP distills base(x_t, "a woman") on the noisy training latent x_t. At mid/low noise (σ ∈ [0.10, 0.65]), x_t still contains the subject's own face, so the base model denoises toward the subject and reinforces bleed. Sampling 8 generic class latents directly from the frozen base model (~2.3 MB, zero PNGs) and applying DOP sparsely on those independent latents cuts extra same-gender bleed roughly in half (0.683 → 0.592) at +0.1 GB VRAM. (Note: trainable attention layers are required so the adapter can gate trigger vs. class; MLP-only adapters cannot separate them.)

03 250-Step Ablations & MOSS 16× VAE

Controlled 250-step sweeps across Hana, Mira, and Tomas (16 arms total; 36/36 matched Krea 2 wins, 0.597 → 0.713 portraits) isolating weight λ, sparsity every, CPU vs. GPU crop, commercial Apache-2.0 AuraFace-v1, and a second architecture (MOSS Image Base with 32-channel 16× flux2-vae).

Figure 4: Weight λ tradeoff — Portrait likeness vs. untriggered bleed (Mira, step 250, every = 2)

Evenly spaced across λ ∈ {0, 0.005, 0.02, 0.08} · Lime = Portrait likeness (↑) · Amber = Untriggered "a woman" bleed (↓)

Sweet spot: λ = 0.005–0.02. Both weights hit peak portrait likeness (0.733–0.735 vs 0.638 control) with λ = 0.005 achieving the lowest validation loss (0.06964). Pushing 4× higher to λ = 0.08 drops portrait consistency (0.697) and pushes same-gender bleed to 0.855.

Practical Takeaways (CPU vs. GPU, Commercial License & 16× VAEs)

CPU vs. GPU crop: On Hana, device="gpu" ran 8 s faster (267 vs 275 s) and scored 0.635 vs 0.618, at +1.7 GB peak VRAM (22.2 vs 20.5 GB).

Auto-margin hinge (face_id_margin = 0.82): On 1,250-step Krea 2 LoKr runs, gating the identity loss with ReLU(0.82 - cos) shuts off identity gradients once a training crop already exceeds 0.82 cosine — preventing late-step overcooking and lowering bleed (0.861 → 0.834) at zero extra cost.

Commercial license (Apache-2.0 / MIT): Training directly with AuraFace-v1 + YuNet transfers back to unseen InsightFace models (0.597 → 0.642 portraits, 0.552 → 0.641 overrides pooled) while adding less than one-third the extra same-gender bleed of buffalo_l.

Heavy 32-channel 16× VAEs: On MOSS Image Base (flux2-vae), peak VRAM stayed below control (23.3 vs 23.9 GB) and portrait likeness rose 0.456 → 0.512, but 33 CPU crop decodes doubled wall time (264 → 525 s, ~7.9 s/decode) — use every = 4–8 or device="gpu" on 32-channel VAEs.

Full 16-Arm 250-Step Ablation Table (Hana, Mira, Tomas & MOSS Image)
250-Step Arm Upd. Time VRAM Val Av2 P Av2 O Same-G ↓ Au P
Hana · Control (Krea 2 int8) 0 281 s¹ 20.5 GB 0.07530 0.458 0.408 0.429 0.435
Hana · Default CPU (λ=0.02, every=2) 42 275 s 20.5 GB 0.07525 0.618 0.582 0.595 0.601
Hana · GPU crop (device="gpu") 42 267 s 22.2 GB 0.07586 0.635 0.593 0.561 0.575
Hana · Commercial (AuraFace-v1) 40 271 s 20.5 GB 0.07487 0.567 0.555 0.491 0.686
Mira · Control (Krea 2 int8) 0 245 s 20.4 GB 0.07029 0.638 0.622 0.778 0.559
Mira · Ultra-sparse (every=8) 10 244 s 20.4 GB 0.06996 0.607 0.702 0.811 0.508
Mira · Light (λ=0.005, every=2) 43 262 s 20.4 GB 0.06964 0.733 0.715 0.829 0.671
Mira · Default (λ=0.02, every=2) 43 263 s 20.4 GB 0.07055 0.735 0.726 0.842 0.646
Mira · Heavy (λ=0.08, every=2) 43 264 s 20.4 GB 0.07000 0.697 0.784 0.855 0.565
Mira · Commercial (AuraFace-v1) 42 283 s 20.4 GB 0.07099 0.634 0.709 0.778 0.566
Tomas · Control (Krea 2 int8) 0 253 s 20.4 GB 0.06596 0.696 0.625 0.657 0.659
Tomas · Ultra-sparse (every=8) 15 266 s 20.4 GB 0.06518 0.750 0.674 0.685 0.696
Tomas · Default (λ=0.02, every=2) 54 301 s 20.4 GB 0.06570 0.785 0.732 0.730 0.705
Tomas · Commercial (AuraFace-v1) 53 324 s 20.4 GB 0.06646 0.726 0.660 0.682 0.713
Mira · MOSS Control (16× flux2-vae) 0 264 s 23.9 GB 0.51072 0.456 0.540 0.661 0.444
Mira · MOSS SparseID (λ=0.02) 33 525 s 23.3 GB 0.51254 0.512 0.558 0.673 0.470

¹ Hana Control was the first cold-cache run of the 250-step sweep (including initial latent/caption encoding); clean warm-cache overhead is +7.4% on Mira (245 → 263 s) and +18.9% on Tomas (253 → 301 s).

04 Citation & References

bibtex
@misc{lee2026sparseid,
  title        = {SparseID: CPU Latent-Crop Face Identity Supervision for Rectified-Flow LoRAs},
  author       = {Henry Lee},
  year         = {2026},
  month        = {November},
  howpublished = {\url{https://nynxz.com/blog/sparse-id}},
  note         = {Implemented in ZenTrainer (\url{https://github.com/Nynxz/ZenTrainer}); evaluated on OpenCharacters (\url{https://huggingface.co/datasets/nynxz/OpenCharacters})}
}

References & Prior Art

  1. OpenCharacters — H. Lee. OpenCharacters: Consent-Free CC-BY-4.0 Fictional Character Benchmark (Hana, Sora, Kieran, Mira & Tomas). 2026. nynxz/OpenCharacters
  2. PortraitBooth — X. Peng et al. PortraitBooth: A Versatile Portrait Model for Fast Identity-preserved Personalization. CVPR 2024. arXiv:2312.06354
  3. PuLID — Z. Guo et al. PuLID: Pure and Lightning ID Customization via Contrastive Alignment. NeurIPS 2024. arXiv:2404.16022
  4. ConsisID — S. Yuan et al. Identity-Preserving Text-to-Video Generation by Frequency Decomposition. CVPR 2025. arXiv:2411.17440
  5. ArcFace — J. Deng et al. ArcFace: Additive Angular Margin Loss for Deep Face Recognition. CVPR 2019. arXiv:1801.07698
  6. SCRFD — J. Guo et al. Sample and Computation Redistribution for Efficient Face Detection. ICLR 2022. arXiv:2105.04714
  7. YuNet — W. Wu, H. Peng, S. Yu. YuNet: A Tiny Millisecond-level Face Detector. MIR 2023. OpenCV Zoo
  8. AuraFace-v1 — fal.ai. Apache-2.0 ArcFace R100 face recognizer. Hugging Face
  9. AI Toolkit & ai-toolkit-perceptual — Ostris (ostris/ai-toolkit, Differential Output Preservation) and community perceptual anchoring fork (ai-toolkit-perceptual).
  10. Base Models — Krea 2, MOSS Image, and FLUX.2.