Skip to content

Commit f00a538

Browse files
fix: add a switch for ensemble_time_upper_bound and fix some bug in main (#1226)
* change runner prompts * v1 * ensemble_time_upper_bound * lint * fix inf bug in function prob_dis_torch() and ensemble prompts * lint * lint --------- Co-authored-by: amstrongzyf <[email protected]>
1 parent c4b8baa commit f00a538

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

rdagent/app/data_science/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ class DataScienceBasePropSetting(KaggleBasePropSetting):
176176
#### Task Generate related
177177
fix_seed_and_data_split: bool = False
178178

179+
ensemble_time_upper_bound: bool = False
180+
179181

180182
DS_RD_SETTING = DataScienceBasePropSetting()
181183

rdagent/scenarios/data_science/proposal/exp_gen/prompts_v2.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -539,28 +539,31 @@ hypothesis_select:
539539
- **Time Limit Guidance**
540540
{% if time_max < 0 %}
541541
- Initial Case: runtime info unavailable, keep most hypotheses if component is Ensemble.
542-
- Remove only those clearly excessive (e.g., > {{ full_time }} hours) or overly complex.
543542
{% elif time_max >= full_time * 0.5 %}
544543
- High Runtime Case: current max runtime ({{ time_max }} hours) leaves little room for extra runs.
545544
- Avoid high-fold or heavy ensembles.
546545
- Maximum recommended folds: {{ (full_time // time_max) | int }}
547-
- Remove hypotheses clearly excessive (> {{ full_time }} hours)
548546
{% else %}
549547
- Low Runtime Case: current max runtime ({{ time_max }} hours) is far from the time limit.
550548
- Prefer hypotheses with runtimes ≤ {{ full_time }} hours.
551549
- Hypotheses slightly above {{ time_max }} hours can be retained only with strong justification.
552550
{% endif %}
553551
554552
### Ensemble Model Core Principle in Low Runtime Case
555-
Your goal is not just to tune individual models, but to build an **effective ensemble**. Make design decisions that lead to **strong overall ensemble performance**, not just strong base models.
556-
Please note: you are operating under a time budget dedicated to ensemble training of {{res_time}} seconds, and the maximum allowed time is {{full_time}} seconds.
557-
558-
Please take the remaining {{res_time}} seconds to carefully consider and design the most reasonable and optimal ensemble models based on your current progress.
553+
Your goal is not just to tune individual models, but to build an **effective ensemble**. Make design decisions that lead to **strong overall ensemble performance**, not just strong base models.
554+
These are examples:
555+
556+
Example 1:
559557
Assume training a single model takes about 1 hour. For example, if you have roughly twice that time left, you can try training multiple models with different random seeds or data splits to reuse time effectively.
560558
If you have more time, you might consider training a multi-fold ensemble. Use your judgment to decide how many folds or seeds fit within your remaining time budget.
559+
560+
Example 2:
561+
Assume training a single fold of a model takes at most {{ time_max }} hours. Within your remaining time budget, prioritize training multiple folds of the same model rather than trying many different models.
562+
For instance, if you have roughly 2 × {{ time_max }} hours left, you could train 2 folds of the same model with different data splits or random seeds.
563+
If more time is available, you might consider increasing the number of folds further. Use your judgment to decide how many folds fit within the remaining time budget while respecting the time_max constraint for a single fold.
561564
562565
### 2. Training-Time Resource Allocation
563-
- You may use **multiple folds** if justified, but you must **ensure the full pipeline completes within runtime limits**.
566+
- You may use **multiple folds** if justified, but you must **ensure the full pipeline completes within remaining time budget**.
564567
- Avoid reducing base model quality just to save time. For example:
565568
- Freezing large parts of the model (e.g., embeddings)
566569
- Using only embedding-level regression instead of full modeling

rdagent/scenarios/data_science/proposal/exp_gen/proposal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ def _prob_dis_torch(
963963
alpha, beta = 1.0, 0
964964
gamma = math.log(2) / 30
965965
logits = alpha * sim_matrix * math.exp(-gamma * path_length) + beta * torch.tanh(score_diff_matrix)
966+
logits = torch.clamp(logits, min=-2, max=2)
966967
probs = torch.softmax(logits, dim=1)
967968

968969
num_candidates = probs.size(-1)

rdagent/scenarios/data_science/scen/__init__.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,13 @@ def recommend_debug_timeout(self):
156156
return DS_RD_SETTING.debug_recommend_timeout
157157

158158
def real_full_timeout(self):
159-
remain_time = RD_Agent_TIMER_wrapper.timer.remain_time()
160-
all_duration = RD_Agent_TIMER_wrapper.timer.all_duration
161-
remain_percent = remain_time / all_duration
159+
if DS_RD_SETTING.ensemble_time_upper_bound:
160+
remain_time = RD_Agent_TIMER_wrapper.timer.remain_time()
161+
all_duration = RD_Agent_TIMER_wrapper.timer.all_duration
162+
remain_percent = remain_time / all_duration
163+
if remain_percent * 100 < 100 - DS_RD_SETTING.ratio_merge_or_ensemble:
164+
return DS_RD_SETTING.full_timeout * DS_RD_SETTING.runner_longer_timeout_multiplier_upper
162165

163-
if remain_percent * 100 < 100 - DS_RD_SETTING.ratio_merge_or_ensemble:
164-
return DS_RD_SETTING.full_timeout * DS_RD_SETTING.runner_longer_timeout_multiplier_upper
165-
166-
# Every 'patience' failures, move to next timeout level
167-
# Each level adds 'runner_timeout_increase_stage' multiplier to timeout
168-
# Capped by upper limit to prevent infinite growth
169166
return (
170167
DS_RD_SETTING.full_timeout
171168
* min(

0 commit comments

Comments
 (0)