fix(sampler): the value function path steered without saying so

Only the fixed-direction fallback announced its lift, so a working value
function was indistinguishable from nothing happening.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
digital-garbage
2026-08-21 01:50:25 +03:00
co-authored by Claude Opus 5
parent 3e6cb7fbb3
commit e409ac8f82
2 changed files with 16 additions and 0 deletions
+8
View File
@@ -4894,6 +4894,14 @@ class FunPackLTXAVSceneChainSampler:
grad = value_fn.gradient(source)
unit = torch.nn.functional.normalize(grad.float(), dim=-1)
vf_state["d"] = self._direction_in_cond_space(model, raw_cond, unit, cond)
if vf_state["d"] is not None:
# Say so out loud: the fixed-direction fallback announces itself when it
# lifts, so silence here reads as "nothing happened" rather than success.
lifted = int(vf_state["d"].shape[-1]) != int(unit.shape[-1])
print("[FunPackSceneChain] embed_guidance: steering on the value function "
"gradient" + (f", lifted {int(unit.shape[-1])} -> "
f"{int(vf_state['d'].shape[-1])} through the model's own "
"text preprocessor" if lifted else ""))
if vf_state["d"] is None:
print("[FunPackSceneChain] embed_guidance: the value function gradient "
"cannot be mapped onto this model's conditioning, using fixed direction")
+8
View File
@@ -884,3 +884,11 @@ def test_an_unusable_value_function_falls_back_to_the_fixed_direction(capsys):
out = capsys.readouterr().out
assert out.count("value function gradient failed") == 1 # once per run, not per step
assert not torch.equal(seen["cond"], cond) # fixed direction still steers
def test_a_working_value_function_says_so_instead_of_steering_silently(capsys):
_run_embed_wrapper_with_vf(_h3ish_model(), torch.randn(1, 12, TEXT_DIM),
torch.randn(1, 12, HIDDEN), _RawSpaceValueFunction(), steps=4)
out = capsys.readouterr().out
assert out.count("steering on the value function gradient") == 1
assert "5120 -> 5376" in out