A second, independent node — Anima Role Ref KV Apply — was added to anima_role_ref_kv: it returns a patched MODEL instead of running its own sampler, and shares one adapter engine with the original sampler node, so the two coexist without affecting each other.

Four real defects were fixed along the way: v2.0 Diffusers/PEFT-named adapters were rejected (added a key mapping and relaxed validation), a KeyError appeared when an fp32 residual stream ran on bf16 weights (weight tables are now built lazily per dtype), timesteps → sigma applied the schedule shift twice and produced pure noise (now t / multiplier), and reference RoPE positions were computed in pixels instead of latent units, which scrambled the composition (now latent units); the reference KV also no longer leaks into the unconditional branch when cfg > 1.

Text context is now read from the sampler's own model call, so upstream text patches such as negpip stay effective, with positive / negative demoted to optional fallbacks.

Verified by py_compile on all files and 21/21 offline checks; in ComfyUI the reference reproduces correctly with an acceleration LoRA at cfg 1, and the original node is unchanged.

AnticPan changed pull request status to merged

Thanks a lot for the PR, and for the detailed write-up. I went through the diff and checked it against my training and inference code.

RoPE units: the original sampler calls reference(..., (height//8, width//8)), which is the same as x.shape[-2:]. Your fix is correct.
Sigma: the model already receives the shifted t, so t / multiplier is the right inverse, and model_sampling.sigma() does apply the shift twice. Good catch.
Adapter keys and alpha: the v2.0 adapters are trained with rank 128 and alpha 128, so the missing alpha defaulting to the rank (scale 1.0) is equivalent. from_diffusers also looks right.
cfg > 1: injecting the reference into the cond branch only matches the original behavior.

Before merging I'd like to run an A/B check. I'll use the same seed, 28 steps, shift 3 and cfg 4, and compare Anima Role Ref KV against Apply with inject = cond only. I also want to test lowvram/offload and a style LoRA stacked on top, since the engine calls the block linears directly. Could you share which ComfyUI version and which sampler/scheduler you used for your test, and whether you tried cfg > 1?

I'll merge once the comparison looks consistent. Thanks again!

Sign up or log in to comment