fast_spatial ¶
Spatial fast mode for the MLX Wan runtime (RIFE's spatial twin).
RIFE --fast cuts frames (temporal). This module cuts pixels (spatial): denoise at target // scale, decode at that size, then resample the decoded frames up to the target. No second denoise pass — that is --refine (quality). The two compose:
--fast-spatialalone → speed (≈ scale² fewer tokens)--refinealone → quality two-pass (H3 / LTX-2)--fast+--refine→ fewer frames at base res, full-res refine--fast+--fast-spatial→ fewer frames and fewer pixels
The upsample runs in pixel space, after the VAE decode. It used to run in latent space (bilinear over the latent H/W plane, sharing the refine hand-off primitive) and that is what made spatial fast mode incoherent: an interpolated Wan latent is off the decoder's manifold, so decode returned the right silhouette under a smeared veil. --refine can get away with the latent-space upsample because a second DMD pass re-denoises the result; spatial fast mode hands the latent straight to the decoder, so it cannot. See :mod:fastvideo.mlx_runtime.frame_upsample for the full rationale.
MetalFX is intentionally not used: it needs game-engine motion vectors and depth that diffusion output lacks.
Classes¶
fastvideo.mlx_runtime.fast_spatial.FastSpatialPlan dataclass ¶
FastSpatialPlan(plan: RefinePlan, upsample_mode: str, sharpen: float = DEFAULT_FAST_SPATIAL_SHARPEN)
Resolved geometry for a spatial-fast (upsample-only) run.
Attributes¶
fastvideo.mlx_runtime.fast_spatial.FastSpatialPlan.enabled property ¶
enabled: bool
Determine whether spatial scaling is enabled.
Returns:
| Type | Description |
|---|---|
bool |
|
fastvideo.mlx_runtime.fast_spatial.FastSpatialPlan.scale property ¶
scale: int
Provides the configured spatial scaling factor.
Returns:
| Name | Type | Description |
|---|---|---|
int | int | The spatial scaling factor. |
fastvideo.mlx_runtime.fast_spatial.FastSpatialPlan.stage1_height property ¶
stage1_height: int
Provide the stage-one latent height used for reduced-resolution processing.
Returns:
| Name | Type | Description |
|---|---|---|
int | int | The stage-one latent height. |
Functions:¶
fastvideo.mlx_runtime.fast_spatial.apply_fast_spatial_upsample ¶
apply_fast_spatial_upsample(frames: Iterable[ndarray], spatial: FastSpatialPlan) -> list[ndarray]
Resample decoded stage-1 frames up to the target resolution.
This runs on decoded RGB frames, not on latents: see the module docstring for why the latent-space version produced a blurred veil.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames | Iterable[ndarray] | Decoded HxWx3 uint8 RGB frames, produced by decoding at the stage-one resolution. | required |
spatial | FastSpatialPlan | Plan defining the target size, interpolation kernel, and unsharp strength. | required |
Returns:
| Type | Description |
|---|---|
list[ndarray] | list[np.ndarray]: Frames at the target resolution. When spatial scaling is disabled the frames are returned unchanged, as a list. |
Source code in fastvideo/mlx_runtime/fast_spatial.py
fastvideo.mlx_runtime.fast_spatial.plan_fast_spatial ¶
plan_fast_spatial(*, height: int, width: int, num_frames: int, spatial_scale: int = 2, vae_spatial_compression: int = 8, vae_temporal_compression: int = 4, patch_size: tuple[int, int, int] = (1, 2, 2), upsample_mode: str = DEFAULT_PIXEL_UPSAMPLE_MODE, sharpen: float = DEFAULT_FAST_SPATIAL_SHARPEN, enabled: bool = True) -> FastSpatialPlan
Build a plan for reduced-resolution denoising followed by pixel-space upsampling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
upsample_mode | str | Pixel interpolation kernel, one of :data: | DEFAULT_PIXEL_UPSAMPLE_MODE |
sharpen | float | Unsharp strength applied after the resize. | DEFAULT_FAST_SPATIAL_SHARPEN |
Returns:
| Name | Type | Description |
|---|---|---|
FastSpatialPlan | FastSpatialPlan | The validated spatial-fast processing plan. |
Raises:
| Type | Description |
|---|---|
ValueError | If the upsample mode is unsupported or |
Source code in fastvideo/mlx_runtime/fast_spatial.py
fastvideo.mlx_runtime.fast_spatial.resolve_spatial_mode ¶
Select the active spatial processing mode, with refinement taking precedence.
Returns:
| Name | Type | Description |
|---|---|---|
str | str |
|