Same Weights, Same Seed, Different Pixels: Porting PixRestore to ComfyUI
Описание и применение
Интеграция PixRestore в ComfyUI обеспечивает воспроизводимость официального eager‑путь с небольшими отличиями в пикселях, учитывая режимы выполнения, числовые настройки и преобразование изображений.
Задача
Ensuring that a custom PixRestore integration for ComfyUI reproduces the official eager execution results while handling differences in execution mode, numerical settings, and image conversion.
Результат
The integration reproduces the official eager execution results within a small numerical tolerance, identifies and documents sources of discrepancy, and establishes robust parity tests that detect incorrect computations.
Рабочий процесс
- 1. Define the official run: use PixRestore‑S model, PyTorch 2.14.1+cu130, and eager mode with TORCHDYNAMO_DISABLE=1.
- 2. Compare eager vs compiled paths: run official script in eager mode and compiled path with triton-windows; record differences.
- 3. Capture reference flags and apply them in a context manager before inference, then restore caller flags afterward.
- 4. Seed RNG inside torch.random.fork_rng to avoid altering ComfyUI’s state.
- 5. Convert output tensors to 8‑bit integers using the same normalization and clipping as the reference script, then return floats to ComfyUI.
- 6. Record hashes of intermediate values (input, noise, DINOv2 features, model output, final float image, 8‑bit result) for mismatch tracing.
- 7. Run parity tests with deliberate perturbations (seed change, feature scaling) to ensure tests detect incorrect computations.
- 8. Verify repeatability and caching behavior with A→B→A sequences and unload‑reload checks.
- 9. Document limits: only PixRestore‑S, 512×512, CFG 1.0, no tiling, no real‑photo evaluation.
- 10. Prepare example workflows and setup instructions in the repository.
Доказательства
11.3% of the output's 8‑bit channel values differed between them.
The integration captures the caller's backend settings, applies the reference settings for its call, and restores the caller's settings afterward.
The final 8‑bit comparison was: 11.3% of channel values differed. Maximum absolute difference: 5/255. Mean absolute difference: 0.11/255.
The CPU parity tests include two deliberate perturbations: Change the seed. Multiply the extracted DINOv2 features by 1.001.
- Дата записи: 2026-10-22T10:26:18.777Z