Files
fn_registry/python/functions/ml/diffusers_load_pipeline.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.2 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
diffusers_load_pipeline function py ml 1.0.0 impure def diffusers_load_pipeline(model: ModelRef, device: str = 'auto', dtype: str = 'fp16') -> Any Carga un pipeline diffusers (AutoPipelineForText2Image) con cache global por (model_key, dtype, device). Segunda llamada con mismos parametros retorna el objeto cacheado sin recargar disco.
diffusers
ml
image-generation
pipeline
cache
torch
pendiente-usar
torch_device_select_py_ml
model_ref_py_ml
false error_go_core
torch
diffusers
name desc
model Referencia al modelo. model.path si disponible (ruta local), model.name si no (HuggingFace Hub o nombre corto).
name desc
device Preferencia de device: 'auto' (CUDA>MPS>CPU), 'cuda', 'cuda:N', 'mps', 'cpu'. Default 'auto'.
name desc
dtype Precision del modelo: 'fp16' (torch.float16 + variant=fp16), 'bf16' (bfloat16), 'fp32' (float32). Default 'fp16'.
Pipeline diffusers cargado y movido al device. Callable via pipe(prompt=..., ...). Cacheado en _PIPELINE_CACHE. true
carga pipeline y retorna callable
segunda carga usa cache (< 100ms)
python/functions/ml/tests/test_diffusers_backend.py python/functions/ml/diffusers_load_pipeline.py

Ejemplo

import sys
sys.path.insert(0, "python/functions/ml")
from diffusers_load_pipeline import diffusers_load_pipeline
from model_ref import ModelRef

model = ModelRef(
    name="sd-turbo",
    model_type="sd15",
    quantization="fp16",
    path="/home/lucas/vaults/imagegen_models/diffusers/sd-turbo",
)
pipe = diffusers_load_pipeline(model, device="cuda", dtype="fp16")
# Segunda llamada: cache hit, < 100ms
pipe2 = diffusers_load_pipeline(model, device="cuda", dtype="fp16")
assert pipe is pipe2

Notas

Cache global _PIPELINE_CACHE indexado por (model_key, dtype, resolved_device). model_key es model.path si no es None, sino model.name.

Para liberar memoria: usar diffusers_unload(pipe=None) que llama _clear_pipeline_cache().

Imports lazy de torch y diffusers dentro de la funcion — ImportError descriptivo si no instalados.