2121
2222const std::map<std::string, common_speculative_type> common_speculative_type_from_name_map = {
2323 {" none" , COMMON_SPECULATIVE_TYPE_NONE},
24- {" draft" , COMMON_SPECULATIVE_TYPE_DRAFT },
25- {" eagle3" , COMMON_SPECULATIVE_TYPE_EAGLE3 },
24+ {" draft-simple " , COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE },
25+ {" draft- eagle3" , COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3 },
2626 {" ngram-simple" , COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE},
2727 {" ngram-map-k" , COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K},
2828 {" ngram-map-k4v" , COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K4V},
@@ -145,15 +145,15 @@ struct common_speculative_impl {
145145 virtual void accept (llama_seq_id seq_id, uint16_t n_accepted) = 0;
146146};
147147
148- struct common_speculative_state_draft : public common_speculative_impl {
148+ struct common_speculative_impl_draft_simple : public common_speculative_impl {
149149 common_params_speculative_draft params;
150150
151151 llama_batch batch;
152152
153153 std::vector<common_sampler_ptr> smpls;
154154
155- common_speculative_state_draft (const common_params_speculative & params, uint32_t n_seq)
156- : common_speculative_impl(COMMON_SPECULATIVE_TYPE_DRAFT , n_seq)
155+ common_speculative_impl_draft_simple (const common_params_speculative & params, uint32_t n_seq)
156+ : common_speculative_impl(COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE , n_seq)
157157 , params(params.draft)
158158 {
159159 auto * ctx_dft = this ->params .ctx_dft ;
@@ -206,7 +206,7 @@ struct common_speculative_state_draft : public common_speculative_impl {
206206 }
207207 }
208208
209- ~common_speculative_state_draft () override {
209+ ~common_speculative_impl_draft_simple () override {
210210 llama_batch_free (batch);
211211 }
212212
@@ -340,11 +340,11 @@ struct common_speculative_state_draft : public common_speculative_impl {
340340 }
341341};
342342
343- struct common_speculative_state_eagle3 : public common_speculative_impl {
343+ struct common_speculative_impl_draft_eagle3 : public common_speculative_impl {
344344 // common_params_speculative_eagle3 params;
345345
346- common_speculative_state_eagle3 (const common_params_speculative & /* params*/ , uint32_t n_seq)
347- : common_speculative_impl(COMMON_SPECULATIVE_TYPE_EAGLE3 , n_seq) {}
346+ common_speculative_impl_draft_eagle3 (const common_params_speculative & /* params*/ , uint32_t n_seq)
347+ : common_speculative_impl(COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3 , n_seq) {}
348348
349349 void begin (llama_seq_id /* seq_id*/ , const llama_tokens & /* prompt*/ ) override {
350350 // noop
@@ -365,13 +365,13 @@ struct common_speculative_state_eagle3 : public common_speculative_impl {
365365};
366366
367367// state of self-speculation (simple implementation, not ngram-map)
368- struct common_speculative_state_ngram_simple : public common_speculative_impl {
368+ struct common_speculative_impl_ngram_simple : public common_speculative_impl {
369369 common_params_speculative_ngram_map params;
370370
371371 // shared across all sequences
372372 common_ngram_simple_config config;
373373
374- common_speculative_state_ngram_simple (
374+ common_speculative_impl_ngram_simple (
375375 const common_params_speculative & params, uint32_t n_seq,
376376 common_ngram_simple_config config)
377377 : common_speculative_impl(COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE, n_seq)
@@ -405,13 +405,13 @@ struct common_speculative_state_ngram_simple : public common_speculative_impl {
405405 }
406406};
407407
408- struct common_speculative_state_ngram_map_k : public common_speculative_impl {
408+ struct common_speculative_impl_ngram_map_k : public common_speculative_impl {
409409 common_params_speculative_ngram_map params;
410410
411411 // n_seq configs
412412 std::vector<common_ngram_map> config;
413413
414- common_speculative_state_ngram_map_k (
414+ common_speculative_impl_ngram_map_k (
415415 const common_params_speculative & params,
416416 const common_ngram_map & config,
417417 uint32_t n_seq)
@@ -453,7 +453,7 @@ struct common_speculative_state_ngram_map_k : public common_speculative_impl {
453453 }
454454};
455455
456- struct common_speculative_state_ngram_mod : public common_speculative_impl {
456+ struct common_speculative_impl_ngram_mod : public common_speculative_impl {
457457 common_params_speculative_ngram_mod params;
458458
459459 // shared across all sequences
@@ -475,7 +475,7 @@ struct common_speculative_state_ngram_mod : public common_speculative_impl {
475475
476476 std::vector<seq_info> sinfos;
477477
478- common_speculative_state_ngram_mod (
478+ common_speculative_impl_ngram_mod (
479479 const common_params_speculative & params,
480480 uint32_t n_seq)
481481 : common_speculative_impl(COMMON_SPECULATIVE_TYPE_NGRAM_MOD, n_seq)
@@ -621,7 +621,7 @@ struct common_speculative_state_ngram_mod : public common_speculative_impl {
621621 }
622622};
623623
624- struct common_speculative_state_ngram_cache : public common_speculative_impl {
624+ struct common_speculative_impl_ngram_cache : public common_speculative_impl {
625625 common_params_speculative_ngram_cache params;
626626
627627 uint16_t n_draft;
@@ -639,7 +639,7 @@ struct common_speculative_state_ngram_cache : public common_speculative_impl {
639639
640640 std::vector<seq_info> sinfos;
641641
642- common_speculative_state_ngram_cache (
642+ common_speculative_impl_ngram_cache (
643643 const common_params_speculative & params,
644644 uint32_t n_seq,
645645 uint16_t n_draft,
@@ -775,7 +775,7 @@ static common_ngram_map get_common_ngram_map(
775775 return common_ngram_map (size_key, size_value, key_only, min_hits);
776776}
777777
778- static common_speculative_state_ngram_cache create_state_ngram_cache (
778+ static common_speculative_impl_ngram_cache create_state_ngram_cache (
779779 const common_speculative_config & config,
780780 uint32_t n_seq,
781781 const std::string & path_static,
@@ -786,7 +786,7 @@ static common_speculative_state_ngram_cache create_state_ngram_cache(
786786 bool save_static = false ;
787787 bool save_dynamic = false ;
788788
789- common_speculative_state_ngram_cache state (config.params , n_seq, n_draft, path_static, path_dynamic, save_static, save_dynamic);
789+ common_speculative_impl_ngram_cache state (config.params , n_seq, n_draft, path_static, path_dynamic, save_static, save_dynamic);
790790
791791 return state;
792792}
@@ -818,8 +818,8 @@ const char * common_speculative_all_types_str() {
818818std::string common_speculative_type_to_str (common_speculative_type type) {
819819 switch (type) {
820820 case COMMON_SPECULATIVE_TYPE_NONE: return " none" ;
821- case COMMON_SPECULATIVE_TYPE_DRAFT : return " draft" ;
822- case COMMON_SPECULATIVE_TYPE_EAGLE3 : return " eagle3" ;
821+ case COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE : return " draft-simple " ;
822+ case COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3 : return " draft- eagle3" ;
823823 case COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE: return " ngram-simple" ;
824824 case COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K: return " ngram-map-k" ;
825825 case COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K4V: return " ngram-map-k4v" ;
@@ -872,9 +872,9 @@ common_speculative * common_speculative_init(common_params_speculative & params,
872872 {
873873 uint32_t enabled_configs = common_get_enabled_speculative_configs (params.types );
874874
875- bool has_draft = (enabled_configs & (1u << COMMON_SPECULATIVE_TYPE_DRAFT));
876- bool has_draft_model = !params.draft .mparams .path .empty ();
875+ bool has_draft_model_path = !params.draft .mparams .path .empty ();
877876
877+ bool has_draft_simple = (enabled_configs & (1u << COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE));
878878 // bool has_mtp = false; // TODO: add MTP here
879879 bool has_draft_eagle3 = false ; // TODO PR-18039: if params.speculative.eagle3
880880
@@ -906,22 +906,22 @@ common_speculative * common_speculative_init(common_params_speculative & params,
906906 if (has_ngram_cache) {
907907 configs.push_back (common_speculative_config (COMMON_SPECULATIVE_TYPE_NGRAM_CACHE, params));
908908 }
909- if (has_draft ) {
910- if (!has_draft_model ) {
909+ if (has_draft_simple ) {
910+ if (!has_draft_model_path ) {
911911 LOG_WRN (" %s: draft model is not specified - cannot use 'draft' type\n " , __func__);
912- has_draft = false ;
912+ has_draft_simple = false ;
913913 }
914- } else if (has_draft_model ) {
914+ } else if (has_draft_model_path ) {
915915 LOG_WRN (" %s: draft model is specified but 'draft' speculative type is not explicitly enabled - enabling it\n " , __func__);
916- has_draft = true ;
916+ has_draft_simple = true ;
917917 }
918918
919- if (has_draft ) {
920- configs.push_back (common_speculative_config (COMMON_SPECULATIVE_TYPE_DRAFT , params));
919+ if (has_draft_simple ) {
920+ configs.push_back (common_speculative_config (COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE , params));
921921 }
922922 // TODO: add MTP here
923923 if (has_draft_eagle3) {
924- configs.push_back (common_speculative_config (COMMON_SPECULATIVE_TYPE_EAGLE3 , params));
924+ configs.push_back (common_speculative_config (COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3 , params));
925925 }
926926 }
927927
@@ -932,12 +932,12 @@ common_speculative * common_speculative_init(common_params_speculative & params,
932932 switch (config.type ) {
933933 case COMMON_SPECULATIVE_TYPE_NONE:
934934 break ;
935- case COMMON_SPECULATIVE_TYPE_DRAFT : {
936- impls.push_back (std::make_unique<common_speculative_state_draft >(config.params , n_seq));
935+ case COMMON_SPECULATIVE_TYPE_DRAFT_SIMPLE : {
936+ impls.push_back (std::make_unique<common_speculative_impl_draft_simple >(config.params , n_seq));
937937 break ;
938938 }
939- case COMMON_SPECULATIVE_TYPE_EAGLE3 : {
940- impls.push_back (std::make_unique<common_speculative_state_eagle3 >(config.params , n_seq));
939+ case COMMON_SPECULATIVE_TYPE_DRAFT_EAGLE3 : {
940+ impls.push_back (std::make_unique<common_speculative_impl_draft_eagle3 >(config.params , n_seq));
941941 break ;
942942 }
943943 case COMMON_SPECULATIVE_TYPE_NGRAM_SIMPLE: {
@@ -950,7 +950,7 @@ common_speculative * common_speculative_init(common_params_speculative & params,
950950 /* .size_ngram = */ ngram_size_key,
951951 /* .size_mgram = */ mgram_size_value
952952 };
953- auto state = std::make_unique<common_speculative_state_ngram_simple >(
953+ auto state = std::make_unique<common_speculative_impl_ngram_simple >(
954954 /* .params = */ config.params ,
955955 /* .n_seq = */ n_seq,
956956 /* .state = */ config_simple
@@ -961,21 +961,21 @@ common_speculative * common_speculative_init(common_params_speculative & params,
961961 case COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K:
962962 case COMMON_SPECULATIVE_TYPE_NGRAM_MAP_K4V: {
963963 impls.push_back (
964- std::make_unique<common_speculative_state_ngram_map_k >(
964+ std::make_unique<common_speculative_impl_ngram_map_k >(
965965 config.params , get_common_ngram_map (config.type , config.params .ngram_map_k ), n_seq));
966966 break ;
967967 }
968968 case COMMON_SPECULATIVE_TYPE_NGRAM_MOD: {
969969 impls.push_back (
970- std::make_unique<common_speculative_state_ngram_mod >(config.params , n_seq));
970+ std::make_unique<common_speculative_impl_ngram_mod >(config.params , n_seq));
971971 break ;
972972 }
973973 case COMMON_SPECULATIVE_TYPE_NGRAM_CACHE: {
974974 auto state = create_state_ngram_cache (
975975 config, n_seq,
976976 params.ngram_cache .lookup_cache_static ,
977977 params.ngram_cache .lookup_cache_dynamic );
978- impls.push_back (std::make_unique<common_speculative_state_ngram_cache >(state));
978+ impls.push_back (std::make_unique<common_speculative_impl_ngram_cache >(state));
979979 break ;
980980 }
981981 default :
0 commit comments