Fix value function loading: torch.load inside inference_mode(False)
Model weights loaded via torch.load inside ComfyUI's inference_mode become inference tensors and can't participate in backward. Wrapping the load in inference_mode(False) ensures parameters are normal autograd tensors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
55d905e6ee
commit
e999a96d9b
+4
-2
@@ -1296,10 +1296,12 @@ class FunPackLTXAVSceneChainSampler:
|
||||
except ImportError:
|
||||
from value_function import OnlineValueFunction
|
||||
from conditioning import refinement_state_path
|
||||
import os as _os
|
||||
path = refinement_state_path(refinement_key, "value_fn", prefix="refine_v2", extension="pt")
|
||||
if not __import__("os").path.exists(path):
|
||||
if not _os.path.exists(path):
|
||||
return None
|
||||
vf = OnlineValueFunction.load(path)
|
||||
with torch.inference_mode(False):
|
||||
vf = OnlineValueFunction.load(path)
|
||||
return vf if vf.is_ready() else None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user