MCPcopy Create free account
hub / github.com/alibaba/MNN / load

Method load

transformers/llm/engine/src/speculative_decoding/mtp.cpp:18–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void 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
40std::vector<VARP> MtpGeneration::mtpForward(const std::vector<int>& input_ids, VARP hidden_states) {
41 CHECK_LLM_RUNNING_RET(mContext, std::vector<VARP>());

Callers

nothing calls this directly

Calls 9

setHintPtrMethod · 0.80
mtp_modelMethod · 0.80
getOutputIndexMethod · 0.80
loadFunction · 0.50
cloneFunction · 0.50
resetMethod · 0.45
getMethod · 0.45
resizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected