{"record":{"id":"46e5b9f4d220b057","repo":"mudler/LocalAI","slug":"acestep-cpp-error-models-not-loaded-n","errorCode":null,"errorMessage":"[acestep-cpp] ERROR: models not loaded\\n","messagePattern":"\\[acestep-cpp\\] ERROR: models not loaded\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/acestep-cpp/cpp/goacestepcpp.cpp","lineNumber":118,"sourceCode":"            return 2;\n        }\n    }\n\n    // Load VAE model\n    fprintf(stderr, \"[acestep-cpp] Loading VAE from %s\\n\", vae_model_path);\n    vae_ggml_load(&g_vae, vae_model_path);\n    g_vae_loaded = true;\n\n    fprintf(stderr, \"[acestep-cpp] All models loaded successfully (turbo=%d)\\n\", g_is_turbo);\n    return 0;\n}\n\nint generate_music(const char * caption, const char * lyrics, int bpm,\n                   const char * keyscale, const char * timesignature,\n                   float duration, float temperature, bool instrumental,\n                   int seed, const char * dst, int threads) {\n    if (!g_dit_loaded || !g_vae_loaded) {\n        fprintf(stderr, \"[acestep-cpp] ERROR: models not loaded\\n\");\n        return 1;\n    }\n\n    const int FRAMES_PER_SECOND = 25;\n\n    // Defaults\n    if (duration <= 0)\n        duration = 30.0f;\n    std::string cap_str    = caption ? caption : \"\";\n    std::string lyrics_str = (instrumental || !lyrics) ? \"\" : lyrics;\n    std::string ks_str     = keyscale ? keyscale : \"N/A\";\n    std::string ts_str     = timesignature ? timesignature : \"4/4\";\n    std::string lang_str   = \"unknown\";\n    char        bpm_str[16];\n    if (bpm > 0) {\n        snprintf(bpm_str, sizeof(bpm_str), \"%d\", bpm);\n    } else {\n        snprintf(bpm_str, sizeof(bpm_str), \"N/A\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/acestep-cpp/cpp/goacestepcpp.cpp#L100-L136","documentation":"acestep-cpp guard inside generate_music(): it refuses to run unless both g_dit_loaded and g_vae_loaded are true (set only after successful load_model stages). Calling generation before a fully successful load returns 1 with this message — typically a client/orchestration bug that skipped or did not check load_model's return code.","triggerScenarios":"Invoking generate_music after load_model returned 1/2/3 and the caller ignored it, or calling generate_music on a fresh process where load_model was never invoked; the boolean guard trips.","commonSituations":"Go binding callers not propagating load_model's error; race where a request arrives during model load; retries after a failed load that never re-attempt loading.","solutions":["Check load_model's return value; only expose generation after it returns 0.","Gate the service endpoint behind a readiness flag set on successful load; return 503 until then.","If load failed, fix per its log line (errors 154-156) and reload before retrying generation."],"exampleFix":"// before\nload_model(lm, te, dit, vae);          // return ignored\ngenerate_music(...);                    // ERROR: models not loaded\n\n// after\nif (load_model(lm, te, dit, vae) != 0) {\n    return fmt.Errorf(\"model load failed\");\n}\ngenerate_music(...);","handlingStrategy":"type-guard","validationCode":"// expose readiness only after a fully successful load\nint rc = load_model(lm, te, dit, vae);\nready = (rc == 0);  // g_dit_loaded && g_vae_loaded are set on success\nif (!ready) return rc;","typeGuard":"bool models_ready() {\n    return g_dit_loaded && g_vae_loaded;  // mirrors generate_music's own guard\n}","tryCatchPattern":null,"preventionTips":["Always check load_model's return code; propagate it to the caller instead of continuing.","Gate the generation endpoint behind a readiness flag / health check that flips only on rc==0.","On load failure, fix the load error (154-156) and reload — retrying generate alone will keep failing."],"tags":["cpp","acestep","lifecycle","guard","music-generation"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}