| 241 | } // namespace |
| 242 | |
| 243 | int main(int argc, char ** argv) { |
| 244 | try { |
| 245 | const std::filesystem::path model_path = arg_value(argc, argv, "--model", "models/Ace-Step1.5"); |
| 246 | const std::string backend_name = arg_value(argc, argv, "--backend", "cuda"); |
| 247 | const int device = int_arg(argc, argv, "--device", 0); |
| 248 | const int threads = int_arg(argc, argv, "--threads", 1); |
| 249 | const int warmup = int_arg(argc, argv, "--warmup", 0); |
| 250 | const int iterations = int_arg(argc, argv, "--iterations", 1); |
| 251 | const std::string request_sequence_json = arg_value(argc, argv, "--request-sequence-json", ""); |
| 252 | const std::string noise_file = arg_value(argc, argv, "--noise-file", ""); |
| 253 | const std::filesystem::path output_dir = arg_value(argc, argv, "--output-dir", ""); |
| 254 | const std::filesystem::path timing_path = |
| 255 | arg_value(argc, argv, "--timing-file", "/tmp/ace_step_warm_bench_timing.log"); |
| 256 | if (request_sequence_json.empty()) { |
| 257 | throw std::runtime_error("ACE-Step warmbench requires --request-sequence-json"); |
| 258 | } |
| 259 | const auto session_option_overrides = parse_session_options(argc, argv); |
| 260 | |
| 261 | set_env_required("ENGINE_TRACE_ENABLED", "0"); |
| 262 | set_env_required("ENGINE_TIMING_ENABLED", "1"); |
| 263 | set_env_required("ENGINE_TIMING_FILE", timing_path.string()); |
| 264 | for (const auto & [key, value] : session_option_overrides) { |
| 265 | if (key == "ace_step.dit_tensor_dump_dir") { |
| 266 | set_env_required("ENGINE_ACE_STEP_DIT_TENSOR_DUMP_DIR", value); |
| 267 | } else if (key == "ace_step.dit_tensor_compare_dir") { |
| 268 | set_env_required("ENGINE_ACE_STEP_DIT_TENSOR_COMPARE_DIR", value); |
| 269 | } else if (key == "ace_step.dit_tensor_compare_result") { |
| 270 | set_env_required("ENGINE_ACE_STEP_DIT_TENSOR_COMPARE_RESULT", value); |
| 271 | } else if (key == "ace_step.dit_tensor_compare_threshold") { |
| 272 | set_env_required("ENGINE_ACE_STEP_DIT_TENSOR_COMPARE_THRESHOLD", value); |
| 273 | } else if (key == "ace_step.trace_enabled") { |
| 274 | set_env_required("ENGINE_TRACE_ENABLED", value); |
| 275 | } else if (key == "ace_step.trace_file") { |
| 276 | set_env_required("ENGINE_TRACE_FILE", value); |
| 277 | } |
| 278 | } |
| 279 | engine::runtime::TaskSpec task{engine::runtime::VoiceTaskKind::Tts, engine::runtime::RunMode::Offline}; |
| 280 | auto registry = engine::runtime::make_default_registry(); |
| 281 | engine::runtime::ModelLoadRequest load_request; |
| 282 | load_request.model_path = model_path; |
| 283 | load_request.family_hint = "ace_step"; |
| 284 | for (const auto & [key, value] : session_option_overrides) { |
| 285 | load_request.options.insert_or_assign(key, value); |
| 286 | } |
| 287 | auto model = registry.load(load_request); |
| 288 | |
| 289 | engine::runtime::SessionOptions options; |
| 290 | options.backend.type = parse_backend(backend_name); |
| 291 | options.backend.device = device; |
| 292 | options.backend.threads = threads; |
| 293 | for (const auto & [key, value] : session_option_overrides) { |
| 294 | options.options.insert_or_assign(key, value); |
| 295 | } |
| 296 | auto session_base = model->create_task_session(task, options); |
| 297 | auto * session = dynamic_cast<engine::runtime::IOfflineVoiceTaskSession *>(session_base.get()); |
| 298 | if (session == nullptr) { |
| 299 | throw std::runtime_error("loaded ACE-Step session is not an offline TTS session"); |
| 300 | } |
nothing calls this directly
no test coverage detected