11 Commits
Author SHA1 Message Date
BerniniR 6382d7aaeb v1.1.5: fix attention backend silent failure + SDE sampler crash 2026-07-22 23:14:39 +08:00
xiaolibai-sys 164896ed78 bump v1.1.4: nvfp4 support, GPU LoRA fold, loader I/O pipeline, async D2H, unified logging
- nvfp4: _quantization_metadata -> comfy_quant synthesis, SlotEntry extra params (block_scale), dual-scale LoRA fold, orig_dtype fixup
- LoRA: plain-mode block LoRAs no longer silently dropped; folded on GPU after weights land
- loader: parallel positioned reads, pipelined group load, no per-tensor clone, header-only dtype probes
- block swap: read_block intra-block parallel + disk_workers node option; async D2H write-back on transfer stream; lazy evict_all skips wasted write-back
- arch: split models/loader.py out of wan_model.py; single utils/keys.py; LoRA folding consolidated in utils/lora.py; global utils/log.py ([BerniniR][Tag] format, BERNINI_LOG_LEVEL)
2026-07-21 14:07:05 +08:00
xiaolibai-sys bec4164798 LoraBlockReader: warn on unknown suffix keys (no silent skip) 2026-07-18 00:40:51 +08:00
xiaolibai-sys 4f510d6dd0 bump v1.1.2: unified slot architecture + LoraBlockReader on-demand LoRA
- Unified (block, lora) slot: SlotEntry carries co-located LoRA payload;
  fold consumes slot.lora -> None (no external bookkeeping).
- Resident mode: LoRA loaded into RAM, co-located per-block during
  streaming loop, pool freed after load (no change, already working).
- Lazy mode: new LoraBlockReader reads per-block LoRA on demand from
  disk via offset plan (no RAM pool). Same RandomAccessBlockReader data
  pipeline architecture.
- LoraBlockReader supports both Diffusers (lora_A/lora_B) and
  Kohya (lora_down/lora_up) key formats + DoRA (diff/diff_b) + alpha.
- DiskPrefetcher _attach_block_lora uses LoraBlockReader instead of
  model._lora_groups RAM dict, eliminating 1.5GB global LoRA pool
  in lazy mode.
- _normalize_unet_key extracted as shared module-level function.
- LoraTensorEntry dataclass moved to utils/types.py.
- Updated all BlockSwapManager/DiskHome call sites with lora_reader
  parameter threading.
2026-07-18 00:36:39 +08:00
xiaolibai-sys ad19628149 v1.1.1
Unify block-swap loading paths: SlotEntry + ring buffer + PinStage

- SlotEntry unifies regular Tensor and QuantizedTensor (fp8) handling,
  replacing p.data = d (a no-op on __torch_wrapper_subclass__) with
  module._parameters[key] = nn.Parameter(...)
- GPU ring buffer (cursor-based) replaces free-list — no explicit release
- PinStage @dataclass: pinned CPU staging ring, size = prefetch_count
- _detect_model_config merges duplicated config detection
- _block_swap config flag removed — model reads from self._block_swap_config
- StreamingBlockPipeline removed (dead code)
- BlockSwapManager always used when block_to_swap > 0; block_to_swap = 0
  falls back to standard GPU-only loading (1x memory, zero overhead)
- Fix: TeaCache pre-load bypassed block_swap_args (sampler.py:603)
- Fix: cache/guard paths now restore _block_swap_config if missing
- Fix: CUDA OOM with pin_memory on Windows — pin pool = prefetch_count
- Fix: black/noise output with pin path — sync transfer stream before assign_to
- Fix: shutdown size mismatch — offload_block copies slot-to-slot, not via freed params
- Remove: pinned_pool.py, block_ortho.py (dead code)
- Docs: README.md, README_DEVELOPER.md updated for v1.1.x architecture
2026-07-17 13:23:32 +08:00
xiaolibai-sys 1f0c475126 v1.1.0
Core
- Fix: p.data = d is a no-op on __torch_wrapper_subclass__ (QuantizedTensor).
  Replace with SlotEntry + module._parameters[key] reassignment, bypassing
  PyTorch's wrapper-subclass .data assignment interception.
- Fix: VAE decoder gray/NaN output caused by QuantizedTensor weight remaining
  on CPU during fp8 Linear forward.
- Fix: CUDA OOM on Windows when pin_memory=True — reduce pin pool size to
  prefetch_count (default 3) instead of W+prefetch (23); only use pin pool
  for prefetch loads (non_blocking=True).
- Fix: black output with pin_memory=True — run H2D copies on the transfer
  stream, sync before assign_to, so weights are fully written before forward.
- Fix: BlockSwap shutdown crash ("size 5120 vs 0") — offload_block copies
  GPU→home directly from slot entries, not through freed block params.
- Fix: Model switch RAM/VRAM leak — clear_pools() drops all pool tensor
  references; shutdown sets _blocks = [] and _home = None.
- Fix: update SlotEntry.empty_like to propagate pin_memory for QuantizedTensor
  _qdata and _params.scale (was silently unpinned).
- Remove dead code: pinned_pool.py, block_ortho.py (unreferenced).
- Audit utils/ for dead imports (PinnedBlockPool) and stale comments.

Architecture
- SlotEntry: unified data type for ring-buffer slot pool, abstracts regular
  Tensor and QuantizedTensor (fp8). copy_from() copies weight data; assign_to()
  rewires module._parameters with a fresh GPU QuantizedTensor.
- Ring buffer (cursor % N) replaces free-list for GPU slot allocation.
- PinStage @dataclass: standalone pinned CPU staging ring, built lazily from
  GPU entry metadata (safe device-independent construction).
- _detect_model_config(): merge duplicated ~80-line config detection in
  load_bernini_model (was written twice for safetensors vs full-SD paths).
- BlockSwapConfig: unified config path. model.load() accepts BerniniBlockSwap
  dataclass; model stores it as self._block_swap_config; pre_forward reads it
  directly instead of via transformer_options.

Features
- loading_mode dropdown (Full / Streaming) in BerniniR_BlockSwapArgs node.
- Block swap node exposes pin_memory, loading_mode selections.

Context window
- Fix: compatibility with differential diffusion (color blocks, artifacts) —
  correct mask accumulation and crossfade when edit_mask is active.
2026-07-17 11:28:18 +08:00
xiaolibai-sys 520d9ae6cd fix: FreeNoise color shift + RAM not released after model unload
Two fixes for dual-expert 14B sampling:

1. FreeNoise color shift (bernini_sampling.py)
   - Clone noise before FreeNoise shuffling so differential diffusion
     uses original i.i.d. noise (model trained on i.i.d.).
   - FreeNoise-shuffled noise only for k-diffusion x_T initialization.

2. RAM not released after model unload (model_manager.py)
   - BerniniRModelHandle.unload() now calls release_model_ram() before
     mm.unload_model_and_clones, replacing all parameters with empty
     tensors via module._parameters[key] = empty(0).
   - Fixed _make_low_wrapper closure dropping high_model reference via
     nonlocal, causing the cleanup loop to call None.unload().
2026-07-16 15:00:30 +08:00
xiaolibai-sys 7cd21a0a26 v1.0.4: robustness fixes R1-R8 + official ComfyUI conditioning parity
- R1 model_manager: include block_swap in LRU cache key (prevents reusing a
  non-block-swap patcher for a block-swap request)
- R2 conditioning: _resize_long_edge aligned to official ComfyUI BerniniConditioning
  (round() + always re-upscale), max(stride,...) guards 0-dim on thin strips
- R3 conditioning: source/reference trimmed to length, NO loop-pad (matches
  official edit-canvas semantics; context is in-context ref along seq dim)
- R4 segment_schedule: swap reversed start>end ranges instead of producing
  empty/negative segments
- R6 conditioning: snap temporal_overlap to multiple of 4, min 4 (exact latent trim)
- R7 block_swap: _max_prefetch guards block_mb<=0 division-by-zero
- R5 guidance_schedule: confirmed false-positive (steps<=1 guards already present)
- R8 prompt_embedding/segment_schedule: clip_loaded_internally flag (left as-is per user)
- pyproject.toml: bump 1.0.3 -> 1.0.4
2026-07-15 12:42:23 +08:00
xiaolibai-sys a177ad5dbc v1.0.3: fix FreeNoise double/zero-apply, TeaCache+compile guard, isolated compile cache, stale-comment cleanup
- FreeNoise: applied exactly once on the single-sampler path; now also applied on the dual-expert path (was zero)
- TeaCache: restores eager transformer_forward when the model is torch.compiled, so block-skipping actually engages (previously silent no-op)
- Compile cache: isolated to %TEMP%/bernini_r_inductor_cache (env-overridable), version-gated purge + manual purge via BerniniR_CompileModel.purge_cache / BERNINI_PURGE_COMPILE_CACHE
- Removed web/guidance_ui.js frontend (guidance moved to the BerniniR_GuidanceConfig node); dropped WEB_DIRECTORY export
- Stale-comment cleanup across nodes/ and utils/; refreshed README and added README_DEVELOPER
- Bump version to 1.0.3
2026-07-15 11:08:43 +08:00
xiaolibai-sys 3e4539deaa Update block_swap.py 2026-07-15 02:27:34 +08:00
Wen Li 91ce7daa7b Initial commit: ComfyUI-BerniniR Wrapper v1.0.0
Seven-mode guidance (CFG/APG/RAAG/S2/Z2/STG_A/STG_R), context-window sampling, segment prompt-travel, lazy streaming load, layered VRAM management.
2026-07-15 00:54:57 +08:00