@@ -527,8 +527,7 @@ struct CacheDitState {
527527 std::string get_summary () const {
528528 char buf[256 ];
529529 snprintf (buf, sizeof (buf),
530- " CacheDIT[Fn=%d,Bn=%d,thresh=%.2f]: cached %zu/%d steps, %d/%d blocks" ,
531- get_double_Fn_blocks (), get_double_Bn_blocks (),
530+ " CacheDIT[thresh=%.2f]: cached %zu/%d steps, %d/%d blocks" ,
532531 config.dbcache .residual_diff_threshold ,
533532 cached_steps.size (), total_steps,
534533 total_blocks_cached, total_blocks_computed + total_blocks_cached);
@@ -636,6 +635,19 @@ inline int get_preset_warmup(const std::string& preset) {
636635 return 8 ;
637636}
638637
638+ inline int get_preset_Fn (const std::string& preset) {
639+ if (preset == " slow" || preset == " s" || preset == " S" ) return 8 ;
640+ if (preset == " medium" || preset == " m" || preset == " M" ) return 8 ;
641+ if (preset == " fast" || preset == " f" || preset == " F" ) return 6 ;
642+ if (preset == " ultra" || preset == " u" || preset == " U" ) return 4 ;
643+ return 8 ;
644+ }
645+
646+ inline int get_preset_Bn (const std::string& preset) {
647+ (void )preset;
648+ return 0 ;
649+ }
650+
639651inline void parse_dbcache_options (const std::string& opts, DBCacheConfig& cfg) {
640652 if (opts.empty ()) return ;
641653
@@ -858,7 +870,19 @@ struct CacheDitConditionState {
858870 float diff = CacheDitState::calculate_residual_diff (
859871 it->second .prev_input .data (), input_data, ne);
860872
861- if (diff < config.residual_diff_threshold ) {
873+ float effective_threshold = config.residual_diff_threshold ;
874+ if (config.Fn_compute_blocks > 0 ) {
875+ float fn_confidence = 1 .0f + 0 .02f * (config.Fn_compute_blocks - 8 );
876+ fn_confidence = std::max (0 .5f , std::min (2 .0f , fn_confidence));
877+ effective_threshold *= fn_confidence;
878+ }
879+ if (config.Bn_compute_blocks > 0 ) {
880+ float bn_quality = 1 .0f - 0 .03f * config.Bn_compute_blocks ;
881+ bn_quality = std::max (0 .5f , std::min (1 .0f , bn_quality));
882+ effective_threshold *= bn_quality;
883+ }
884+
885+ if (diff < effective_threshold) {
862886 skip_current_step = true ;
863887 total_steps_skipped++;
864888 cached_steps.push_back (current_step_index);
0 commit comments