Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.7 KiB
id, title, status, type, domain, scope, priority, depends, blocks, related, created, updated, tags
| id | title | status | type | domain | scope | priority | depends | blocks | related | created | updated | tags | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0082 | Compilar binario `sd` (stable-diffusion.cpp) para sdcli_generate_go_ml | pendiente | feature |
|
multi-app | media | 2026-05-13 | 2026-05-17 |
Objetivo
Compilar el binario sd de leejet/stable-diffusion.cpp
con backend CUDA en este host (WSL2 + RTX 3070) e instalarlo en $PATH. Habilita
los tests reales de sdcli_generate_go_ml y el wrapper Go subprocess (Ola 3.C ya
construido pero con tests en skip por falta de binario).
Contexto
- Funcion Go
sdcli_resolve_binary_go_mlbuscasdosd-clien$PATH. sdcli_generate_go_mlorquesta args viagenconfig_to_sdcli_args_go_ml, lanza subproceso consubprocess_stream_go_core, parsea progreso consdcli_parse_progress_go_ml, lee PNG de salida.- Tests
TestSdcliResolveBinary_NotFound,..._Hintpasan;TestSdcliGenerate_RequiresBinaryhacet.Skip()porquesdno existe en$PATH. - Backend
sdcpp_python_load_py_mlya validado con SD Turbo (CPU, 27s/imagen). El binario Go nativo deberia ser comparable o mejor con CUDA.
Arquitectura
Archivos NUEVOS sugeridos:
bash/functions/infra/build_sd_cpp.sh+.md— funcion del registry que clona y compila stable-diffusion.cpp con flags configurables (-DSD_CUDA=ON,-DSD_FLASH_ATTN=ON,-DSD_FAST_SOFTMAX=ON). Idempotente.bash/functions/infra/install_sd_cpp_bin.sh+.md— copia el binario compilado a~/.local/bin/sdo equivalente en$PATH.
NO modificar:
functions/ml/sdcli_*.go— su contrato no cambia, solo se desbloquea el path feliz.
Tareas
-
Compilacion 1.1. Clonar
https://github.com/leejet/stable-diffusion.cppensources/stable-diffusion.cpp/. 1.2. Verificar requisitos:cmake >= 3.18,gcc, CUDA toolkit (instalable concuda_toolkit_check_bash_infra). Si CUDA toolkit falta, instalarlo o documentar pasos manuales. 1.3. Crearbash/functions/infra/build_sd_cpp.shque: - Acepta flag--backend cuda|cpu|vulkan- cmake -B build -DSD_CUDA=ON (segun flag) - cmake --build build -j - Verifica quebuild/bin/sdobuild/sdexiste. 1.4. Crearbash/functions/infra/install_sd_cpp_bin.shque copiasda~/.local/bin/y verificacommand -v sd. -
Smoke test 2.1. Ejecutar
sd --versiondesde Go:SdcliResolveBinary("")debe encontrarlo. 2.2. Generar 1 imagen con SD Turbo.safetensorsy comparar tiempo vssdcpp_python(esperado: similar o mejor con CUDA). -
Indexar 3.1.
./fn indexy verificar 2 funciones nuevas. -
Cleanup 4.1. Re-run
CGO_ENABLED=1 go test -tags fts5 -run TestSdcliGenerate ./functions/ml/—TestSdcliGenerate_RequiresBinarydebe pasar sin skip.
Ejemplo de uso
fn run build_sd_cpp --backend cuda
fn run install_sd_cpp_bin
sd --help # ya en PATH
./fn doctor ml # sd_cli debe pasar a "ok"
Decisiones
- Compilar en
sources/(gitignored) — no commitear binario. - Instalar en
~/.local/bin/— sin sudo, en$PATHpor defecto en shells. - Backend CUDA preferido — esta maquina tiene RTX 3070 (8GB). CPU es fallback.
Prerequisitos
- Issues 3.B/3.C completados (sdcpp_python + sdcli go scaffolding).
- Modelo SD Turbo en vault (ya esta).
Riesgos
- CUDA toolkit no instalado:
nvccausente segunfn doctor ml. Mitigacion: fallback CPU (-DSD_CUDA=OFF) o instalar toolkit primero. - API rota entre versiones de
sd: pinear release concreto (tag git) en el script. - Binario grande (~200MB con CUDA libs estaticas): vale, sources/ esta gitignored.