fix
This commit is contained in:
@@ -346,6 +346,7 @@ surfaces:
|
||||
num_inference_steps: request.sampling.num_inference_steps
|
||||
num_inference_steps_sr: request.sampling.num_inference_steps_sr
|
||||
guidance_scale: request.sampling.guidance_scale
|
||||
guidance_scale_2: request.sampling.guidance_scale_2
|
||||
guidance_rescale: request.sampling.guidance_rescale
|
||||
boundary_ratio: request.sampling.boundary_ratio
|
||||
sigmas: request.sampling.sigmas
|
||||
@@ -365,15 +366,7 @@ surfaces:
|
||||
data_type: "Derived from the request shape and not a public input."
|
||||
|
||||
sampling_param_extensions:
|
||||
moved:
|
||||
guidance_scale_2:
|
||||
target: request.sampling.guidance_scale_2
|
||||
sources:
|
||||
- fastvideo.configs.sample.lingbotworld.LingBotWorld_SamplingParam
|
||||
- fastvideo.configs.sample.lingbotworld.Wan2_2_I2V_A14B_SamplingParam
|
||||
- fastvideo.configs.sample.wan.SelfForcingWan2_2_T2V_A14B_480P_SamplingParam
|
||||
- fastvideo.configs.sample.wan.Wan2_2_I2V_A14B_SamplingParam
|
||||
- fastvideo.configs.sample.wan.Wan2_2_T2V_A14B_SamplingParam
|
||||
moved: {}
|
||||
profile_owned:
|
||||
action_list:
|
||||
target: request.extensions.hunyuangamecraft.action_list
|
||||
@@ -598,6 +591,7 @@ cli:
|
||||
- text_encoder_cpu_offload
|
||||
- text_encoder_precisions
|
||||
- torch_compile_kwargs
|
||||
- transformer_quant
|
||||
- tp_size
|
||||
- trust_remote_code
|
||||
- use_fsdp_inference
|
||||
@@ -703,6 +697,7 @@ cli:
|
||||
- text_encoder_cpu_offload
|
||||
- text_encoder_precisions
|
||||
- torch_compile_kwargs
|
||||
- transformer_quant
|
||||
- tp_size
|
||||
- trust_remote_code
|
||||
- use_fsdp_inference
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
"""Triton kernel entrypoints exposed by ``fastvideo_kernel``."""
|
||||
|
||||
from .fused_attention import attention as fused_attention
|
||||
|
||||
__all__ = ["fused_attention"]
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Compatibility shim for the legacy non-QAT Triton attention import path.
|
||||
|
||||
Historically callers imported
|
||||
``fastvideo_kernel.triton_kernels.fused_attention`` directly. The shared
|
||||
implementation now lives in ``attn_qat_train.py`` and is parameterized by the
|
||||
``IS_QAT`` flag. This module preserves the original public API for tests and
|
||||
downstream users while always dispatching to the non-QAT configuration.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import torch
|
||||
|
||||
from .attn_qat_train import attention as _attention
|
||||
|
||||
|
||||
def attention(
|
||||
q: torch.Tensor,
|
||||
k: torch.Tensor,
|
||||
v: torch.Tensor,
|
||||
causal: bool,
|
||||
sm_scale: float,
|
||||
warp_specialize: bool = True,
|
||||
) -> torch.Tensor:
|
||||
"""Run the shared Triton attention kernel in non-QAT mode."""
|
||||
use_qat_qkv_backward = True
|
||||
smooth_k = False
|
||||
is_qat = False
|
||||
two_level_quant_p = False
|
||||
fake_quant_p = False
|
||||
use_high_prec_o = False
|
||||
smooth_q = False
|
||||
use_global_sf_p = False
|
||||
use_global_sf_qkv = False
|
||||
|
||||
return _attention(
|
||||
q,
|
||||
k,
|
||||
v,
|
||||
causal,
|
||||
sm_scale,
|
||||
use_qat_qkv_backward,
|
||||
smooth_k,
|
||||
warp_specialize,
|
||||
is_qat,
|
||||
two_level_quant_p,
|
||||
fake_quant_p,
|
||||
use_high_prec_o,
|
||||
smooth_q,
|
||||
use_global_sf_p,
|
||||
use_global_sf_qkv,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["attention"]
|
||||
@@ -0,0 +1,4 @@
|
||||
from ._bootstrap import ensure_local_kernel_sources_first
|
||||
|
||||
|
||||
ensure_local_kernel_sources_first()
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
"""Test import helpers for preferring the in-tree fastvideo-kernel sources."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _prepend_import_path(path: Path) -> None:
|
||||
path_str = str(path)
|
||||
if path_str not in sys.path:
|
||||
sys.path.insert(0, path_str)
|
||||
|
||||
|
||||
def _purge_package(name: str) -> None:
|
||||
prefix = f"{name}."
|
||||
for module_name in tuple(sys.modules):
|
||||
if module_name == name or module_name.startswith(prefix):
|
||||
sys.modules.pop(module_name, None)
|
||||
|
||||
|
||||
def _module_is_from_checkout(module_file: str | None, checkout_root: Path) -> bool:
|
||||
if module_file is None:
|
||||
return False
|
||||
|
||||
try:
|
||||
module_path = Path(module_file).resolve()
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
return module_path.is_relative_to(checkout_root.resolve())
|
||||
|
||||
|
||||
def ensure_local_kernel_sources_first() -> None:
|
||||
tests_root = Path(__file__).resolve().parent
|
||||
kernel_root = tests_root.parent
|
||||
repo_root = kernel_root.parent
|
||||
kernel_python_root = kernel_root / "python"
|
||||
|
||||
# Keep the in-tree kernel sources ahead of any preinstalled wheel so tests
|
||||
# exercise the checkout under review.
|
||||
for path in (repo_root, kernel_root, kernel_python_root):
|
||||
_prepend_import_path(path)
|
||||
|
||||
importlib.invalidate_caches()
|
||||
|
||||
loaded_kernel = sys.modules.get("fastvideo_kernel")
|
||||
if loaded_kernel is None:
|
||||
return
|
||||
|
||||
if not _module_is_from_checkout(
|
||||
getattr(loaded_kernel, "__file__", None),
|
||||
kernel_python_root,
|
||||
):
|
||||
_purge_package("fastvideo_kernel")
|
||||
@@ -0,0 +1,4 @@
|
||||
from ._bootstrap import ensure_local_kernel_sources_first
|
||||
|
||||
|
||||
ensure_local_kernel_sources_first()
|
||||
@@ -0,0 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import types
|
||||
from pathlib import Path
|
||||
|
||||
from tests._bootstrap import ensure_local_kernel_sources_first
|
||||
|
||||
|
||||
def test_bootstrap_prefers_local_kernel_checkout(monkeypatch) -> None:
|
||||
tests_root = Path(__file__).resolve().parent
|
||||
kernel_root = tests_root.parent
|
||||
repo_root = kernel_root.parent
|
||||
kernel_python_root = kernel_root / "python"
|
||||
|
||||
stale_module = types.ModuleType("fastvideo_kernel")
|
||||
stale_module.__file__ = (
|
||||
"/tmp/site-packages/fastvideo_kernel/__init__.py"
|
||||
)
|
||||
monkeypatch.setitem(sys.modules, "fastvideo_kernel", stale_module)
|
||||
monkeypatch.setattr(sys, "path", ["/tmp/site-packages"])
|
||||
|
||||
ensure_local_kernel_sources_first()
|
||||
|
||||
assert "fastvideo_kernel" not in sys.modules
|
||||
assert sys.path[:3] == [
|
||||
str(kernel_python_root),
|
||||
str(kernel_root),
|
||||
str(repo_root),
|
||||
]
|
||||
@@ -107,6 +107,8 @@ def legacy_from_pretrained_to_config(
|
||||
engine[key] = value
|
||||
elif key == "override_text_encoder_quant":
|
||||
quantization["text_encoder_quant"] = value
|
||||
elif key == "transformer_quant":
|
||||
quantization["transformer_quant"] = value
|
||||
elif key == "workload_type":
|
||||
pipeline["workload_type"] = value
|
||||
elif key == "lora_path":
|
||||
|
||||
@@ -436,96 +436,6 @@ class FastVideoArgs:
|
||||
help="BSA chunk_3d_shape_k as three ints, e.g., 4 4 4.",
|
||||
)
|
||||
|
||||
# LTX-2 VAE tiling overrides
|
||||
parser.add_argument(
|
||||
"--ltx2-vae-tiling",
|
||||
action=StoreBoolean,
|
||||
default=FastVideoArgs.ltx2_vae_tiling,
|
||||
help="Enable LTX-2 VAE tiling overrides.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ltx2-vae-spatial-tile-size-in-pixels",
|
||||
type=int,
|
||||
default=FastVideoArgs.ltx2_vae_spatial_tile_size_in_pixels,
|
||||
help="LTX-2 VAE spatial tile size in pixels.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ltx2-vae-spatial-tile-overlap-in-pixels",
|
||||
type=int,
|
||||
default=FastVideoArgs.ltx2_vae_spatial_tile_overlap_in_pixels,
|
||||
help="LTX-2 VAE spatial tile overlap in pixels.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ltx2-vae-temporal-tile-size-in-frames",
|
||||
type=int,
|
||||
default=FastVideoArgs.ltx2_vae_temporal_tile_size_in_frames,
|
||||
help="LTX-2 VAE temporal tile size in frames.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ltx2-vae-temporal-tile-overlap-in-frames",
|
||||
type=int,
|
||||
default=FastVideoArgs.ltx2_vae_temporal_tile_overlap_in_frames,
|
||||
help="LTX-2 VAE temporal tile overlap in frames.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ltx2-initial-latent-path",
|
||||
type=str,
|
||||
default=FastVideoArgs.ltx2_initial_latent_path,
|
||||
help="Path to load/save a precomputed LTX-2 initial latent.",
|
||||
)
|
||||
|
||||
# LoRA parameters (inference-time adapter loading)
|
||||
parser.add_argument(
|
||||
"--lora-path",
|
||||
type=str,
|
||||
default=FastVideoArgs.lora_path,
|
||||
help="Path to a LoRA adapter (directory or HF repo id). If set, LoRA will be applied at inference.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lora-nickname",
|
||||
type=str,
|
||||
default=FastVideoArgs.lora_nickname,
|
||||
help="Nickname to refer to the loaded LoRA adapter (useful for swapping).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--lora-target-modules",
|
||||
nargs="+",
|
||||
type=str,
|
||||
default=FastVideoArgs.lora_target_modules,
|
||||
help="Optional list of module name substrings to restrict LoRA injection (e.g. q_proj k_proj v_proj).",
|
||||
)
|
||||
|
||||
# BSA runtime control (LongCat)
|
||||
parser.add_argument(
|
||||
"--enable-bsa",
|
||||
action=StoreBoolean,
|
||||
help="Enable Block Sparse Attention (BSA) at runtime (overrides config).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bsa-sparsity",
|
||||
type=float,
|
||||
help="BSA sparsity (e.g., 0.9375).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bsa-cdf-threshold",
|
||||
type=float,
|
||||
help="BSA CDF threshold (optional).",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bsa-chunk-q",
|
||||
nargs=3,
|
||||
type=int,
|
||||
metavar=("T", "H", "W"),
|
||||
help="BSA chunk_3d_shape_q as three ints, e.g., 4 4 4.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bsa-chunk-k",
|
||||
nargs=3,
|
||||
type=int,
|
||||
metavar=("T", "H", "W"),
|
||||
help="BSA chunk_3d_shape_k as three ints, e.g., 4 4 4.",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--enable-torch-compile",
|
||||
action=StoreBoolean,
|
||||
@@ -551,11 +461,6 @@ class FastVideoArgs:
|
||||
action=StoreBoolean,
|
||||
help="Enable layerwise CPU offload with async H2D prefetch overlap.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dit-layerwise-offload",
|
||||
action=StoreBoolean,
|
||||
help="Enable layerwise CPU offload with async H2D prefetch overlap.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--use-fsdp-inference",
|
||||
action=StoreBoolean,
|
||||
@@ -645,12 +550,6 @@ class FastVideoArgs:
|
||||
default=FastVideoArgs.override_pipeline_cls_name,
|
||||
help="Override pipeline cls name",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--override-pipeline-cls-name",
|
||||
type=str,
|
||||
default=FastVideoArgs.override_pipeline_cls_name,
|
||||
help="Override pipeline cls name",
|
||||
)
|
||||
parser.add_argument("--init-weights-from-safetensors",
|
||||
type=str,
|
||||
help="Path to safetensors file for initial weight loading")
|
||||
|
||||
@@ -235,8 +235,8 @@ def test_cli_dest_inventory_matches_live_parsers() -> None:
|
||||
def test_review_gap_fields_are_explicitly_inventory_tracked() -> None:
|
||||
inventory = _load_inventory()
|
||||
|
||||
sampling_extensions = inventory["surfaces"]["sampling_param_extensions"]
|
||||
assert "guidance_scale_2" in sampling_extensions["moved"]
|
||||
sampling_base = inventory["surfaces"]["sampling_param_base"]
|
||||
assert "guidance_scale_2" in sampling_base["moved"]
|
||||
|
||||
image_request = inventory["surfaces"]["openai_image_request"]
|
||||
video_request = inventory["surfaces"]["openai_video_request"]
|
||||
|
||||
Reference in New Issue
Block a user