Skip to content

Commit 384bfbd

Browse files
chuanhaoyukongweiqian
authored andcommitted
feat: add regione gamma related dit cache changes.
1 parent a676e4c commit 384bfbd

9 files changed

Lines changed: 433 additions & 43 deletions

File tree

xllm/core/common/global_flags.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ DECLARE_int64(dit_cache_end_blocks);
362362

363363
DECLARE_string(dit_regione_refresh_steps);
364364
DECLARE_double(dit_regione_region_threshold);
365+
DECLARE_double(dit_regione_cache_threshold);
366+
DECLARE_bool(dit_regione_use_avd_gamma);
367+
DECLARE_bool(dit_regione_erosion_dilation);
368+
DECLARE_bool(dit_regione_profile);
365369

366370
DECLARE_bool(dit_sp_communication_overlap);
367371

xllm/core/framework/config/dit_config.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ DEFINE_double(dit_regione_region_threshold,
6161
0.80,
6262
"RegionE: cosine threshold for adaptive region partition.");
6363

64+
DEFINE_double(dit_regione_cache_threshold,
65+
0.03,
66+
"RegionE: AVDCache error threshold δ (paper Eq.8). "
67+
"Reuse velocity while 1-accumulate <= threshold. "
68+
"Qwen-Image-Edit default in RegionE inplace.py is 0.03.");
69+
70+
DEFINE_bool(dit_regione_use_avd_gamma,
71+
true,
72+
"RegionE: use AVDCache with gamma (paper/inplace.py method). "
73+
"Uses the original diffusers 28-step gamma curve, linearly "
74+
"upsampled/downsampled to the actual inference step count. "
75+
"Set false to use fixed skip_interval instead.");
76+
77+
DEFINE_bool(dit_regione_erosion_dilation,
78+
true,
79+
"RegionE: enable erosion/dilation for region mask cleanup.");
80+
81+
DEFINE_bool(dit_regione_profile,
82+
false,
83+
"RegionE: print per-step timing breakdown for partial/full DiT and "
84+
"K/V CPU offload.");
85+
6486
DEFINE_bool(dit_sp_communication_overlap,
6587
true,
6688
"Communication & Computation overlap for sequence parallel");
@@ -141,6 +163,10 @@ void DiTConfig::from_flags() {
141163
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_cache_end_blocks);
142164
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_refresh_steps);
143165
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_region_threshold);
166+
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_cache_threshold);
167+
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_use_avd_gamma);
168+
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_erosion_dilation);
169+
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_regione_profile);
144170
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_sp_communication_overlap);
145171
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_debug_print);
146172
XLLM_CONFIG_ASSIGN_FROM_FLAG(dit_laser_attention_enabled);
@@ -169,6 +195,10 @@ void DiTConfig::from_json(const JsonReader& json) {
169195
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_cache_end_blocks);
170196
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_refresh_steps);
171197
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_region_threshold);
198+
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_cache_threshold);
199+
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_use_avd_gamma);
200+
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_erosion_dilation);
201+
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_regione_profile);
172202
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_sp_communication_overlap);
173203
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_debug_print);
174204
XLLM_CONFIG_ASSIGN_FROM_JSON(dit_laser_attention_enabled);
@@ -210,6 +240,14 @@ void DiTConfig::append_config_json(nlohmann::ordered_json& config_json) const {
210240
config_json, default_config, dit_regione_refresh_steps);
211241
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
212242
config_json, default_config, dit_regione_region_threshold);
243+
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
244+
config_json, default_config, dit_regione_cache_threshold);
245+
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
246+
config_json, default_config, dit_regione_use_avd_gamma);
247+
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
248+
config_json, default_config, dit_regione_erosion_dilation);
249+
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
250+
config_json, default_config, dit_regione_profile);
213251
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(
214252
config_json, default_config, dit_sp_communication_overlap);
215253
APPEND_CONFIG_JSON_VALUE_IF_NOT_DEFAULT(

xllm/core/framework/config/dit_config.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class DiTConfig final {
5353
"dit_cache_end_blocks",
5454
"dit_regione_refresh_steps",
5555
"dit_regione_region_threshold",
56+
"dit_regione_cache_threshold",
57+
"dit_regione_use_avd_gamma",
58+
"dit_regione_erosion_dilation",
59+
"dit_regione_profile",
5660
"dit_sp_communication_overlap",
5761
"dit_debug_print",
5862
"dit_laser_attention_enabled",
@@ -93,6 +97,14 @@ class DiTConfig final {
9397

9498
PROPERTY(double, dit_regione_region_threshold) = 0.80;
9599

100+
PROPERTY(double, dit_regione_cache_threshold) = 0.03;
101+
102+
PROPERTY(bool, dit_regione_use_avd_gamma) = true;
103+
104+
PROPERTY(bool, dit_regione_erosion_dilation) = true;
105+
106+
PROPERTY(bool, dit_regione_profile) = false;
107+
96108
PROPERTY(bool, dit_sp_communication_overlap) = true;
97109

98110
PROPERTY(bool, dit_debug_print) = false;

xllm/core/framework/dit_cache/dit_cache_config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,20 @@ struct FBCacheTaylorSeerOptions : public DiTBaseCacheOptions {
5757
};
5858

5959
struct RegionEOptions : public DiTBaseCacheOptions {
60+
// Fallback fixed-interval AVD when gamma is disabled or step count
61+
// mismatches.
6062
int64_t skip_interval_steps = 3;
6163
int64_t tail_steps = 1;
6264
std::vector<int64_t> refresh_steps = {16};
6365
float region_threshold = 0.80f;
66+
// AVDCache δ in paper Eq.8/9 / inplace.py cache_threshold (Qwen default
67+
// 0.03).
68+
float cache_threshold = 0.03f;
69+
// Use fitted γ_t AVDCache (paper) instead of fixed skip_interval.
70+
bool use_avd_gamma = true;
71+
// Enable erosion/dilation morphological cleanup after ARP mask selection.
72+
bool erosion_dilation = true;
73+
bool profile = false;
6474
};
6575

6676
struct ResidualCacheOptions {

0 commit comments

Comments
 (0)