Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.63 KB

pulid.md

File metadata and controls

38 lines (27 loc) · 1.63 KB

PuLID implementation and validation

For model files, identity preparation, and generation commands, see the PuLID usage guide.

Architecture summary

The PuLID-Flux contribution to the Flux denoise loop is a stack of 20 small cross-attention modules (PerceiverAttentionCA) inserted between the Flux transformer blocks:

  • After every 2nd of the 19 double-stream blocks (10 hook points)
  • After every 4th of the 38 single-stream blocks (10 hook points)

Each cross-attention layer takes the current image tokens as query, the 32-token / 2048-dim identity embedding as key+value, and adds its output (scaled by id_weight, typically 1.0) back to the image tokens.

Identity embedding format

The extraction script writes a float32 NumPy array of shape (num_tokens, 2048), typically (32, 2048). DGL reads it with tensor::load as [2048, num_tokens], with the token dimension contiguous. pulid::apply checks the tensor's dtype and shape.

Verification

A three-way SHA-256 check is the recommended sanity test when bringing up a new combination of model + backend + hardware:

Run Expected hash relation
A: DGL condition without pulid::apply baseline
B: same script with pulid::apply(..., strength = 0) byte-identical to A
C: same script with pulid::apply(..., strength = 1) different from A,B, preserves source identity

If A and C differ but A and B differ too, the injection is allocating or computing something even at zero weight -- likely a bug.