Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.

Commit 6ce3dee

Browse files
committed
Clear max_seq_len
1 parent 1bc8e34 commit 6ce3dee

10 files changed

Lines changed: 34 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ mise.toml
5555
uv.lock
5656
**/wandb/
5757
.ruff_cache/
58+
*.pkl

arbor/core/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ class Config(BaseModel):
1010

1111
# Basic settings
1212
storage_path: str = str(Path.home() / ".arbor" / "storage")
13-
max_context_length: Optional[int] = None
1413

1514
# Training settings
1615
accelerate_config: Optional[str] = None

arbor/integrations/dspy/arbor_provider.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import time
32
from datetime import datetime
43
from typing import TYPE_CHECKING, Any
@@ -64,13 +63,13 @@ class ArborReinforceJob(ReinforceJob):
6463
"max_completion_length": None,
6564
"gradient_checkpointing_kwargs": None,
6665
"bf16": False,
66+
"fp16": True,
6767
"scale_rewards": True,
6868
"max_grad_norm": 1.0,
6969
"report_to": "none",
7070
"log_completions": True,
7171
"logging_steps": 10,
72-
# By default, none is the model's max context length
73-
"max_context_length": None,
72+
"max_seq_len": None,
7473
"lora_config": None,
7574
"loss_type": "dapo",
7675
"soft_completion_penalty_length": None,
@@ -135,6 +134,7 @@ def initialize(self):
135134
self.DEFAULT_TRAIN_KWARGS["mask_truncated_completions"],
136135
)
137136
bf16 = self.train_kwargs.get("bf16", self.DEFAULT_TRAIN_KWARGS["bf16"])
137+
fp16 = self.train_kwargs.get("fp16", self.DEFAULT_TRAIN_KWARGS["fp16"])
138138
scale_rewards = self.train_kwargs.get(
139139
"scale_rewards", self.DEFAULT_TRAIN_KWARGS["scale_rewards"]
140140
)
@@ -154,8 +154,8 @@ def initialize(self):
154154
logging_steps = self.train_kwargs.get(
155155
"logging_steps", self.DEFAULT_TRAIN_KWARGS["logging_steps"]
156156
)
157-
max_context_length = self.train_kwargs.get(
158-
"max_context_length", self.DEFAULT_TRAIN_KWARGS["max_context_length"]
157+
max_seq_len = self.train_kwargs.get(
158+
"max_seq_len", self.DEFAULT_TRAIN_KWARGS["max_seq_len"]
159159
)
160160
max_steps = self.train_kwargs.get("max_steps", 500)
161161
num_training_gpus = self.train_kwargs.get("num_training_gpus", 1)
@@ -186,14 +186,14 @@ def initialize(self):
186186
"soft_completion_penalty_length": soft_completion_penalty_length,
187187
"mask_truncated_completions": mask_truncated_completions,
188188
"bf16": bf16,
189+
"fp16": fp16,
189190
"scale_rewards": scale_rewards,
190191
"gradient_checkpointing_kwargs": gradient_checkpointing_kwargs,
191192
"max_grad_norm": max_grad_norm,
192193
"report_to": report_to,
193194
"log_completions": log_completions,
194195
"logging_steps": logging_steps,
195-
# "max_context_length": max_context_length,
196-
# "max_seq_len": max_context_length,
196+
"max_seq_len": max_seq_len,
197197
"max_steps": max_steps,
198198
"loss_type": loss_type,
199199
"num_training_gpus": num_training_gpus,
@@ -202,7 +202,7 @@ def initialize(self):
202202
},
203203
"inference_config": {
204204
"model": finetune_model,
205-
"max_context_length": max_context_length,
205+
"max_seq_len": max_seq_len,
206206
},
207207
"gpu_config": {
208208
"type": "multi",
@@ -214,12 +214,21 @@ def initialize(self):
214214
}
215215
url = urljoin(api_base, "fine_tuning/grpo/initialize")
216216
headers = {"Content-Type": "application/json"}
217-
response = requests.post(url=url, headers=headers, json=data)
218-
print(json.dumps(response.json(), indent=2))
219-
response.raise_for_status()
220-
response = response.json()
221-
self.lm.model = ArborProvider._add_provider_prefix(response["current_model"])
222-
self.provider_job_id = response.get("job_id")
217+
try:
218+
response = requests.post(url=url, headers=headers, json=data)
219+
response.raise_for_status()
220+
response = response.json()
221+
self.lm.model = ArborProvider._add_provider_prefix(
222+
response["current_model"]
223+
)
224+
self.provider_job_id = response.get("job_id")
225+
except KeyboardInterrupt:
226+
print(
227+
"Keyboard interrupt received. Stopping reinforcement learning job initialization."
228+
)
229+
except Exception as err:
230+
print(f"Error initializing reinforcement learning job: {err}")
231+
raise err
223232

224233
def _run_grpo_step_one_group(
225234
self,

arbor/server/api/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class InferenceLaunchOwner(StrictBaseModel):
179179

180180
class InferenceLaunchRequest(StrictBaseModel):
181181
model: str
182-
max_context_length: Optional[int] = None
182+
max_seq_len: Optional[int] = None
183183
num_gpus: Optional[int] = 1
184184
owner: Optional[InferenceLaunchOwner] = None
185185
log_file_path: Optional[str] = None

arbor/server/services/jobs/inference_job.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def launch(
106106
vllm_module = "arbor.server.services.inference.vllm_serve"
107107
command = f"{sys.executable} -m {vllm_module} --model {self.launched_model_name} --port {self.port} --gpu-memory-utilization 0.9 --tensor-parallel-size {n_gpus} --enable_prefix_caching --disable-log-stats"
108108

109-
if launch_config.max_context_length:
110-
command += f" --max_model_len {launch_config.max_context_length}"
109+
if launch_config.max_seq_len:
110+
command += f" --max_model_len {launch_config.max_seq_len}"
111111

112112
logger.info(f"Running command: {command}")
113113

arbor/server/services/jobs/inference_launch_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
@dataclass
66
class InferenceLaunchConfig:
7-
max_context_length: Optional[int] = None
7+
max_seq_len: Optional[int] = None
88
gpu_ids: Optional[list[int]] = None
99
num_gpus: Optional[int] = 1
1010
grpo_job_id: Optional[str] = None

arbor/server/services/managers/inference_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def launch_from_request(
8484
return existing_job
8585

8686
launch_config = InferenceLaunchConfig(
87-
max_context_length=launch_request.max_context_length,
87+
max_seq_len=launch_request.max_seq_len,
8888
gpu_ids=list(preallocated_gpu_ids) if preallocated_gpu_ids else None,
8989
num_gpus=launch_request.num_gpus,
9090
log_file_path=launch_request.log_file_path,

examples/checkpointing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def initialize_grpo(
6565
"trainer_config": trainer_config,
6666
"inference_config": {
6767
"model": model,
68-
"max_context_length": 2048,
68+
"max_seq_len": 2048,
6969
},
7070
"gpu_config": {
7171
"type": "multi",

examples/inference_swap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818

1919

2020
def launch_model(
21-
model_name: str, *, num_gpus: int = 1, max_context_length: int | None = None
21+
model_name: str, *, num_gpus: int = 1, max_seq_len: int | None = None
2222
) -> str:
2323
"""Launch the inference server for a model via Arbor's /launch endpoint."""
2424

2525
payload: dict[str, object] = {"model": model_name, "num_gpus": num_gpus}
26-
if max_context_length is not None:
27-
payload["max_context_length"] = max_context_length
26+
if max_seq_len is not None:
27+
payload["max_seq_len"] = max_seq_len
2828

2929
response = requests.post(f"{chat_base}/launch", json=payload)
3030
response.raise_for_status()

examples/unique_chars_grpo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _unique_letter_reward(input, pred, trace=None) -> float:
6969
"max_grad_norm": 1.0,
7070
"report_to": "wandb",
7171
"log_completions": True,
72-
"max_context_length": None,
72+
"max_seq_len": None, #defaults to 2048
7373
"max_steps": 1000,
7474
"logging_steps": 10,
7575
"loss_type": "dapo", #"dr_grpo",

0 commit comments

Comments
 (0)