{"record":{"id":"3aad73c72907961a","repo":"mudler/LocalAI","slug":"acestep-cpp-error-t-d-exceeds-max-15000-n","errorCode":null,"errorMessage":"[acestep-cpp] ERROR: T=%d exceeds max 15000\\n","messagePattern":"\\[acestep-cpp\\] ERROR: T=(.+?) exceeds max 15000\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/acestep-cpp/cpp/goacestepcpp.cpp","lineNumber":154,"sourceCode":"        snprintf(bpm_str, sizeof(bpm_str), \"N/A\");\n    }\n\n    int   num_steps      = 8;\n    float guidance_scale = g_is_turbo ? 1.0f : 7.0f;\n    float shift          = 1.0f;\n\n    if (seed < 0) {\n        std::random_device rd;\n        seed = (int)(rd() & 0x7FFFFFFF);\n    }\n\n    // Compute T (latent frames at 25Hz)\n    int T = (int)(duration * FRAMES_PER_SECOND);\n    T     = ((T + g_dit.cfg.patch_size - 1) / g_dit.cfg.patch_size) * g_dit.cfg.patch_size;\n    int S = T / g_dit.cfg.patch_size;\n\n    if (T > 15000) {\n        fprintf(stderr, \"[acestep-cpp] ERROR: T=%d exceeds max 15000\\n\", T);\n        return 2;\n    }\n\n    int Oc     = g_dit.cfg.out_channels;      // 64\n    int ctx_ch = g_dit.cfg.in_channels - Oc;  // 128\n\n    fprintf(stderr, \"[acestep-cpp] T=%d, S=%d, duration=%.1fs, seed=%d\\n\", T, S, duration, seed);\n\n    // 1. Load BPE tokenizer from text encoder GGUF\n    BPETokenizer tok;\n    if (!load_bpe_from_gguf(&tok, g_text_enc_path.c_str())) {\n        fprintf(stderr, \"[acestep-cpp] FATAL: failed to load BPE tokenizer\\n\");\n        return 3;\n    }\n\n    // 2. Build formatted prompts (matches dit-vae.cpp text2music template)\n    std::string instruction = \"Fill the audio semantic mask based on the given conditions:\";\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/acestep-cpp/cpp/goacestepcpp.cpp#L136-L172","documentation":"acestep-cpp duration limit: latent frame count T = duration * 25 Hz, rounded up to a multiple of the DiT patch size, must not exceed 15000 (the silence_latent tensor length). Exceeding it returns 2 before tokenization. Since T is patch-aligned, the practical safe maximum duration is just under 15000/25 = 600 s, with a few frames of headroom lost to rounding.","triggerScenarios":"Calling generate_music(duration=600) or more (or a large duration after defaulting: duration<=0 becomes 30, but explicit big values pass through) where ceil-to-patch pushes T past 15000.","commonSituations":"Requesting 10+ minute tracks; UI sliders allowing beyond-limit values; duration taken from unvalidated user input; forgetting that patch rounding can push a borderline 599.9 s request over.","solutions":["Lower duration to at most 590 s (safe margin under the 600 s / 15000-frame ceiling).","For longer pieces, generate segments and concatenate in post-processing.","Clamp/validate duration at the API boundary before calling generate_music."],"exampleFix":"// before\ngenerate_music(..., duration=700.0f, ...);   // T=17500 -> exceeds max 15000\n\n// after\nfloat d = duration > 590.0f ? 590.0f : duration;  // or split into segments\ngenerate_music(..., duration=d, ...);","handlingStrategy":"validation","validationCode":"// clamp to the patch-aligned ceiling before calling generate_music\nconst int FRAMES_PER_SECOND = 25;\nint T = (int)(duration * FRAMES_PER_SECOND);\nT = ((T + patch_size - 1) / patch_size) * patch_size;  // mirror backend rounding\nif (T > 15000) duration = 590.0f;  // safe margin under 600s","typeGuard":"bool duration_supported(float duration, int patch_size) {\n    int T = (int)(duration * 25);\n    T = ((T + patch_size - 1) / patch_size) * patch_size;\n    return T > 0 && T <= 15000;\n}","tryCatchPattern":null,"preventionTips":["Cap the duration input at the API/UI layer (<=590 s) so the backend limit is never exercised.","Split long-form requests into <=590 s segments and concatenate outputs.","Account for patch-size round-up when computing the effective ceiling — do not use exactly 600.0 s."],"tags":["cpp","acestep","limits","validation","music-generation"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}