Skip to content

Commit 4c9794b

Browse files
committed
fix
1 parent 129f098 commit 4c9794b

File tree

2 files changed

+18
-43
lines changed

2 files changed

+18
-43
lines changed

optillm/mars/agent.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def _assign_temperature(self) -> float:
3434
def _get_reasoning_effort(self) -> str:
3535
"""Get reasoning effort level based on agent temperature"""
3636
if self.temperature <= 0.4:
37-
return "low" # 8k reasoning tokens
37+
return "low" # ~20% of max_tokens for reasoning
3838
elif self.temperature <= 0.8:
39-
return "medium" # 16k reasoning tokens
39+
return "medium" # ~50% of max_tokens for reasoning
4040
else:
41-
return "high" # 24k reasoning tokens
41+
return "high" # ~80% of max_tokens for reasoning
4242

4343
def generate_solution(self, problem: str, request_id: str = None) -> Tuple[AgentSolution, int]:
4444
"""Generate a solution for the given problem using reasoning API"""
@@ -51,20 +51,11 @@ def generate_solution(self, problem: str, request_id: str = None) -> Tuple[Agent
5151
problem=problem
5252
)
5353

54-
# Configure reasoning parameters based on fixed budgets
54+
# Configure reasoning parameters - simplified with effort only
5555
reasoning_effort = self._get_reasoning_effort()
56-
max_tokens = self.config['max_tokens'] # Fixed 32k
57-
58-
# Use fixed reasoning tokens based on effort level
59-
if reasoning_effort == "low":
60-
reasoning_tokens = self.config['low_effort_tokens'] # 8k
61-
elif reasoning_effort == "medium":
62-
reasoning_tokens = self.config['medium_effort_tokens'] # 16k
63-
else: # high
64-
reasoning_tokens = self.config['high_effort_tokens'] # 24k
56+
max_tokens = self.config['max_tokens'] # Fixed 30k
6557

6658
reasoning_config = {
67-
"max_tokens": reasoning_tokens,
6859
"effort": reasoning_effort
6960
}
7061

@@ -134,9 +125,8 @@ def verify_solution(self, problem: str, solution: str, verifier_id: int, solutio
134125
solution=solution
135126
)
136127

137-
# Use fixed verification token budgets
138-
max_tokens = self.config['max_tokens'] # Fixed 32k
139-
verification_reasoning_tokens = self.config['verification_tokens'] # Fixed 8k
128+
# Use simplified verification with effort parameter
129+
max_tokens = self.config['max_tokens'] # Fixed 30k
140130

141131
try:
142132
response = self.client.chat.completions.create(
@@ -150,8 +140,7 @@ def verify_solution(self, problem: str, solution: str, verifier_id: int, solutio
150140
timeout=180,
151141
extra_body={
152142
"reasoning": {
153-
"max_tokens": verification_reasoning_tokens,
154-
"effort": "low"
143+
"effort": "low" # Low effort for verification consistency
155144
}
156145
}
157146
)
@@ -196,9 +185,8 @@ def improve_solution(self, problem: str, current_solution: str, feedback: str, i
196185
issues="\n".join(f"- {issue}" for issue in issues)
197186
)
198187

199-
# Use fixed improvement token budgets (use high effort for iterations)
200-
max_tokens = self.config['max_tokens'] # Fixed 32k
201-
improvement_reasoning_tokens = self.config['high_effort_tokens'] # Fixed 24k
188+
# Use simplified improvement with high effort
189+
max_tokens = self.config['max_tokens'] # Fixed 30k
202190

203191
try:
204192
response = self.client.chat.completions.create(
@@ -212,8 +200,7 @@ def improve_solution(self, problem: str, current_solution: str, feedback: str, i
212200
timeout=300,
213201
extra_body={
214202
"reasoning": {
215-
"max_tokens": improvement_reasoning_tokens,
216-
"effort": "high"
203+
"effort": "high" # High effort for improvements
217204
}
218205
}
219206
)

optillm/mars/mars.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,17 @@
1515

1616
logger = logging.getLogger(__name__)
1717

18-
# Default MARS configuration with fixed 32k token budget
18+
# Default MARS configuration - simplified with OpenRouter effort parameter
1919
DEFAULT_CONFIG = {
2020
'num_agents': 3,
2121
'max_iterations': 5, # Balanced for quality vs efficiency
2222
'verification_passes_required': 2, # Balanced for 5-iteration efficiency
2323
'consensus_threshold': 2, # Keep at 2 for 3-agent setup
2424
'min_verified_solutions': 1, # Keep minimal requirement
25-
'max_tokens': 32000, # Fixed 32k token budget for all calls
25+
'max_tokens': 30000, # Fixed 30k token budget for all calls
2626
'max_verification_attempts': 3,
2727
'early_termination': True,
28-
'use_reasoning_api': True,
29-
# Fixed reasoning token allocations
30-
'low_effort_tokens': 8000, # Agent 0 (temperature 0.3)
31-
'medium_effort_tokens': 16000, # Agent 1 (temperature 0.6)
32-
'high_effort_tokens': 24000, # Agent 2 (temperature 1.0)
33-
'verification_tokens': 8000, # Fixed low effort for verification consistency
34-
'synthesis_tokens': 24000 # Fixed high effort for final synthesis
28+
'use_reasoning_api': True
3529
}
3630

3731
def multi_agent_reasoning_system(
@@ -189,24 +183,19 @@ def _synthesize_final_solution(
189183
)
190184

191185
try:
192-
# Use fixed synthesis token budgets
193-
synthesis_max_tokens = config['max_tokens'] # Fixed 32k
194-
synthesis_reasoning_tokens = config['synthesis_tokens'] # Fixed 24k
195-
196-
# Use fixed reasoning effort for synthesis
186+
# Use simplified synthesis with effort parameter
197187
response = client.chat.completions.create(
198188
model=model,
199189
messages=[
200190
{"role": "system", "content": "You are a mathematical synthesis expert."},
201191
{"role": "user", "content": synthesis_prompt}
202192
],
203-
max_tokens=synthesis_max_tokens,
193+
max_tokens=config['max_tokens'],
204194
temperature=0.3, # Lower temperature for synthesis
205195
timeout=300,
206196
extra_body={
207197
"reasoning": {
208-
"max_tokens": synthesis_reasoning_tokens,
209-
"effort": "high"
198+
"effort": "high" # High effort for final synthesis
210199
}
211200
}
212201
)
@@ -219,11 +208,10 @@ def _synthesize_final_solution(
219208
{"role": "system", "content": "You are a mathematical synthesis expert."},
220209
{"role": "user", "content": synthesis_prompt}
221210
],
222-
"max_tokens": synthesis_max_tokens,
211+
"max_tokens": config['max_tokens'],
223212
"temperature": 0.3,
224213
"extra_body": {
225214
"reasoning": {
226-
"max_tokens": synthesis_reasoning_tokens,
227215
"effort": "high"
228216
}
229217
}

0 commit comments

Comments
 (0)