2026-08-13 15:31:59 +07:00
|
|
|
"""Compare direct FL2VA H3 and sampler boundaries with captured Comfy state."""
|
2026-08-12 14:12:42 +07:00
|
|
|
|
|
|
|
|
import glob
|
|
|
|
|
|
|
|
|
|
import torch
|
|
|
|
|
|
|
|
|
|
from h3_blackwell_runtime.checkpoint import H3Checkpoint
|
|
|
|
|
from h3_blackwell_runtime.denoiser import H3PackedDenoiser
|
2026-08-13 15:31:59 +07:00
|
|
|
from h3_blackwell_runtime.packing import unpatchify_video
|
|
|
|
|
from h3_blackwell_runtime.sampler import res_multistep_update
|
2026-08-12 14:12:42 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
root = "/artifacts/fl2va-sampler-reference"
|
2026-08-13 15:31:59 +07:00
|
|
|
capture = "/artifacts/capture"
|
2026-08-12 14:12:42 +07:00
|
|
|
initial = torch.load(f"{root}/initial.pt", map_location="cuda", weights_only=False)
|
|
|
|
|
steps = [torch.load(path, map_location="cuda", weights_only=False) for path in sorted(glob.glob(f"{root}/step_*.pt"))]
|
|
|
|
|
sigmas = initial["sigmas"].to("cuda")
|
2026-08-13 15:31:59 +07:00
|
|
|
model = H3PackedDenoiser.from_checkpoint(
|
|
|
|
|
H3Checkpoint("/models/minimax_h3_fl2va_pruned_nvfp4.safetensors"), attention_backend="sage2"
|
|
|
|
|
).eval()
|
2026-08-12 14:46:43 +07:00
|
|
|
video_shape = (1, 24, 7, 12, 20)
|
|
|
|
|
video_count = torch.tensor(video_shape).prod().item()
|
2026-08-13 15:31:59 +07:00
|
|
|
old_video = old_sigma = None
|
|
|
|
|
|
2026-08-12 14:12:42 +07:00
|
|
|
for index, reference in enumerate(steps):
|
2026-08-13 15:31:59 +07:00
|
|
|
h3_input = torch.load(f"{capture}/input_{index:02d}.pt", map_location="cuda", weights_only=False)
|
|
|
|
|
h3_output = torch.load(f"{capture}/output_{index:02d}.pt", map_location="cuda", weights_only=False)
|
|
|
|
|
with torch.inference_mode():
|
|
|
|
|
raw_video, _ = model(
|
|
|
|
|
h3_input["hidden"].to("cuda"),
|
|
|
|
|
h3_input["timesteps"].to("cuda"),
|
|
|
|
|
h3_input["position_ids"].to("cuda"),
|
|
|
|
|
h3_input["segments"],
|
|
|
|
|
h3_output["video_segment"],
|
|
|
|
|
h3_output["audio_segment"],
|
|
|
|
|
)
|
|
|
|
|
video_out = unpatchify_video(raw_video, h3_output["video"].shape[2], h3_output["video"].shape[3], h3_output["video"].shape[4])
|
|
|
|
|
h3_delta = (video_out.float() - h3_output["video"].to("cuda").float()).abs()
|
|
|
|
|
|
|
|
|
|
state_video = reference["x"].to("cuda").reshape(-1)[:video_count].reshape(video_shape)
|
|
|
|
|
reference_denoised = reference["denoised"].to("cuda").reshape(-1)[:video_count].reshape(video_shape)
|
|
|
|
|
converted_denoised = state_video + sigmas[index] * h3_output["video"].to("cuda")
|
|
|
|
|
denoised_delta = (converted_denoised.float() - reference_denoised.float()).abs()
|
|
|
|
|
|
2026-08-13 14:58:04 +07:00
|
|
|
if index + 1 < len(steps):
|
2026-08-13 15:31:59 +07:00
|
|
|
previous_sigma = sigmas[index - 1] if index else None
|
|
|
|
|
updated = res_multistep_update(state_video, reference_denoised, sigmas[index], sigmas[index + 1], old_video, old_sigma, previous_sigma)
|
|
|
|
|
next_video = steps[index + 1]["x"].to("cuda").reshape(-1)[:video_count].reshape(video_shape)
|
|
|
|
|
update_delta = (updated.float() - next_video.float()).abs()
|
|
|
|
|
update_text = f"update_mean={update_delta.mean().item():.6g} update_max={update_delta.max().item():.6g}"
|
2026-08-13 14:58:04 +07:00
|
|
|
else:
|
2026-08-13 15:31:59 +07:00
|
|
|
update_text = "update_mean=final-unobserved update_max=final-unobserved"
|
|
|
|
|
|
|
|
|
|
print(
|
|
|
|
|
f"step={index:02d} "
|
|
|
|
|
f"h3_mean={h3_delta.mean().item():.6g} h3_max={h3_delta.max().item():.6g} "
|
|
|
|
|
f"denoised_mean={denoised_delta.mean().item():.6g} denoised_max={denoised_delta.max().item():.6g} "
|
|
|
|
|
f"{update_text}"
|
|
|
|
|
)
|
|
|
|
|
old_video, old_sigma = reference_denoised, sigmas[index + 1]
|