#pragma once #include "engine/models/ace_step/assets.h" #include "engine/models/ace_step/tokenizer_text.h" #include "engine/models/ace_step/types.h" #include "engine/framework/core/execution_context.h" #include #include #include #include #include #include #include namespace engine::models::ace_step { class Qwen3PlannerWeightsRuntime; class Qwen3PlannerPrefillGraph; class Qwen3PlannerDecodeGraph; class Qwen3PlannerCfgPrefillGraph; class Qwen3PlannerCfgDecodeGraph; struct AceStepPlannerPreparedInput { std::string formatted_prompt; AceStepTokenizedText tokenized_prompt; }; struct Phase1ConstraintTables { std::optional newline_token; std::optional backtick_token; std::vector forbidden_tokens; std::map, std::vector> bpm_prefix_map; std::map, std::vector> duration_prefix_map; std::map, std::vector> keyscale_prefix_map; std::map, std::vector> language_prefix_map; std::map, std::vector> timesig_prefix_map; }; class AceStepQwen3PlannerRuntime { public: struct GenerationConfig { int64_t max_prompt_tokens = 4096; int64_t max_cot_tokens = 512; int64_t max_code_tokens = 4032; bool prefix_bucketing = true; bool fused_projections = false; bool f16_decode = false; bool independent_cfg_prefill = false; }; AceStepQwen3PlannerRuntime( std::shared_ptr assets, core::ExecutionContext & execution); AceStepQwen3PlannerRuntime( std::shared_ptr assets, core::ExecutionContext & execution, assets::TensorStorageType weight_storage_type, size_t decode_graph_arena_bytes, size_t weight_context_bytes, GenerationConfig generation); ~AceStepQwen3PlannerRuntime(); AceStepPlannerPreparedInput prepare_prompt(const AceStepRequest & request) const; AceStepPlan generate(const AceStepRequest & request, bool generate_audio_codes = true) const; void release_graph_workspace() const; std::string decode_tokens(const std::vector & token_ids) const; AceStepPlan parse_output(const std::string & output_text) const; private: std::shared_ptr assets_; AceStepTextTokenizer tokenizer_; GenerationConfig generation_; std::shared_ptr weights_runtime_; std::unique_ptr host_planner_prefill_execution_; std::shared_ptr planner_prefill_weights_runtime_; size_t decode_graph_arena_bytes_ = 0; mutable std::unique_ptr prefill_graph_; mutable std::unique_ptr decode_graph_; mutable std::array, 2> code_prefill_graphs_; mutable std::unique_ptr unconditional_prefill_graph_; mutable std::unique_ptr code_decode_graph_; mutable std::unique_ptr cfg_prefill_graph_; mutable std::array, 2> code_f16_decode_graphs_; mutable std::unique_ptr cot_decode_graph_; std::vector is_audio_code_token_; std::vector phase2_candidate_token_ids_; Phase1ConstraintTables phase1_constraints_; }; } // namespace engine::models::ace_step