Merge branch 'master' into update-comfyui-workflow-templates-0.11.24-20260802-215736

This commit is contained in:
Daxiong (Lin)
2026-08-03 01:17:33 +08:00
committed by GitHub
3 changed files with 32 additions and 16 deletions

View File

@@ -671,6 +671,19 @@ def pin_eviction_tiers(loaded, evict_active):
tiers.append((PIN_SUBSETS, True, True))
return tiers
def registration_eviction_tiers(evict_active):
subsets = PIN_SUBSETS + LOADED_PIN_SUBSETS
tiers = [
(subsets, False, False),
(subsets, True, False),
]
if evict_active:
tiers.extend([
(subsets, False, True),
(subsets, True, True),
])
return tiers
def free_pins(size, evict_active=False, loaded=False):
freed = 0
for subsets, current_prompt, active in pin_eviction_tiers(loaded, evict_active):
@@ -703,19 +716,19 @@ def ensure_pin_budget(size, evict_active=False, loaded=False):
to_free = shortfall + PIN_PRESSURE_HYSTERESIS
return free_pins(to_free, evict_active=evict_active, loaded=loaded) >= shortfall
def free_registrations(shortfall, evict_active=True, loaded=False):
def free_registrations(shortfall, evict_active=True):
if MAX_PINNED_MEMORY <= 0:
return False
if shortfall <= 0:
return True
shortfall += REGISTERABLE_PIN_HYSTERESIS
for subsets, current_prompt, active in pin_eviction_tiers(loaded, evict_active):
for subsets, current_prompt, active in registration_eviction_tiers(evict_active):
shortfall -= free_model_pins(shortfall, subsets, current_prompt, active, registrations=True)
return shortfall <= REGISTERABLE_PIN_HYSTERESIS
def ensure_pin_registerable(size, evict_active=True, loaded=False):
return free_registrations(TOTAL_PINNED_MEMORY + size - MAX_PINNED_MEMORY, evict_active=evict_active, loaded=loaded)
def ensure_pin_registerable(size, evict_active=True):
return free_registrations(TOTAL_PINNED_MEMORY + size - MAX_PINNED_MEMORY, evict_active=evict_active)
class LoadedModel:
def __init__(self, model: ModelPatcher):

View File

@@ -56,7 +56,7 @@ def get_pin(module, subset="weights"):
_, _, stack_split, pinned_size, *_ = module._pin_state[subset]
size = pin.nbytes
comfy.model_management.ensure_pin_registerable(size, loaded=subset.endswith("-loaded"))
comfy.model_management.ensure_pin_registerable(size)
if torch.cuda.cudart().cudaHostRegister(pin.data_ptr(), size, 1) != 0:
comfy.model_management.discard_cuda_async_error()
@@ -93,7 +93,7 @@ def pin_memory(module, subset="weights", size=None):
comfy.memory_management.extra_ram_release(comfy.memory_management.RAM_CACHE_HEADROOM)
if (not comfy.model_management.ensure_pin_budget(size, loaded=loaded) or
not comfy.model_management.ensure_pin_registerable(registerable_size, loaded=loaded)):
not comfy.model_management.ensure_pin_registerable(registerable_size)):
return _steal_pin(module, stack, buckets, size, priority, subset)
offset = hostbuf.size
@@ -105,7 +105,7 @@ def pin_memory(module, subset="weights", size=None):
pin.untyped_storage()._comfy_hostbuf = hostbuf
if torch.cuda.cudart().cudaHostRegister(pin.data_ptr(), size, 1) != 0:
comfy.model_management.discard_cuda_async_error()
comfy.model_management.free_registrations(size, loaded=loaded)
comfy.model_management.free_registrations(size)
if torch.cuda.cudart().cudaHostRegister(pin.data_ptr(), size, 1) != 0:
comfy.model_management.discard_cuda_async_error()
del pin

View File

@@ -467,7 +467,7 @@ def _hailuo03_model_inputs(include_ratio: bool = True, allow_adaptive: bool = Tr
),
IO.Combo.Input(
"resolution",
options=["2K"],
options=["768P", "2K"],
tooltip="Resolution of the output video.",
),
]
@@ -578,11 +578,12 @@ class MinimaxHailuo03TextToVideoNode(IO.ComfyNode):
],
is_api_node=True,
price_badge=IO.PriceBadge(
depends_on=IO.PriceBadgeDepends(widgets=["model.duration"]),
depends_on=IO.PriceBadgeDepends(widgets=["model.resolution", "model.duration"]),
expr="""
(
$dur := $lookup(widgets, "model.duration");
{"type": "usd", "usd": $dur * 0.1859}
$rate := $lookup(widgets, "model.resolution") = "768p" ? 0.1287 : 0.1859;
{"type": "usd", "usd": $dur * $rate}
)
""",
),
@@ -660,11 +661,12 @@ class MinimaxHailuo03FirstLastFrameNode(IO.ComfyNode):
],
is_api_node=True,
price_badge=IO.PriceBadge(
depends_on=IO.PriceBadgeDepends(widgets=["model.duration"]),
depends_on=IO.PriceBadgeDepends(widgets=["model.resolution", "model.duration"]),
expr="""
(
$dur := $lookup(widgets, "model.duration");
{"type": "usd", "usd": $dur * 0.1859}
$rate := $lookup(widgets, "model.resolution") = "768p" ? 0.1287 : 0.1859;
{"type": "usd", "usd": $dur * $rate}
)
""",
),
@@ -818,20 +820,21 @@ class MinimaxHailuo03ReferenceNode(IO.ComfyNode):
is_api_node=True,
price_badge=IO.PriceBadge(
depends_on=IO.PriceBadgeDepends(
widgets=["model.duration"],
widgets=["model.resolution", "model.duration"],
input_groups=["model.reference_images", "model.reference_videos"],
),
expr="""
(
$dur := $lookup(widgets, "model.duration");
$rate := $lookup(widgets, "model.resolution") = "768p" ? 0.1287 : 0.1859;
$imgsRaw := $lookup(inputGroups, "model.reference_images");
$imgs := $imgsRaw ? $imgsRaw : 0;
$vidsRaw := $lookup(inputGroups, "model.reference_videos");
$vids := $vidsRaw ? $vidsRaw : 0;
$base := $dur * 0.1859 + ($imgs > 5 ? ($imgs - 5) * 0.0572 : 0);
$base := $dur * $rate + ($imgs > 5 ? ($imgs - 5) * 0.0572 : 0);
$vids > 0
? {"type": "range_usd", "min_usd": $base + $vids * 2 * 0.1859,
"max_usd": $base + 15 * 0.1859, "format": {"approximate": true}}
? {"type": "range_usd", "min_usd": $base + $vids * 2 * $rate,
"max_usd": $base + 15 * $rate, "format": {"approximate": true}}
: {"type": "usd", "usd": $base}
)
""",