Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Two-pass generation runs only with 8 first-pass steps

Bowen Xuee8f6afec46eb
diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.py
index 5c6d0a1..2cf848f 100644
--- a/freevideo_engine/agent/guide.py
+++ b/freevideo_engine/agent/guide.py
@@ -70,6 +70,13 @@ GUIDE = {
'lighting and surroundings as described above; do not copy its simplified, flat look." The result follows '
'the draft and looks plainer than a direct generation, so keep the direct one when the user prefers its look.',
],
+ 'quality': [
+ 'Steps per quality: "light" = 8 first-pass steps + 3 refine steps, two-pass (default); "medium" = 12 steps, '
+ '"high" = 16 steps, "max" = 20 steps, each in one pass.',
+ 'Two-pass generation runs only with 8 first-pass steps. Any other base_steps (for example 20 with '
+ 'two_pass=true) runs in one pass of that many steps; the job notice says so. A preview is always two-pass '
+ 'with 8 steps.',
+ ],
'timing': [
'Single-block frames are 24 fps on a 17n+5 grid (6 s -> 6.583 s, 10 s -> 10.125 s). '
'Under 30 s defaults to one generation when the device supports this size and quality; unknown limits use 15 s. '
diff --git a/freevideo_engine/agent/jobs.py b/freevideo_engine/agent/jobs.py
index 1545127..b56e89b 100644
--- a/freevideo_engine/agent/jobs.py
+++ b/freevideo_engine/agent/jobs.py
@@ -131,8 +131,14 @@ def continuation_problems(spec, prefix='', *, editor=None):
problems = []
if not spec['two_pass']:
# The quality name is a contract enum, never caller text.
- problem = schema.diagnostic(prefix + '/quality', '"light" (two-pass), or sampling.two_pass=true,' + why, None)
- got = '"%s" (one pass)' % spec['quality']
+ if spec.get('sampling_note'):
+ # Two-pass was asked for with a first-pass count other than 8: it runs one pass.
+ problem = schema.diagnostic(prefix + '/quality',
+ '"light" (two-pass), or sampling.two_pass=true with base_steps=8,' + why, None)
+ got = '%d first-pass steps (one pass)' % spec['base_steps']
+ else:
+ problem = schema.diagnostic(prefix + '/quality', '"light" (two-pass), or sampling.two_pass=true,' + why, None)
+ got = '"%s" (one pass)' % spec['quality']
problems.append(dict(problem, got=got, message=problem['message'].replace('received None', 'received ' + got)))
if spec['preview']:
problems.append(schema.diagnostic(prefix + '/preview', 'false' + why, True))
@@ -546,6 +552,12 @@ class Jobs:
self.finish(row, 'failed', error=dict(code='interrupted',
message='ComfyUI restarted while this job ran; submit it again'), save=False)
row['_restored'] = True
+ if row['kind'] == 'generate' and row['status'] in ACTIVE:
+ # Waiting, queued or running when the process restarted: this process runs it
+ # under the one-pass rule, however it is started again. A finished job is left.
+ note = self.legacy_one_pass_note(row['spec'])
+ if note:
+ row['spec']['sampling_note'] = note
if row['kind'] == 'generate' and not row['spec'].get('refine_from'):
# Before device-aware Agent planning, every accepted job used the unknown limit.
row['spec'].setdefault('single_max_frames', None)
@@ -1079,6 +1091,15 @@ class Jobs:
result['chain_id'] = row['chain_id']
if row['kind'] == 'generate':
result.update(cancel_requested=row.get('cancel_requested', False), attempt=row.get('attempt', 1))
+ note = spec.get('sampling_note')
+ if (note is None and row['status'] not in DONE and spec.get('two_pass') and not spec.get('preview')
+ and not spec.get('refine_from')):
+ # A job stored before the one-pass rule and not yet run: the engine applies it when it runs.
+ # A finished one keeps what it did, which a stored request cannot tell.
+ from ..two_pass import one_pass_note
+ note = one_pass_note(spec.get('base_steps', 8))
+ if note:
+ result['notice'] = note
if row['status'] == 'waiting':
pending = [d for d in row.get('depends_on', ()) if self.jobs.get(d, {}).get('status') not in DONE]
result['waiting_for'] = pending or row.get('waiting_for') or (['gpu'] if row['kind'] in GPU_KINDS + ('generate',) else [])
@@ -1449,9 +1470,28 @@ class Jobs:
relative = edited
return relative
+ @staticmethod
+ def legacy_one_pass_note(spec):
+ """The note for an unfinished two-pass job stored before the one-pass rule, else None."""
+ base = spec.get('base_steps', 8)
+ if (spec.get('sampling_note') is None and spec.get('two_pass') is True and not spec.get('preview')
+ and not spec.get('refine_from') and type(base) is int and 1 <= base <= 32 and base != 8):
+ from ..two_pass import one_pass_note
+ return one_pass_note(base)
+ return None # a damaged stored value gets no note; the row is judged where it is used
+
async def start_generation(self, row):
def prepare():
spec = row['spec']
+ note = self.legacy_one_pass_note(spec)
+ if note:
+ # A job stored before the one-pass rule starts under it now, on a first start
+ # and on a resume alike: keep what it runs as, so the note outlasts the run and
+ # a reload (a stored request alone cannot tell, and a finished old job must
+ # not gain a note).
+ with self.lock:
+ spec['sampling_note'] = note
+ self.touch(row)
if row.get('resume_pending'):
self.start_chain(row, resume=True)
return
diff --git a/freevideo_engine/agent/routes.py b/freevideo_engine/agent/routes.py
index 0dfc247..040c525 100644
--- a/freevideo_engine/agent/routes.py
+++ b/freevideo_engine/agent/routes.py
@@ -251,6 +251,8 @@ def plan(port, value, jobs=None):
result['geometry'] = {k: canvas[k] for k in ('width', 'height', 'frames', 'seconds', 'fps', 'latent_frames')}
result['sampling'] = dict(two_pass=passes['enabled'], total_steps=passes['total_steps'],
first_pass=passes.get('first'), second_pass=passes.get('second') if passes['enabled'] else None)
+ if spec.get('sampling_note'):
+ result['warnings'].append(spec['sampling_note'])
if spec['seconds'] > 15:
result['warnings'].append('Longer than 15 s is experimental')
if spec['task'] == 'ref2va':
diff --git a/freevideo_engine/agent/schema.py b/freevideo_engine/agent/schema.py
index 303b8ee..df65bb3 100644
--- a/freevideo_engine/agent/schema.py
+++ b/freevideo_engine/agent/schema.py
@@ -176,7 +176,22 @@ def generate(*, local=False):
{'if': {'if': {'required': ['sampling'], 'properties': {'sampling': {'required': ['two_pass']}}},
'then': {'properties': {'sampling': {'properties': {'two_pass': {'const': False}}}}},
'else': {'required': ['quality'], 'properties': {'quality': {'not': {'const': 'light'}}}}},
- 'then': {'properties': {'preview': {'const': False}}}}],
+ 'then': {'properties': {'preview': {'const': False}}}},
+ # A preview is two-pass, which runs only with 8 first-pass steps: refused when the effective
+ # first-pass count is another number, given in sampling or inherited from the quality.
+ {'if': {'properties': {'preview': {'const': True}}, 'required': ['preview']},
+ # x-derived: issues() names this case at /sampling with the derived sampling checks.
+ 'then': {'x-derived': True, 'not': {'anyOf': [
+ {'required': ['sampling'], 'properties': {'sampling': {'required': ['two_pass', 'base_steps'],
+ 'properties': {'two_pass': {'const': True}, 'base_steps': {'not': {'const': 8}}}}}},
+ {'required': ['sampling'], 'properties': {
+ 'sampling': {'required': ['base_steps'], 'not': {'required': ['two_pass']},
+ 'properties': {'base_steps': {'not': {'const': 8}}}},
+ 'quality': {'const': 'light'}}},
+ {'required': ['sampling', 'quality'], 'properties': {
+ 'sampling': {'required': ['two_pass'], 'not': {'required': ['base_steps']},
+ 'properties': {'two_pass': {'const': True}}},
+ 'quality': {'enum': ['medium', 'high', 'max']}}}]}}}],
description='x-job-kind selects normalization and checks derived geometry and sampling step comparisons; these calculations are not JSON Schema constraints.',
**{'x-job-kind': 'generate'})
@@ -976,7 +991,7 @@ def issues(schema, value, path='', *, refs=False):
if 'if' in schema:
rule = schema.get('then', True) if not issues(schema['if'], value) else schema.get('else', True)
errors += issues(rule, value, path)
- if 'not' in schema and not issues(schema['not'], value):
+ if 'not' in schema and not schema.get('x-derived') and not issues(schema['not'], value):
errors.append(diagnostic(path, 'a permitted field combination', value))
if 'oneOf' in schema or 'anyOf' in schema:
# Structural unions choose the most specific applicable branch, then
@@ -1101,6 +1116,8 @@ def cross_issues(schema, value, path):
validate_steps(base, refine, two)
except ValueError:
bad('sampling', 'two-pass refine_steps=3 or refine_steps below base_steps', custom)
+ if value.get('preview') and two and base != 8:
+ bad('sampling', 'base_steps=8 for a preview, the only first-pass count that runs two-pass', custom)
if kind == 'vlm':
rows = value['questions'] if isinstance(value['questions'], list) else [value['questions']]
count = sum(len(r.get('images', [])) + (r.get('video', {}).get('frames', 6) if isinstance(r.get('video'), dict)
diff --git a/freevideo_engine/agent/spec.py b/freevideo_engine/agent/spec.py
index 3997350..1a932ae 100644
--- a/freevideo_engine/agent/spec.py
+++ b/freevideo_engine/agent/spec.py
@@ -130,9 +130,16 @@ def sampling(value):
two, base, refine = QUALITY[quality]
custom = value.get('sampling', {})
two, base, refine = custom.get('two_pass', two), custom.get('base_steps', base), custom.get('refine_steps', refine)
+ note = None
+ if two:
+ from ..two_pass import one_pass_note
+ # Only the 8-step first pass goes two-pass; any other count is one pass, said once in the answer.
+ note = one_pass_note(base)
+ two = two and note is None
if custom:
quality = next((k for k, v in QUALITY.items() if v == (two, base, refine)), 'custom')
- return dict(quality=quality, two_pass=two, base_steps=base, refine_steps=refine)
+ return dict(quality=quality, two_pass=two, base_steps=base, refine_steps=refine,
+ **({'sampling_note': note} if note else {}))
def generation_media(value):
diff --git a/freevideo_engine/comfy_bridge.py b/freevideo_engine/comfy_bridge.py
index e820671..6b5b750 100644
--- a/freevideo_engine/comfy_bridge.py
+++ b/freevideo_engine/comfy_bridge.py
@@ -969,7 +969,7 @@ def progress_message(event):
(first['width'], first['height'], second['width'], second['height'],
event.get('base_steps', 8), event.get('refine_steps', 3)),
detail='Audio is preserved from the first pass', sampling_plan=event)
- return dict(label='Single-pass · %d steps' % event.get('base_steps', 8), detail=event.get('reason'), sampling_plan=event)
+ return dict(label='Single-pass · %d step%s' % (event.get('base_steps', 8), '' if event.get('base_steps', 8) == 1 else 's'), detail=event.get('reason'), sampling_plan=event)
if name == 'latent_upscaler_prepare':
return dict(label='Preparing two-pass upscaler', timing_phase='load')
if name == 'first_pass_reused':
@@ -1203,7 +1203,7 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,
base_steps = int(argument(arguments, '--base-steps', 8))
refine_steps = int(argument(arguments, '--refine-steps', 3))
from .preview import validate_flags
- validate_flags(preview, upscale, two_pass)
+ validate_flags(preview, upscale, two_pass, base_steps)
from .two_pass import validate_steps
validate_steps(base_steps, refine_steps, two_pass)
canvas = validate_request(prompt, width, height, seconds, seed, continue_from=continue_from, frames=frames)
diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.py
index 92fe888..cf1aa7f 100644
--- a/freevideo_engine/comfy_nodes.py
+++ b/freevideo_engine/comfy_nodes.py
@@ -45,7 +45,8 @@ class FreeVideoGenerate(io.ComfyNode):
io.Boolean.Input('two_pass', display_name='Two-step generation', default=True, optional=True,
tooltip='Usually faster: generate at a lower resolution, then upscale and finish sampling at the target size.'),
io.Int.Input('base_steps', display_name='First-pass steps', default=8, min=1, max=32, optional=True,
- tooltip='Default: 8. Changing sampling steps may reduce generation quality.'),
+ tooltip='Default: 8. Two-pass acceleration runs only with 8 first-pass steps; any other count '
+ 'generates in one pass of that many steps. Changing sampling steps may reduce generation quality.'),
io.Int.Input('refine_steps', display_name='Second-pass steps', default=3, min=1, max=31, optional=True,
tooltip='Default: 3. Three steps use the independent refinement schedule. Changing sampling steps may reduce generation quality.'),
io.Boolean.Input('force_regenerate', display_name='Force regeneration', default=False, optional=True,
@@ -173,6 +174,12 @@ class FreeVideoGenerate(io.ComfyNode):
if notice:
logging.warning('[FreeVideo] %s', notice)
PromptServer.instance.send_progress_text(notice, node_id)
+ if two_pass and not refine_from and not preview:
+ from .two_pass import one_pass_note
+ step_note = one_pass_note(base_steps)
+ if step_note:
+ logging.warning('[FreeVideo] %s', step_note)
+ notice = notice + '\n' + step_note if notice else step_note
notice = notice + '\n' if notice else ''
def said():
return notice + ''.join(line + '\n' for line in notes)
diff --git a/freevideo_engine/comfy_progress.py b/freevideo_engine/comfy_progress.py
index 8b22e38..51da6f5 100644
--- a/freevideo_engine/comfy_progress.py
+++ b/freevideo_engine/comfy_progress.py
@@ -124,7 +124,7 @@ class ProgressState:
# pass from a first pass, without repeating the whole plan.
plan = message.get('sampling_plan')
if isinstance(plan, dict):
- value['plan_context'] = {key: deepcopy(plan[key]) for key in ('enabled', 'preview', 'base_steps', 'refine_steps', 'second')
+ value['plan_context'] = {key: deepcopy(plan[key]) for key in ('enabled', 'requested', 'preview', 'base_steps', 'refine_steps', 'second')
if key in plan}
elif old and not fresh and old['message'].get('plan_context'):
value.setdefault('plan_context', deepcopy(old['message']['plan_context']))
diff --git a/freevideo_engine/decode_resume.py b/freevideo_engine/decode_resume.py
index 58fc241..c02a964 100644
--- a/freevideo_engine/decode_resume.py
+++ b/freevideo_engine/decode_resume.py
@@ -71,6 +71,48 @@ def _digest(path):
return digest.hexdigest()
+def _plan_without_staged(plan):
+ return {k: v for k, v in plan.items() if k != 'staged'} if isinstance(plan, dict) else plan
+
+
+def _canvas_without_staged(canvas):
+ if isinstance(canvas, dict) and isinstance(canvas.get('sampling_plan'), dict):
+ return dict(canvas, sampling_plan=_plan_without_staged(canvas['sampling_plan']))
+ return canvas
+
+
+def _without_staged(value):
+ """A copy of `value` whose sampling plan lacks `staged` in its two stored places.
+
+ The controller keeps the plan twice: as `sampling_plan` and inside the
+ canvas (`geometry`), and the canvas is also part of the saved identity.
+ Nothing else is normalised.
+ """
+ if not isinstance(value, dict):
+ return value
+ result = dict(value)
+ if 'sampling_plan' in result:
+ result['sampling_plan'] = _plan_without_staged(result['sampling_plan'])
+ if 'geometry' in result:
+ result['geometry'] = _canvas_without_staged(result['geometry'])
+ return result
+
+
+def same_identity(left, right):
+ """Equal sampling identities, ignoring the plan's `staged` marker.
+
+ A plan made before the marker existed (a 20-step preview of a large canvas
+ kept in the previous version) differs from today's plan of the same request
+ only by that key; every field that decides the math is still compared.
+ """
+ return _without_staged(left) == _without_staged(right)
+
+
+def same_canvas(saved, canvas):
+ """The saved canvas equals the request's, ignoring the plan's `staged` marker."""
+ return _canvas_without_staged(saved) == _canvas_without_staged(canvas)
+
+
def sampling_provenance(request):
"""Bind the result to the exact conditioning, model manifest and math."""
from .paths import base_path
@@ -127,14 +169,15 @@ def load_saved_sampling(request, torch, *, continuation_tail_callback=None):
if not completed_sampling(previous):
raise ValueError('Decoder retry requires all planned finite sampling steps')
provenance = sampling_provenance(request)
- if provenance != sampling_provenance(prior) or provenance != previous.get('sampling_provenance'):
+ if (not same_identity(provenance, sampling_provenance(prior))
+ or not same_identity(provenance, previous.get('sampling_provenance'))):
raise ValueError('Retained sampling does not match this request and its current inputs')
canvas = request['geometry']
if any(previous.get('geometry', {}).get(key) != canvas[key] for key in ('width', 'height', 'frames', 'fps')):
raise ValueError('Retained sampling geometry differs from the request')
value = torch.load(str(paths['latents']), map_location='cpu', weights_only=True)
if (not isinstance(value, dict) or type(value.get('seed')) is not int or value['seed'] != request['seed']
- or value.get('geometry') != canvas or value.get('sampling_provenance') != provenance):
+ or not same_canvas(value.get('geometry'), canvas) or not same_identity(value.get('sampling_provenance'), provenance)):
raise ValueError('Retained latent provenance differs from the sampling receipt')
width, height, frames, fps = (canvas[key] for key in ('width', 'height', 'frames', 'fps'))
if (any(type(n) is not int or n <= 0 for n in (width, height, frames, fps))
@@ -248,12 +291,13 @@ def load_first_pass(request, torch):
if not isinstance(prior, dict) or not first_pass_complete(previous):
raise ValueError('Upscaling requires a finished preview')
provenance = refine_provenance(request)
- if provenance != refine_provenance(prior) or provenance != previous['refine_provenance']:
+ if (not same_identity(provenance, refine_provenance(prior))
+ or not same_identity(provenance, previous['refine_provenance'])):
raise ValueError('The preview does not match this request and its current inputs')
canvas, first = request['geometry'], request['sampling_plan']['first']
value = torch.load(str(paths['input']), map_location='cpu', weights_only=True)
if (not isinstance(value, dict) or type(value.get('seed')) is not int or value['seed'] != request['seed']
- or value.get('geometry') != canvas or value.get('refine_provenance') != provenance):
+ or not same_canvas(value.get('geometry'), canvas) or not same_identity(value.get('refine_provenance'), provenance)):
raise ValueError('Preview first-pass provenance differs from its receipt')
width, height, frames, fps = first['width'], first['height'], first['frames'], canvas['fps']
if (any(type(n) is not int or n <= 0 for n in (width, height, frames, fps))
@@ -309,12 +353,13 @@ def load_refine_input(request, torch, *, continuation_tail_callback=None):
if not isinstance(prior, dict) or not refine_checkpoint_complete(previous):
raise ValueError('First-pass retry requires a complete retained first pass')
provenance = refine_provenance(request)
- if provenance != refine_provenance(prior) or provenance != previous['refine_provenance']:
+ if (not same_identity(provenance, refine_provenance(prior))
+ or not same_identity(provenance, previous['refine_provenance'])):
raise ValueError('Retained first pass does not match this request and its current inputs')
canvas = request['geometry']
value = torch.load(str(paths['input']), map_location='cpu', weights_only=True)
if (not isinstance(value, dict) or type(value.get('seed')) is not int or value['seed'] != request['seed']
- or value.get('geometry') != canvas or value.get('refine_provenance') != provenance):
+ or not same_canvas(value.get('geometry'), canvas) or not same_identity(value.get('refine_provenance'), provenance)):
raise ValueError('Retained first-pass provenance differs from its receipt')
width, height, frames, fps = (canvas[key] for key in ('width', 'height', 'frames', 'fps'))
if (any(type(n) is not int or n <= 0 for n in (width, height, frames, fps))
diff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.py
index 6585e63..3d03c7d 100644
--- a/freevideo_engine/generate.py
+++ b/freevideo_engine/generate.py
@@ -425,7 +425,7 @@ def _run(args):
two_pass = getattr(args, 'two_pass', True)
preview = getattr(args, 'preview', False) is True
from .preview import validate_flags, source as preview_source
- validate_flags(preview, getattr(args, 'refine_from', None), two_pass)
+ validate_flags(preview, getattr(args, 'refine_from', None), two_pass, requested_steps)
refine_source = preview_source(args.refine_from) if getattr(args, 'refine_from', None) else None
if requested_steps is not None:
validate_steps(requested_steps, refine_steps, two_pass)
@@ -567,6 +567,8 @@ def _run(args):
from .two_pass import plan as continuation_plan
validate_route(task=profile['engine'].get('task', 't2va'), anchor=anchored)
planned = continuation_plan(canvas, two_pass, base_steps=base_steps, refine_steps=refine_steps)
+ if two_pass and not planned['enabled'] and base_steps != 8:
+ raise ValueError(planned['reason'] + ' A continuation needs two-pass generation.')
continuation_first = planned['first']
continuation = usable_continuation(continuation, canvas, None if active_loras else manifest, planned)
if manifest.get('precision') not in ('fp8', 'int8', 'bf16'): # BF16: the unquantized reference
@@ -1007,9 +1009,9 @@ def _run(args):
request.pop('resume_refine', None)
request.pop('resume_first_pass', None)
if resume_decode is None and resume_refine is None and preview_pass is not None:
- from .decode_resume import refine_provenance
+ from .decode_resume import refine_provenance, same_identity
receipt = json.loads(Path(preview_pass['metrics']).read_text(encoding='utf-8'))
- if refine_provenance(request) == receipt.get('refine_provenance'):
+ if same_identity(refine_provenance(request), receipt.get('refine_provenance')):
request['resume_first_pass'] = dict(preview_pass)
report['upscaled_preview']['first_pass_reused'] = True
else:
diff --git a/freevideo_engine/macos_generate.py b/freevideo_engine/macos_generate.py
index f5e6a7d..38e47e3 100644
--- a/freevideo_engine/macos_generate.py
+++ b/freevideo_engine/macos_generate.py
@@ -127,7 +127,7 @@ def run(args):
require_native()
from .preview import validate_flags, source as preview_source
preview = getattr(args, 'preview', False) is True
- validate_flags(preview, getattr(args, 'refine_from', None), args.two_pass)
+ validate_flags(preview, getattr(args, 'refine_from', None), args.two_pass, getattr(args, 'base_steps', None))
refine_source = preview_source(args.refine_from, native=True) if getattr(args, 'refine_from', None) else None
output = Path(args.out).expanduser().resolve()
artifacts = output.with_suffix('.artifacts')
diff --git a/freevideo_engine/preview.py b/freevideo_engine/preview.py
index c1908a2..028405c 100644
--- a/freevideo_engine/preview.py
+++ b/freevideo_engine/preview.py
@@ -14,11 +14,14 @@ CUDA_FILES = ('first-pass.pt', 'first-pass.engine.json', 'video.json', 'conditio
MAC_FILES = ('first-pass.pt', 'first-pass.json', 'engine-request.json', 'conditioning.pt')
-def validate_flags(preview, refine_from, two_pass):
+def validate_flags(preview, refine_from, two_pass, base_steps=None):
if preview and refine_from:
raise ValueError('Choose either a preview or an upscale of one, not both')
if (preview or refine_from) and not two_pass:
raise ValueError('Previews and their upscale use two-pass generation')
+ if preview and base_steps not in (None, 8):
+ # Two-pass runs only with 8 first-pass steps (two_pass.TWO_PASS_BASE_STEPS).
+ raise ValueError('A preview uses two-pass generation, which runs only with 8 first-pass steps')
def source(output, native=False):
diff --git a/freevideo_engine/two_pass.py b/freevideo_engine/two_pass.py
index e69ceba..d32bb40 100644
--- a/freevideo_engine/two_pass.py
+++ b/freevideo_engine/two_pass.py
@@ -22,6 +22,19 @@ def validate_steps(base_steps=8, refine_steps=3, enabled=True):
raise ValueError('Second-pass steps must be fewer than first-pass steps')
+# The learned latent lift and the three refinement steps were built and checked
+# for the 8-step first pass only. Any other first-pass count runs in one pass.
+TWO_PASS_BASE_STEPS = 8
+
+
+def one_pass_note(base_steps):
+ """The sentence a request gets when its step count rules out two-pass, else None."""
+ if base_steps == TWO_PASS_BASE_STEPS:
+ return None
+ return ('Two-pass generation runs only with %d first-pass steps; this request runs in one pass of %d step%s.'
+ % (TWO_PASS_BASE_STEPS, base_steps, '' if base_steps == 1 else 's'))
+
+
# A first pass below this many pixels is too small for the learned lift: about
# a third of the clips at 768x512 and every clip at 512x512 had coloured
# bursts, and none did from 480x288 (960x544) upward. Those sizes run in one pass.
@@ -107,6 +120,13 @@ def plan(canvas, enabled=True, task='t2va', *, base_steps=8, refine_steps=3, sta
if not enabled:
result['reason'] = 'Two-pass generation is disabled.'
return result
+ if base_steps != TWO_PASS_BASE_STEPS:
+ if not staged:
+ single = plan(canvas, False, task, base_steps=base_steps)
+ return dict(single, requested=True, reason=one_pass_note(base_steps))
+ # A preview and its upscale keep the first pass they were made with; the
+ # receipt says so, because a replay without the flag would take the one-pass rule.
+ result['staged'] = True
if min(target['width'], target['height']) >= 512:
first = dict(width=((target['width'] + 63) // 64) * 32,
height=((target['height'] + 63) // 64) * 32, frames=target['frames'])
diff --git a/scripts/test_freevideo_entry.mjs b/scripts/test_freevideo_entry.mjs
index 331585b..a84f6b9 100644
--- a/scripts/test_freevideo_entry.mjs
+++ b/scripts/test_freevideo_entry.mjs
@@ -141,8 +141,8 @@ test('main browser entry registers both views and preserves node hooks', async t
computeSize() { return [this.size[0], this.dom.reduce((height, row) => height + (row.options?.getMinHeight?.() || 0), 0)]; }
}
for (const [language, tooltip] of [
- ['en', 'Changing steps may lower quality. Default: 8 first-pass and 3 refine steps. Refine steps must be fewer than first-pass steps unless set to 3.'],
- ['zh', '修改步数可能降低质量。默认首轮 8 步、细化 3 步;细化步数不是 3 时,需少于首轮。'],
+ ['en', 'Changing steps may lower quality. Default: 8 first-pass and 3 refine steps. Two-step generation runs only with 8 first-pass steps. Other step counts use a single pass. Refine steps must be fewer than first-pass steps unless set to 3.'],
+ ['zh', '修改步数可能降低质量。默认首轮 8 步、细化 3 步;只有首轮为 8 步时才会使用两步生成,其他步数只生成一轮;细化步数不是 3 时,需少于首轮。'],
]) {
await t.test(`${language} node step tooltips include the three-step exception for valid plans`, async () => {
navigator.language = language;
diff --git a/web/freevideo.js b/web/freevideo.js
index a4ca3de..01ddec7 100644
--- a/web/freevideo.js
+++ b/web/freevideo.js
@@ -693,8 +693,8 @@ app.registerExtension({
const steps = this.widgets?.find(w => w.name === name);
if (steps) {
steps.label = text(en, zh);
- steps.tooltip = text('Changing steps may lower quality. Default: 8 first-pass and 3 refine steps. Refine steps must be fewer than first-pass steps unless set to 3.',
- '修改步数可能降低质量。默认首轮 8 步、细化 3 步;细化步数不是 3 时,需少于首轮。');
+ steps.tooltip = text('Changing steps may lower quality. Default: 8 first-pass and 3 refine steps. Two-step generation runs only with 8 first-pass steps. Other step counts use a single pass. Refine steps must be fewer than first-pass steps unless set to 3.',
+ '修改步数可能降低质量。默认首轮 8 步、细化 3 步;只有首轮为 8 步时才会使用两步生成,其他步数只生成一轮;细化步数不是 3 时,需少于首轮。');
}
}
for (const widget of this.widgets || []) {
diff --git a/web/generation_progress.js b/web/generation_progress.js
index aa4322f..eea1a40 100644
--- a/web/generation_progress.js
+++ b/web/generation_progress.js
@@ -145,6 +145,9 @@ const DOWNLOADS = {
reference_download: ['Downloading model files', '下载模型文件'],
};
const size = (bytes, unit) => (bytes / (unit === 'GiB' ? 2**30 : 2**20)).toFixed(1);
+// Asked for two passes with a first pass other than 8 steps: the engine ran one pass.
+const ranOnePass = plan => plan.requested === true && plan.enabled === false && plan.preview !== true
+ && Number.isInteger(plan.base_steps) && plan.base_steps > 0 && plan.base_steps !== 8;
// The fixed stage key (for the small bar and replays) and its sentence. Each
// number appears once: sampling says the step, a download says its size and speed.
function activityLabel(message, t, plan = {}, secondPass = false, references = false) {
@@ -174,7 +177,12 @@ function activityLabel(message, t, plan = {}, secondPass = false, references = f
};
const base = Number.isInteger(plan.base_steps) && plan.base_steps > 0 ? plan.base_steps : null;
const second = plan.second || plan.upscale_target;
- if (message.prediction || message.sampling_plan) return named('prepare');
+ if (message.prediction || message.sampling_plan) {
+ if (!ranOnePass(plan)) return named('prepare');
+ const n = plan.base_steps;
+ return {key: 'prepare', text: t(`Two-step generation needs 8 first-pass steps. This video uses a single ${n}-step pass.`,
+ `只有首轮为 8 步时才会使用两步生成,这次按 ${n} 步只生成一轮。`)};
+ }
if (phase === 'recovery') return message.retry?.reuse_sampling === true ? named('decode')
: message.retry?.reuse_first_pass === true ? steps('pass2', 'pass2') : named('prepare');
if (phase === 'sample_finalize') return named('decode');
@@ -195,7 +203,10 @@ function activityLabel(message, t, plan = {}, secondPass = false, references = f
const count = twoPass ? base : total;
const step = done === null || count === null ? null : Math.min(done + 1, count);
if (twoPass && plan.preview) return steps('preview', 'preview', step, count);
- return steps('pass1', twoPass ? 'first' : 'single', step, count);
+ const sampling = steps('pass1', twoPass ? 'first' : 'single', step, count);
+ if (!twoPass && ranOnePass(plan))
+ sampling.text += t(' (single pass; two-step generation needs 8 first-pass steps)', '(只生成一轮;两步生成需首轮 8 步)');
+ return sampling;
}
const key = labelActivities.get(message.label) || {
starting: 'prepare', prepare: 'prepare', prediction: 'prepare', describe: 'describe', encoding: 'combined',
diff --git a/web/studio.js b/web/studio.js
index 5839ca2..b33de3f 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -776,7 +776,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
// uses it with other steps is shown as custom and left unchanged.
const unavailable = Number(baseSteps.value) !== 8 && !twoPass.checked;
twoPass.disabled = Boolean(extension.source) || unavailable || linked(node, 'two_pass') || !widget(node, 'two_pass');
- twoPassStatus.textContent = unavailable ? t('Coming soon', '即将推出') : '';
+ twoPassStatus.textContent = Number(baseSteps.value) !== 8 ? t('Needs an 8-step first pass', '一采需 8 步') : '';
twoPassLabel.classList.toggle('fv-two-pass-unavailable', unavailable);
// A preview stops after the first pass, so it needs two-pass sampling.
if (!twoPass.checked && previewFirst.checked) {