• Stefy Lanza (nextime / spora )'s avatar
    bring the text encoder back before using it again · df66aa56
    Stefy Lanza (nextime / spora ) authored
    Production, 2026-10-28: Krea-2-Turbo answered one request and then 500ed.
    
        RuntimeError: Expected all tensors to be on the same device, but got
        index is on cuda:0, different from other tensors on cpu
    
    The offload moved the encoder to the CPU and the pipeline is CACHED, so the
    next request met an encoder that was no longer where encode_prompt indexes.
    _free's docstring even said the encoder "waits in host RAM ... the next
    request needs it again" -- and nothing ever brought it back.
    
    What turned that into a 500 rather than a skipped optimisation: the side
    effect outlives this function. The bail-out path returns the original kwargs
    and lets the pipeline generate "the ordinary way", but the ordinary way calls
    the SAME encoder, so it hit the same mismatch and the request failed anyway.
    A fallback that leaves the thing it fell back to broken is not a fallback.
    
    So the offload is a per-request cycle -- bring the encoder on, encode, move it
    off -- and every bail-out restores the encoder first, because each one hands
    the request to a path that needs it on the GPU.
    
    The regression test drives a pipeline that really refuses to encode off-device
    and asserts the SECOND request still works; without the restore it reproduces
    the production message exactly. A second test pins the weaker promise that any
    bail-out leaves the encoder where the ordinary path can use it.
    
    Found by the operator mid-render, not by the suite: every check so far ran one
    request per model against a freshly started engine, which is the one case that
    cannot fail.
    Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_014T3rZozi1Ehk96NG1WesgC
    df66aa56
Name
Last commit
Last update
..
admin Loading commit data...
api Loading commit data...
backends Loading commit data...
broker Loading commit data...
cluster Loading commit data...
compose Loading commit data...
frontproxy Loading commit data...
models Loading commit data...
ocr Loading commit data...
openai Loading commit data...
pipelines Loading commit data...
pydantic Loading commit data...
queue Loading commit data...
tasks Loading commit data...
util Loading commit data...
__init__.py Loading commit data...
cli.py Loading commit data...
config.py Loading commit data...
hf_cache.py Loading commit data...
main.py Loading commit data...
ocr_fleet_workers.py Loading commit data...
platform_paths.py Loading commit data...
system_app.py Loading commit data...