• Stefy Lanza (nextime / spora )'s avatar
    video: hook-based offload for injected cache components (fix device mismatch); gen retry safety net · 9ed35326
    Stefy Lanza (nextime / spora ) authored
    The incremental per-component cache built and cached all components correctly, but
    generation then failed:
    
      RuntimeError: Expected all tensors to be on the same device, but got index is on
      cuda:0, different from other tensors on cpu (... wrapper_CUDA__index_select)
    
    Cause: the load used the `balanced` (device_map) strategy. accelerate's device_map
    only dispatches components it LOADS — injected pre-loaded components keep whatever
    device they're on (CPU) with NO offload hook, so a forward pass mixes cuda inputs
    with cpu weights.
    
    Fix: when incremental cached components are injected, force a HOOK-based offload
    (model → group → sequential), which add offload hooks to EVERY component in the
    pipeline (injected included). model CPU offload keeps only the active ~7 GB 4-bit
    expert resident, so it fits easily and is fast. device_map strategies
    (balanced/disk) are skipped in this case.
    
    Safety net: a non-OOM generation failure that looks like a device mismatch now
    retries ONCE with the incremental cache disabled (plain build = pre-cache
    behaviour), so generation self-heals even if the injection path is imperfect
    instead of wedging the queue. (Load-time failures already fall back this way.)
    Co-Authored-By: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01RdMufYvtTbtGDWsiZVoXce
    9ed35326
video.py 164 KB