Spaces:
Running on Zero
Spend the unaccelerated steps where the motion is decided
Browse filesThe reference workflow keeps its turbo LoRA out of the first pass - `LoraLoaderModelOnly#221` sits bypassed - and
runs fifteen full steps at 0.3 MP before handing the latent to an eight-step turbo refine at 1.2 MP. This Space had
it the other way round: the rack ran at full weight in both passes, so the pass that starts from pure noise, which
is the one that decides what moves, was always crossing the top of the schedule in a distilled adapter's single
learned jump into its averaged, low-motion result. Six steps by default made that jump 71% of the trajectory.
`DRAFT_LORA_SCALE` (0) is the mirror of `REFINE_LORA_SCALE` (1), and between them the second pass stops being only
a resolution feature. Priced on this Space's own calibration at 1344x768 and 125 frames: an unaccelerated single
pass is 28 steps and about 480s of quota, while an unaccelerated 672x384 draft of 15 steps plus an 8-step turbo
refine at that same target is about 224s. The two-pass route is how an unrushed first pass becomes affordable.
Also here, because the change does not work without them:
* A rack folded into the weights by an earlier request left `set_scale` answering "rack is folded, left as it is",
which would have silently returned the draft to full turbo. `apply(allow_fold=False)` now unfolds it.
* `draft_steps` reached neither `estimate_duration` nor `denoise`, so every booking was priced at the default
fifteen no matter where the slider sat.
* The three positional `estimate_duration` calls now name their tail arguments, since inserting a parameter ahead
of `refine_lora` is exactly what would have broken them without a word.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZysx4SVLM4dtDVWQocQV9
- app.py +26 -7
- h3_engine.py +36 -13
- lora_stack.py +10 -0
|
@@ -33,6 +33,7 @@ def run(
|
|
| 33 |
draft_steps,
|
| 34 |
refine_ladder,
|
| 35 |
resizer,
|
|
|
|
| 36 |
refine_lora,
|
| 37 |
draft_only,
|
| 38 |
duration,
|
|
@@ -71,6 +72,7 @@ def run(
|
|
| 71 |
stack,
|
| 72 |
upscale=float(upscale),
|
| 73 |
refine_ladder=str(refine_ladder) if float(upscale) > 1 else None,
|
|
|
|
| 74 |
refine_lora=float(refine_lora) if float(upscale) > 1 else None,
|
| 75 |
draft_only=bool(draft_only) and float(upscale) > 1,
|
| 76 |
draft_steps=int(draft_steps) if float(upscale) > 1 else None,
|
|
@@ -112,8 +114,9 @@ def cost_readout(canvas, upscale, draft_steps, duration, steps, first_frame, las
|
|
| 112 |
h3_engine.upscaled_canvas(height, width, upscale) if upscale > 1 else (height, width)
|
| 113 |
)
|
| 114 |
booked = h3_engine.estimate_duration(
|
| 115 |
-
None, None, first_frame, last_frame, height, width, frames, steps, 0, racked, upscale,
|
| 116 |
-
|
|
|
|
| 117 |
)
|
| 118 |
quota = booked * h3_engine.quota_multiplier()
|
| 119 |
share = quota / h3_engine.DAILY_QUOTA
|
|
@@ -467,6 +470,21 @@ with gr.Blocks(title="MiniMax H3 Turbo LoRAs") as demo:
|
|
| 467 |
"normalization around it, which it did not before.",
|
| 468 |
visible=False,
|
| 469 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
refine_lora = gr.Slider(
|
| 471 |
0.0,
|
| 472 |
1.0,
|
|
@@ -474,11 +492,10 @@ with gr.Blocks(title="MiniMax H3 Turbo LoRAs") as demo:
|
|
| 474 |
step=0.1,
|
| 475 |
label="Turbo LoRA in the refine pass (two-pass)",
|
| 476 |
info=(
|
| 477 |
-
"
|
| 478 |
-
"
|
| 479 |
-
"
|
| 480 |
-
"
|
| 481 |
-
"in both passes."
|
| 482 |
),
|
| 483 |
visible=False,
|
| 484 |
)
|
|
@@ -606,6 +623,7 @@ with gr.Blocks(title="MiniMax H3 Turbo LoRAs") as demo:
|
|
| 606 |
upscale.change(fn=lambda f: gr.Slider(visible=float(f) > 1), inputs=[upscale], outputs=[draft_steps])
|
| 607 |
upscale.change(fn=lambda f: gr.Dropdown(visible=float(f) > 1), inputs=[upscale], outputs=[refine_ladder])
|
| 608 |
upscale.change(fn=lambda f: gr.Radio(visible=float(f) > 1), inputs=[upscale], outputs=[resizer])
|
|
|
|
| 609 |
upscale.change(fn=lambda f: gr.Slider(visible=float(f) > 1), inputs=[upscale], outputs=[refine_lora])
|
| 610 |
upscale.change(fn=lambda f: gr.Checkbox(visible=float(f) > 1), inputs=[upscale], outputs=[draft_only])
|
| 611 |
randomize.change(fn=lambda on: gr.Number(interactive=not on), inputs=[randomize], outputs=[seed])
|
|
@@ -623,6 +641,7 @@ with gr.Blocks(title="MiniMax H3 Turbo LoRAs") as demo:
|
|
| 623 |
draft_steps,
|
| 624 |
refine_ladder,
|
| 625 |
resizer,
|
|
|
|
| 626 |
refine_lora,
|
| 627 |
draft_only,
|
| 628 |
duration,
|
|
|
|
| 33 |
draft_steps,
|
| 34 |
refine_ladder,
|
| 35 |
resizer,
|
| 36 |
+
draft_lora,
|
| 37 |
refine_lora,
|
| 38 |
draft_only,
|
| 39 |
duration,
|
|
|
|
| 72 |
stack,
|
| 73 |
upscale=float(upscale),
|
| 74 |
refine_ladder=str(refine_ladder) if float(upscale) > 1 else None,
|
| 75 |
+
draft_lora=float(draft_lora) if float(upscale) > 1 else None,
|
| 76 |
refine_lora=float(refine_lora) if float(upscale) > 1 else None,
|
| 77 |
draft_only=bool(draft_only) and float(upscale) > 1,
|
| 78 |
draft_steps=int(draft_steps) if float(upscale) > 1 else None,
|
|
|
|
| 114 |
h3_engine.upscaled_canvas(height, width, upscale) if upscale > 1 else (height, width)
|
| 115 |
)
|
| 116 |
booked = h3_engine.estimate_duration(
|
| 117 |
+
None, None, first_frame, last_frame, height, width, frames, steps, 0, racked, upscale,
|
| 118 |
+
upscaler_path=None, refine_ladder=None, resizer=h3_engine.DEFAULT_RESIZER,
|
| 119 |
+
draft_steps=int(draft_steps), _quiet=True,
|
| 120 |
)
|
| 121 |
quota = booked * h3_engine.quota_multiplier()
|
| 122 |
share = quota / h3_engine.DAILY_QUOTA
|
|
|
|
| 470 |
"normalization around it, which it did not before.",
|
| 471 |
visible=False,
|
| 472 |
)
|
| 473 |
+
draft_lora = gr.Slider(
|
| 474 |
+
0.0,
|
| 475 |
+
1.0,
|
| 476 |
+
value=h3_engine.DRAFT_LORA_SCALE,
|
| 477 |
+
step=0.1,
|
| 478 |
+
label="Turbo LoRA in the draft pass (two-pass)",
|
| 479 |
+
info=(
|
| 480 |
+
"The draft is the pass that starts from pure noise, and that is where the motion "
|
| 481 |
+
"of the clip is decided. A turbo LoRA is distilled to cross that stretch in one "
|
| 482 |
+
"jump and lands in the averaged, low-motion result its distillation settled on - "
|
| 483 |
+
"so 0 is the default and what the reference workflow does. The draft runs at a "
|
| 484 |
+
"quarter of the target's area, where the extra steps are cheap."
|
| 485 |
+
),
|
| 486 |
+
visible=False,
|
| 487 |
+
)
|
| 488 |
refine_lora = gr.Slider(
|
| 489 |
0.0,
|
| 490 |
1.0,
|
|
|
|
| 492 |
step=0.1,
|
| 493 |
label="Turbo LoRA in the refine pass (two-pass)",
|
| 494 |
info=(
|
| 495 |
+
"By the second pass the composition is already fixed and only detail is left, "
|
| 496 |
+
"which is where a turbo LoRA costs nothing and saves the most - so 1 here, as in "
|
| 497 |
+
"the reference workflow. Only distilled adapters are touched; style LoRAs run at "
|
| 498 |
+
"full weight in both passes."
|
|
|
|
| 499 |
),
|
| 500 |
visible=False,
|
| 501 |
)
|
|
|
|
| 623 |
upscale.change(fn=lambda f: gr.Slider(visible=float(f) > 1), inputs=[upscale], outputs=[draft_steps])
|
| 624 |
upscale.change(fn=lambda f: gr.Dropdown(visible=float(f) > 1), inputs=[upscale], outputs=[refine_ladder])
|
| 625 |
upscale.change(fn=lambda f: gr.Radio(visible=float(f) > 1), inputs=[upscale], outputs=[resizer])
|
| 626 |
+
upscale.change(fn=lambda f: gr.Slider(visible=float(f) > 1), inputs=[upscale], outputs=[draft_lora])
|
| 627 |
upscale.change(fn=lambda f: gr.Slider(visible=float(f) > 1), inputs=[upscale], outputs=[refine_lora])
|
| 628 |
upscale.change(fn=lambda f: gr.Checkbox(visible=float(f) > 1), inputs=[upscale], outputs=[draft_only])
|
| 629 |
randomize.change(fn=lambda on: gr.Number(interactive=not on), inputs=[randomize], outputs=[seed])
|
|
|
|
| 641 |
draft_steps,
|
| 642 |
refine_ladder,
|
| 643 |
resizer,
|
| 644 |
+
draft_lora,
|
| 645 |
refine_lora,
|
| 646 |
draft_only,
|
| 647 |
duration,
|
|
@@ -176,13 +176,21 @@ def audio_sigma(video_sigma: float) -> float:
|
|
| 176 |
# missing - a full eight-step refine to resolve its output - came back worse than anything else tried. Reachable
|
| 177 |
# by `H3_RESIZER=learned` for whoever wants to re-open it; not offered in the UI.
|
| 178 |
DEFAULT_RESIZER = os.getenv("H3_RESIZER", "trilinear")
|
| 179 |
-
# What a *distilled* adapter is worth
|
| 180 |
-
#
|
| 181 |
-
#
|
| 182 |
-
#
|
| 183 |
-
#
|
| 184 |
-
#
|
| 185 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
REFINE_LORA_SCALE = float(os.getenv("H3_REFINE_LORA_SCALE", "1"))
|
| 187 |
|
| 188 |
|
|
@@ -798,6 +806,7 @@ def estimate_duration(
|
|
| 798 |
upscaler_path=None,
|
| 799 |
refine_ladder=None,
|
| 800 |
resizer=DEFAULT_RESIZER,
|
|
|
|
| 801 |
refine_lora=None,
|
| 802 |
draft_only=False,
|
| 803 |
draft_steps=None,
|
|
@@ -875,6 +884,7 @@ def denoise(
|
|
| 875 |
upscaler_path=None,
|
| 876 |
refine_ladder=None,
|
| 877 |
resizer=DEFAULT_RESIZER,
|
|
|
|
| 878 |
refine_lora=None,
|
| 879 |
draft_only=False,
|
| 880 |
draft_steps=None,
|
|
@@ -906,8 +916,10 @@ def denoise(
|
|
| 906 |
|
| 907 |
# A rack that has to change weight between the two passes must stay out of the checkpoint, since a folded one
|
| 908 |
# can only be re-weighted by unfusing it first.
|
|
|
|
| 909 |
refine_lora = REFINE_LORA_SCALE if refine_lora is None else float(refine_lora)
|
| 910 |
-
|
|
|
|
| 911 |
applied = lora_stack.apply(PIPE, loras, allow_fold=not rescaled)
|
| 912 |
|
| 913 |
# Timed separately from the rack work above, which is a one-off: this is the number the booking model is
|
|
@@ -919,6 +931,12 @@ def denoise(
|
|
| 919 |
# area or less, and a step's cost falls faster than the area - and what it hands over is the composition
|
| 920 |
# the refine then works from.
|
| 921 |
steps = DRAFT_STEPS if draft_steps is None else int(draft_steps)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
state = PIPE(
|
| 923 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 924 |
text_token_tags=text_token_tags,
|
|
@@ -971,7 +989,6 @@ def denoise(
|
|
| 971 |
# is about a tenth of what the transformer reads - enough to carry the composition the coarse pass found,
|
| 972 |
# not enough to carry its blur. A separate generator, so the refine noise does not shift the draw order
|
| 973 |
# the draft pass already consumed from the request's own.
|
| 974 |
-
distilled = [spec.adapter for spec in loras if getattr(spec, "distilled", False)]
|
| 975 |
if distilled:
|
| 976 |
print(
|
| 977 |
f"[lora] refine pass: {lora_stack.set_scale(PIPE, refine_lora, distilled)}",
|
|
@@ -1022,7 +1039,8 @@ def denoise(
|
|
| 1022 |
# ---------------------------------------------------------------------------
|
| 1023 |
def generate(
|
| 1024 |
prompt, first_path, last_path, canvas, duration, steps, seed, loras=(), upscale=1.0, refine_ladder=None,
|
| 1025 |
-
resizer=DEFAULT_RESIZER, refine_lora=None, draft_only=False, draft_steps=None,
|
|
|
|
| 1026 |
):
|
| 1027 |
"""Conditioner -> denoise -> mux. Returns `(video_path, report, facts)`."""
|
| 1028 |
if LOAD_ERROR:
|
|
@@ -1040,6 +1058,7 @@ def generate(
|
|
| 1040 |
num_frames = snap_frames(duration)
|
| 1041 |
|
| 1042 |
upscale = float(upscale)
|
|
|
|
| 1043 |
refine_lora = REFINE_LORA_SCALE if refine_lora is None else float(refine_lora)
|
| 1044 |
|
| 1045 |
if DEV_MODE:
|
|
@@ -1119,7 +1138,8 @@ def generate(
|
|
| 1119 |
refine_rows = packed_rows(out_height, out_width, num_frames, first_image, last_image)
|
| 1120 |
booked_at = estimate_duration(
|
| 1121 |
None, None, first_path, last_path, height, width, num_frames, steps, seed, resolved, upscale,
|
| 1122 |
-
None, refine_ladder, resizer,
|
|
|
|
| 1123 |
)
|
| 1124 |
if peak <= DECODE_VRAM_BUDGET and booked_at <= MAX_BOOKING and refine_rows <= MAX_DENOISE_ROWS:
|
| 1125 |
break
|
|
@@ -1146,7 +1166,7 @@ def generate(
|
|
| 1146 |
else f"{upscale:g}x {MID_DOT} {width}x{height} draft in "
|
| 1147 |
f"{DRAFT_STEPS if draft_steps is None else int(draft_steps)} steps, {resizer} resize, "
|
| 1148 |
f"{len(refine_schedule(refine_ladder)) - 1}-step refine at {out_width}x{out_height}"
|
| 1149 |
-
f"{f', turbo
|
| 1150 |
if upscale > 1
|
| 1151 |
else "single pass"
|
| 1152 |
)
|
|
@@ -1157,7 +1177,8 @@ def generate(
|
|
| 1157 |
# only when it runs into the ceiling: `xlarge` is charged at twice the seconds it books.
|
| 1158 |
booked = estimate_duration(
|
| 1159 |
prompt_embeds, text_token_tags, first_image, last_image, height, width, num_frames, steps, seed, resolved,
|
| 1160 |
-
upscale, upscaler_path, refine_ladder, resizer, refine_lora, draft_only,
|
|
|
|
| 1161 |
)
|
| 1162 |
multiplier = quota_multiplier()
|
| 1163 |
print(
|
|
@@ -1188,8 +1209,10 @@ def generate(
|
|
| 1188 |
upscaler_path,
|
| 1189 |
refine_ladder,
|
| 1190 |
resizer,
|
|
|
|
| 1191 |
refine_lora,
|
| 1192 |
draft_only,
|
|
|
|
| 1193 |
)
|
| 1194 |
except Exception as error:
|
| 1195 |
# Deliberately not called "not granted": whether the slot was ever held is what the `[gpu] granted` line
|
|
|
|
| 176 |
# missing - a full eight-step refine to resolve its output - came back worse than anything else tried. Reachable
|
| 177 |
# by `H3_RESIZER=learned` for whoever wants to re-open it; not offered in the UI.
|
| 178 |
DEFAULT_RESIZER = os.getenv("H3_RESIZER", "trilinear")
|
| 179 |
+
# What a *distilled* adapter is worth in each pass. Style adapters are never touched in either: the trajectory is
|
| 180 |
+
# not what they are about.
|
| 181 |
+
#
|
| 182 |
+
# The reference workflow puts the turbo LoRA in the second pass only - its `LoraLoaderModelOnly` sits bypassed in
|
| 183 |
+
# the first - and the arrangement is the whole point rather than an accident. Motion is decided high on the
|
| 184 |
+
# schedule, in the pass that starts from noise; a distilled adapter is trained to cross that stretch in one jump
|
| 185 |
+
# and lands in the averaged, low-motion attractor its distillation settled on. So the draft runs unaccelerated,
|
| 186 |
+
# which it can afford at a quarter of the target's area, and the turbo is spent on the refine, where composition
|
| 187 |
+
# is already fixed and only detail is left to resolve.
|
| 188 |
+
#
|
| 189 |
+
# That is also what makes the second pass worth booking at all. Priced on this Space's own calibration at 1344x768
|
| 190 |
+
# and 125 frames: an unaccelerated single pass is 28 steps and about 480s of quota, while an unaccelerated 672x384
|
| 191 |
+
# draft of 15 steps followed by an 8-step turbo refine at the same target is about 224s. Less than half, for the
|
| 192 |
+
# same resolution and a first pass that was never rushed.
|
| 193 |
+
DRAFT_LORA_SCALE = float(os.getenv("H3_DRAFT_LORA_SCALE", "0"))
|
| 194 |
REFINE_LORA_SCALE = float(os.getenv("H3_REFINE_LORA_SCALE", "1"))
|
| 195 |
|
| 196 |
|
|
|
|
| 806 |
upscaler_path=None,
|
| 807 |
refine_ladder=None,
|
| 808 |
resizer=DEFAULT_RESIZER,
|
| 809 |
+
draft_lora=None,
|
| 810 |
refine_lora=None,
|
| 811 |
draft_only=False,
|
| 812 |
draft_steps=None,
|
|
|
|
| 884 |
upscaler_path=None,
|
| 885 |
refine_ladder=None,
|
| 886 |
resizer=DEFAULT_RESIZER,
|
| 887 |
+
draft_lora=None,
|
| 888 |
refine_lora=None,
|
| 889 |
draft_only=False,
|
| 890 |
draft_steps=None,
|
|
|
|
| 916 |
|
| 917 |
# A rack that has to change weight between the two passes must stay out of the checkpoint, since a folded one
|
| 918 |
# can only be re-weighted by unfusing it first.
|
| 919 |
+
draft_lora = DRAFT_LORA_SCALE if draft_lora is None else float(draft_lora)
|
| 920 |
refine_lora = REFINE_LORA_SCALE if refine_lora is None else float(refine_lora)
|
| 921 |
+
distilled = [spec.adapter for spec in loras if getattr(spec, "distilled", False)]
|
| 922 |
+
rescaled = upscale > 1 and bool(distilled) and (draft_lora != 1 or refine_lora != 1)
|
| 923 |
applied = lora_stack.apply(PIPE, loras, allow_fold=not rescaled)
|
| 924 |
|
| 925 |
# Timed separately from the rack work above, which is a one-off: this is the number the booking model is
|
|
|
|
| 931 |
# area or less, and a step's cost falls faster than the area - and what it hands over is the composition
|
| 932 |
# the refine then works from.
|
| 933 |
steps = DRAFT_STEPS if draft_steps is None else int(draft_steps)
|
| 934 |
+
if distilled:
|
| 935 |
+
# The pass that starts from noise is the one that decides what moves, and a distilled adapter crosses
|
| 936 |
+
# that stretch of the schedule in a single learned jump into a low-motion average. Off here by
|
| 937 |
+
# default, which is where the reference workflow leaves it, and paid for by the extra draft steps -
|
| 938 |
+
# cheap at a quarter of the target's area.
|
| 939 |
+
print(f"[lora] draft pass: {lora_stack.set_scale(PIPE, draft_lora, distilled)}", flush=True)
|
| 940 |
state = PIPE(
|
| 941 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 942 |
text_token_tags=text_token_tags,
|
|
|
|
| 989 |
# is about a tenth of what the transformer reads - enough to carry the composition the coarse pass found,
|
| 990 |
# not enough to carry its blur. A separate generator, so the refine noise does not shift the draw order
|
| 991 |
# the draft pass already consumed from the request's own.
|
|
|
|
| 992 |
if distilled:
|
| 993 |
print(
|
| 994 |
f"[lora] refine pass: {lora_stack.set_scale(PIPE, refine_lora, distilled)}",
|
|
|
|
| 1039 |
# ---------------------------------------------------------------------------
|
| 1040 |
def generate(
|
| 1041 |
prompt, first_path, last_path, canvas, duration, steps, seed, loras=(), upscale=1.0, refine_ladder=None,
|
| 1042 |
+
resizer=DEFAULT_RESIZER, draft_lora=None, refine_lora=None, draft_only=False, draft_steps=None,
|
| 1043 |
+
ip_token=None,
|
| 1044 |
):
|
| 1045 |
"""Conditioner -> denoise -> mux. Returns `(video_path, report, facts)`."""
|
| 1046 |
if LOAD_ERROR:
|
|
|
|
| 1058 |
num_frames = snap_frames(duration)
|
| 1059 |
|
| 1060 |
upscale = float(upscale)
|
| 1061 |
+
draft_lora = DRAFT_LORA_SCALE if draft_lora is None else float(draft_lora)
|
| 1062 |
refine_lora = REFINE_LORA_SCALE if refine_lora is None else float(refine_lora)
|
| 1063 |
|
| 1064 |
if DEV_MODE:
|
|
|
|
| 1138 |
refine_rows = packed_rows(out_height, out_width, num_frames, first_image, last_image)
|
| 1139 |
booked_at = estimate_duration(
|
| 1140 |
None, None, first_path, last_path, height, width, num_frames, steps, seed, resolved, upscale,
|
| 1141 |
+
upscaler_path=None, refine_ladder=refine_ladder, resizer=resizer, draft_lora=draft_lora,
|
| 1142 |
+
refine_lora=refine_lora, draft_only=draft_only, draft_steps=draft_steps, _quiet=True,
|
| 1143 |
)
|
| 1144 |
if peak <= DECODE_VRAM_BUDGET and booked_at <= MAX_BOOKING and refine_rows <= MAX_DENOISE_ROWS:
|
| 1145 |
break
|
|
|
|
| 1166 |
else f"{upscale:g}x {MID_DOT} {width}x{height} draft in "
|
| 1167 |
f"{DRAFT_STEPS if draft_steps is None else int(draft_steps)} steps, {resizer} resize, "
|
| 1168 |
f"{len(refine_schedule(refine_ladder)) - 1}-step refine at {out_width}x{out_height}"
|
| 1169 |
+
f"{f', turbo {draft_lora:g}x then {refine_lora:g}x' if any(getattr(s, 'distilled', False) for s in resolved) else ''}"
|
| 1170 |
if upscale > 1
|
| 1171 |
else "single pass"
|
| 1172 |
)
|
|
|
|
| 1177 |
# only when it runs into the ceiling: `xlarge` is charged at twice the seconds it books.
|
| 1178 |
booked = estimate_duration(
|
| 1179 |
prompt_embeds, text_token_tags, first_image, last_image, height, width, num_frames, steps, seed, resolved,
|
| 1180 |
+
upscale, upscaler_path, refine_ladder, resizer, draft_lora, refine_lora, draft_only, draft_steps,
|
| 1181 |
+
_quiet=True,
|
| 1182 |
)
|
| 1183 |
multiplier = quota_multiplier()
|
| 1184 |
print(
|
|
|
|
| 1209 |
upscaler_path,
|
| 1210 |
refine_ladder,
|
| 1211 |
resizer,
|
| 1212 |
+
draft_lora,
|
| 1213 |
refine_lora,
|
| 1214 |
draft_only,
|
| 1215 |
+
draft_steps,
|
| 1216 |
)
|
| 1217 |
except Exception as error:
|
| 1218 |
# Deliberately not called "not granted": whether the slot was ever held is what the `[gpu] granted` line
|
|
@@ -356,6 +356,16 @@ def apply(pipe, specs, allow_fold: bool = True) -> str:
|
|
| 356 |
pipe.disable_lora()
|
| 357 |
return "; ".join(["none", *notes]) if notes else "none"
|
| 358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
if state["fused"] == key:
|
| 360 |
# The weights already carry this rack. Nothing to activate, nothing to pay.
|
| 361 |
applied = ", ".join(f"{spec.label} @ {spec.weight:g}" for spec in specs if spec.adapter in active)
|
|
|
|
| 356 |
pipe.disable_lora()
|
| 357 |
return "; ".join(["none", *notes]) if notes else "none"
|
| 358 |
|
| 359 |
+
if state["fused"] == key and not allow_fold:
|
| 360 |
+
# The right rack, in the wrong form. A caller that passes `allow_fold=False` is going to re-weight part
|
| 361 |
+
# of it partway through the request, and a folded adapter carries its weight in the checkpoint where
|
| 362 |
+
# `set_adapters` cannot reach it - so the fold comes out rather than the re-weighting silently doing
|
| 363 |
+
# nothing. Only a request that changes weights mid-flight pays this, and only when the previous one
|
| 364 |
+
# happened to leave the same rack folded.
|
| 365 |
+
print("[lora] unfolding: this request re-weights the rack between passes", flush=True)
|
| 366 |
+
pipe.unfuse_lora()
|
| 367 |
+
state["fused"] = None
|
| 368 |
+
|
| 369 |
if state["fused"] == key:
|
| 370 |
# The weights already carry this rack. Nothing to activate, nothing to pay.
|
| 371 |
applied = ", ".join(f"{spec.label} @ {spec.weight:g}" for spec in specs if spec.adapter in active)
|