| 16 | } |
| 17 | |
| 18 | void MtpGeneration::load(Module::Config module_config) { |
| 19 | mMtpMeta.reset(new KVMeta); |
| 20 | mLlm->mRuntimeManager->setHintPtr(Interpreter::KVCACHE_INFO, mMtpMeta.get()); |
| 21 | |
| 22 | mMtpModules.resize(1); |
| 23 | auto mtp_path = mLlm->mConfig->mtp_model(); |
| 24 | |
| 25 | std::vector<std::string> inputNames{"input_embed", "hidden_states", "attention_mask", \ |
| 26 | "position_ids", "logits_index"}; |
| 27 | std::vector<std::string> outputNames {"logits"}; |
| 28 | mMtpModules[0].reset(Module::load(inputNames, outputNames, mtp_path.c_str(), mLlm->mRuntimeManager, &module_config)); |
| 29 | |
| 30 | int verify_length = mLlm->mDraftLength + 1; |
| 31 | // speculative decode module |
| 32 | for(int i = 1; i <= verify_length; i++) { |
| 33 | mMtpModulePool[std::make_pair(i, true)].reset(Module::clone(mMtpModules[0].get())); |
| 34 | } |
| 35 | // prefill module |
| 36 | mMtpModulePool[std::make_pair(mLlm->mPrefillKey, false)] = mMtpModules[0]; |
| 37 | mHiddenStateIndex = mLlm->getOutputIndex("hidden_states"); |
| 38 | } |
| 39 | |
| 40 | std::vector<VARP> MtpGeneration::mtpForward(const std::vector<int>& input_ids, VARP hidden_states) { |
| 41 | CHECK_LLM_RUNNING_RET(mContext, std::vector<VARP>()); |
nothing calls this directly
no test coverage detected