h3-blackwell-runtime/tools/validate_captured_denoiser.py
2026-08-12 14:12:42 +07:00

33 lines
1.2 KiB
Python

"""Run the direct H3 core against one matched ComfyUI capture."""
import time
import torch
from h3_blackwell_runtime.checkpoint import H3Checkpoint
from h3_blackwell_runtime.denoiser import H3PackedDenoiser
capture_dir = "/artifacts/capture"
inputs = torch.load(f"{capture_dir}/input.pt", map_location="cuda", weights_only=False)
expected = torch.load(f"{capture_dir}/output.pt", map_location="cuda", weights_only=False)
checkpoint = H3Checkpoint("/models/minimax_h3_ref2va_pruned_nvfp4.safetensors")
start = time.perf_counter()
model = H3PackedDenoiser.from_checkpoint(checkpoint).eval()
with torch.inference_mode():
video, audio = model(
inputs["hidden"],
inputs["timesteps"],
inputs["position_ids"],
inputs["segments"],
expected["video_segment"],
expected["audio_segment"],
)
torch.cuda.synchronize()
for name, actual, reference in (("video", video, expected["video"]), ("audio", audio, expected["audio"])):
reference = reference.reshape_as(actual)
delta = (actual.float() - reference.float()).abs()
print(f"{name} shape={tuple(actual.shape)} max_abs={delta.max().item():.6g} mean_abs={delta.mean().item():.6g}")
print(f"elapsed_s={time.perf_counter() - start:.3f}")