Compare commits

...
Author SHA1 Message Date
fd1a68d559 Make matmul_precision configurable in trainer config (#2235)
Release / Push CUDA image to Docker (push) Canceled after 0s
The RL and SFT trainers hardcode torch.set_float32_matmul_precision("high"),
which is fine on NVIDIA hardware but is not always the right setting on
ROCm/AMD GPUs, where the reduced-precision matmul path can affect softmax
accuracy for models with large vocabularies.

This adds a matmul_precision field to TrainerConfig and SFTConfig. The
default stays at "high" so nothing changes for existing runs, but users
who need full FP32 (e.g. on ROCm) can now set matmul_precision = "highest"
in their trainer config without patching the source.

Co-authored-by: Daniel Zautner <daniel.zautner@silo.ai>
2026-04-10 15:55:58 +02:00
11880cea13 fix: handle chat template errors in eval sample logging (#2198)
Release / Push CUDA image to Docker (push) Canceled after 0s
* fix: handle chat template errors in eval sample logging

`apply_chat_template` can fail when completions contain tool calls
serialized as strings (e.g. from verifiers) that the model's Jinja
template expects as objects. Fall back to raw string representation
instead of crashing the orchestrator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: deserialize tool call args before falling back to str() in eval logging

When apply_chat_template fails, try deserializing tool call arguments
from JSON strings to dicts first (matching the SFT entrypoint pattern)
before falling back to str(completion).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: deserialize tool call args upfront instead of nested fallback

Always deserialize tool call args before applying the chat template,
matching the SFT entrypoint pattern. deserialize_tool_calls is
idempotent so this is safe to call unconditionally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: root <root@accomplished-lori-of-penetration.datacrunch.io>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 06:52:30 -07:00
9615fe7769 feat: separate eval client type from training (#2247)
Release / Push CUDA image to Docker (push) Canceled after 0s
* feat: separate eval client type (openai_chat_completions) from training

Eval rollouts now use openai_chat_completions instead of the TITO
(token-in-token-out) client used for training. Adds eval_clients and
get_eval_client() to both StaticInferencePool and ElasticInferencePool.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: rename client_type to train_client_type for clarity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: align pool constructors, rename clients -> train_clients, move TITO warning

Both StaticInferencePool and ElasticInferencePool now take the same
constructor signature: (client_config, model_name, train_client_type,
eval_client_type). Renamed clients property to train_clients for
symmetry with eval_clients.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* update warn log

* chore: fix TITO warning, remove get_next_client, add eval to alphabet sort config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: rename _clients to _train_clients for consistency

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: default train_client_type to openai_chat_completions_token

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: teacher pool gets explicit non-TITO client type, clear eval_clients on stop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: revert accidental rollouts.bin rename

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: guard get_eval_client on eval_clients instead of train_clients

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove unused has_clients property

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 06:45:32 -07:00
11 changed files with 200 additions and 136 deletions
+10
View File
@@ -21,6 +21,16 @@ id = "alphabet-sort"
name = "alphabet-sort"
args = { min_turns = 2, max_turns = 2 }
[orchestrator.eval]
interval = 50
[[orchestrator.eval.env]]
id = "alphabet-sort"
name = "alphabet-sort"
num_examples = 50
rollouts_per_example = 4
args = { min_turns = 2, max_turns = 2 }
[trainer]
[inference]
+13
View File
@@ -203,6 +203,19 @@ class SFTConfig(BaseConfig):
),
] = False
matmul_precision: Annotated[
Literal["highest", "high", "medium"],
Field(
description=(
"Precision for float32 matrix multiplications. "
"Use 'highest' for full FP32 (required on ROCm/AMD GPUs to avoid "
"catastrophic precision loss in softmax over large vocabularies). "
"Use 'high' to enable TF32 on NVIDIA GPUs for a speedup with minor "
"precision tradeoff. See torch.set_float32_matmul_precision docs."
),
),
] = "high"
max_steps: Annotated[
int | None,
Field(description="Maximum number of steps to run training for. If None, will run indefinitely."),
+13
View File
@@ -760,6 +760,19 @@ class TrainerConfig(BaseConfig):
),
] = Path("outputs")
matmul_precision: Annotated[
Literal["highest", "high", "medium"],
Field(
description=(
"Precision for float32 matrix multiplications. "
"Use 'highest' for full FP32 (required on ROCm/AMD GPUs to avoid "
"catastrophic precision loss in softmax over large vocabularies). "
"Use 'high' to enable TF32 on NVIDIA GPUs for a speedup with minor "
"precision tradeoff. See torch.set_float32_matmul_precision docs."
),
),
] = "high"
max_steps: Annotated[
int | None,
Field(
+11 -11
View File
@@ -110,14 +110,12 @@ async def orchestrate(config: OrchestratorConfig):
# Setup rollout inference pool (handles both static and elastic modes)
rollout_client_config, rollout_model_name, enable_policy_updates = setup_external_rollout_model(config, logger)
client_type = "openai_chat_completions_token" if config.use_token_client else "openai_chat_completions"
if config.use_token_client:
logger.warning(
"Token-in-token-out (TITO) client is enabled. Only use this if your environment has a linear "
"history and the chat template has the extension property."
)
train_client_type = "openai_chat_completions_token" if config.use_token_client else "openai_chat_completions"
inference_pool = await setup_inference_pool(
rollout_client_config, model_name=rollout_model_name, client_type=client_type
rollout_client_config,
model_name=rollout_model_name,
train_client_type=train_client_type,
eval_client_type="openai_chat_completions",
)
# Setup teacher inference pool if configured
@@ -127,7 +125,9 @@ async def orchestrate(config: OrchestratorConfig):
f"model={config.teacher_model.model.name})"
)
teacher_inference_pool = await setup_inference_pool(
config.teacher_model.client, model_name=config.teacher_model.model.name
config.teacher_model.client,
model_name=config.teacher_model.model.name,
train_client_type="openai_chat_completions",
)
else:
teacher_inference_pool = None
@@ -379,7 +379,7 @@ async def orchestrate(config: OrchestratorConfig):
*[
eval_env.evaluate(
model_name=scheduler.model_name,
get_client=inference_pool.get_next_client,
get_client=inference_pool.get_eval_client,
ckpt_step=ckpt_step,
step=progress.step,
)
@@ -497,7 +497,7 @@ async def orchestrate(config: OrchestratorConfig):
logger.info(f"Computing teacher logprobs for {len(train_examples)} training examples")
teacher_logprobs_start_time = time.perf_counter()
teacher_logprobs_list = await compute_teacher_logprobs(
clients=teacher_inference_pool.clients,
clients=teacher_inference_pool.train_clients,
model_name=config.teacher_model.model.name,
samples=train_examples,
)
@@ -704,7 +704,7 @@ async def orchestrate(config: OrchestratorConfig):
*[
eval_env.evaluate(
model_name=scheduler.model_name,
get_client=inference_pool.get_next_client,
get_client=inference_pool.get_eval_client,
ckpt_step=ckpt_step,
step=progress.step,
)
+2 -2
View File
@@ -156,10 +156,10 @@ class Scheduler:
Uses (api_base_url, dp_rank) as identity rather than client_idx so that
load tracking survives elastic pool refreshes (which reassign indices).
"""
clients = self.inference_pool.clients
clients = self.inference_pool.train_clients
while not clients:
await asyncio.sleep(1)
clients = self.inference_pool.clients
clients = self.inference_pool.train_clients
inflight = Counter(self._client_identity(info.client_config) for info in self.inflight_requests.values())
return min(clients, key=lambda c: inflight[self._client_identity(c)])
+4 -1
View File
@@ -109,7 +109,10 @@ def train(config: TrainerConfig):
setup_torch_distributed(
timeout=timedelta(seconds=config.dist_timeout_seconds), enable_gloo=config.model.fsdp_cpu_offload
)
torch.set_float32_matmul_precision("high")
# Configurable to support ROCm/AMD GPUs where reduced precision
# matmul corrupts softmax over large vocabularies. Override via config
# (e.g. matmul_precision = "highest") on ROCm.
torch.set_float32_matmul_precision(config.matmul_precision)
# Setup multi run manager and offsets (including LoRA validation/scaling hooks if applicable)
multi_run_manager = setup_multi_run_manager(
+4 -1
View File
@@ -84,7 +84,10 @@ def train(config: SFTConfig):
setup_torch_distributed(
timeout=timedelta(seconds=config.dist_timeout_seconds), enable_gloo=config.model.fsdp_cpu_offload
)
torch.set_float32_matmul_precision("high")
# Configurable to support ROCm/AMD GPUs where reduced precision
# matmul corrupts softmax over large vocabularies. Override via config
# (e.g. matmul_precision = "highest") on ROCm.
torch.set_float32_matmul_precision(config.matmul_precision)
if config.model.lora is not None:
setup_multi_run_manager(config.output_dir, 1, torch.device("cuda", world.local_rank), config.model.lora)
+37 -19
View File
@@ -21,7 +21,7 @@ class InferencePool(Protocol):
"""Protocol for inference pools (static or elastic)."""
@property
def clients(self) -> list[vf.ClientConfig]:
def train_clients(self) -> list[vf.ClientConfig]:
"""Get inference clients."""
...
@@ -34,8 +34,8 @@ class InferencePool(Protocol):
"""Update the model name."""
...
async def get_next_client(self) -> vf.ClientConfig:
"""Get next client in round-robin fashion."""
async def get_eval_client(self) -> vf.ClientConfig:
"""Get next eval client in round-robin fashion."""
...
async def wait_for_ready(self, model_name: str, timeout: int = 1800) -> None:
@@ -59,18 +59,22 @@ class StaticInferencePool:
"""Static inference pool with fixed client list."""
def __init__(
self, clients: list[vf.ClientConfig], admin_clients: list[AsyncClient], skip_model_check: bool = False
self,
client_config: ClientConfig,
model_name: str,
train_client_type: str = "openai_chat_completions_token",
eval_client_type: str = "openai_chat_completions",
):
self._clients = clients
self._admin_clients = admin_clients
self._skip_model_check = skip_model_check
self._idx_to_client = {client.client_idx: client for client in clients}
self._client_cycle = cycle(clients)
self.model_name = None # unused
self._train_clients = setup_clients(client_config, client_type=train_client_type)
self._eval_clients = setup_clients(client_config, client_type=eval_client_type)
self._admin_clients = setup_admin_clients(client_config)
self._skip_model_check = client_config.skip_model_check
self._eval_cycle = cycle(self._eval_clients)
self.model_name = model_name
@property
def clients(self) -> list[vf.ClientConfig]:
return self._clients
def train_clients(self) -> list[vf.ClientConfig]:
return self._train_clients
@property
def admin_clients(self) -> list[AsyncClient]:
@@ -79,8 +83,12 @@ class StaticInferencePool:
def update_model_name(self, model_name: str) -> None:
self.model_name = model_name
async def get_next_client(self) -> vf.ClientConfig:
return next(self._client_cycle)
@property
def eval_clients(self) -> list[vf.ClientConfig]:
return self._eval_clients
async def get_eval_client(self) -> vf.ClientConfig:
return next(self._eval_cycle)
async def wait_for_ready(self, model_name: str, timeout: int = 1800) -> None:
await check_health(self._admin_clients, timeout=timeout)
@@ -97,15 +105,27 @@ class StaticInferencePool:
async def setup_inference_pool(
client_config: ClientConfig, model_name: str, client_type: str = "openai_chat_completions"
client_config: ClientConfig,
model_name: str,
train_client_type: str = "openai_chat_completions_token",
eval_client_type: str = "openai_chat_completions",
) -> InferencePool:
"""Create an inference pool from config (static or elastic)."""
logger = get_logger()
if train_client_type == "openai_chat_completions_token":
logger.warning(
"Token-in-token-out (TITO) client is enabled for training. Only use "
"this if your environment has a linear history and the chat "
"template has the extension property."
)
if client_config.is_elastic:
from prime_rl.utils.elastic import ElasticInferencePool
return await ElasticInferencePool.from_config(client_config, model_name=model_name, client_type=client_type)
return await ElasticInferencePool.from_config(
client_config, model_name=model_name, train_client_type=train_client_type, eval_client_type=eval_client_type
)
logger.info(
f"Initializing static inference pool (base_url={', '.join(client_config.base_url)}, "
@@ -113,9 +133,7 @@ async def setup_inference_pool(
f"api_key_var={client_config.api_key_var}, headers={client_config.headers})"
)
return StaticInferencePool(
clients=setup_clients(client_config, client_type=client_type),
admin_clients=setup_admin_clients(client_config),
skip_model_check=client_config.skip_model_check,
client_config, model_name=model_name, train_client_type=train_client_type, eval_client_type=eval_client_type
)
+47 -47
View File
@@ -102,50 +102,48 @@ class ElasticInferencePool:
def __init__(
self,
hostname: str,
client_config: ClientConfig,
model_name: str,
port: int = 8000,
sync_interval: float = 5.0,
client_type: str = "openai_chat_completions",
router_url: str | None = None,
train_client_type: str = "openai_chat_completions_token",
eval_client_type: str = "openai_chat_completions",
):
self.logger = get_logger()
self.hostname = hostname
self.client_config = client_config
self.model_name = model_name
self.base_model_name = model_name # Keep original for health checks
self.port = port
self.sync_interval = sync_interval
self.client_type = client_type
self.router_url = router_url
self.hostname = client_config.elastic.hostname
self.port = client_config.elastic.port
self.sync_interval = client_config.elastic.sync_interval
self.train_client_type = train_client_type
self.eval_client_type = eval_client_type
self.router_url = client_config.router_url
self._servers: dict[str, ServerState] = {}
self._admin_clients: dict[str, AsyncClient] = {}
self._lock = asyncio.Lock()
self._desired: AdapterState = AdapterState()
self._clients: list[vf.ClientConfig] = []
self._train_clients: list[vf.ClientConfig] = []
self._eval_clients: list[vf.ClientConfig] = []
self._client_urls: list[str] = []
self._client_index = 0
self._eval_index = 0
self._sync_task: asyncio.Task | None = None
self._started = False
@classmethod
async def from_config(
cls, config: ClientConfig, model_name: str, client_type: str = "openai_chat_completions"
cls,
client_config: ClientConfig,
model_name: str,
train_client_type: str = "openai_chat_completions_token",
eval_client_type: str = "openai_chat_completions",
) -> ElasticInferencePool:
if config.elastic is None:
if client_config.elastic is None:
raise ValueError("Elastic inference pool requires elastic config")
pool = cls(
hostname=config.elastic.hostname,
client_config=config,
model_name=model_name,
port=config.elastic.port,
sync_interval=config.elastic.sync_interval,
client_type=client_type,
router_url=config.router_url,
client_config, model_name=model_name, train_client_type=train_client_type, eval_client_type=eval_client_type
)
await pool.start()
return pool
@@ -163,8 +161,8 @@ class ElasticInferencePool:
def ready_urls(self) -> list[str]:
return [self._build_inference_url(ip) for ip, s in self._servers.items() if s.status == "ready"]
@property
def clients(self) -> list[vf.ClientConfig]:
def _rebuild_clients(self) -> None:
"""Rebuild inference clients when the set of ready URLs changes."""
# When a router URL is configured, route inference requests through it
# instead of directly to discovered pods. Admin operations still use
# individual pod IPs via admin_clients.
@@ -176,34 +174,35 @@ class ElasticInferencePool:
urls = self.ready_urls
if set(urls) != set(self._client_urls):
self._client_urls = urls
self._client_index = 0
self._clients = (
setup_clients(
ClientConfig(
timeout=self.client_config.timeout,
connect_timeout=self.client_config.connect_timeout,
base_url=urls,
api_key_var=self.client_config.api_key_var,
headers=self.client_config.headers,
dp_rank_count=self.client_config.dp_rank_count,
),
client_type=self.client_type,
)
if urls
else []
self._eval_index = 0
url_config = ClientConfig(
timeout=self.client_config.timeout,
connect_timeout=self.client_config.connect_timeout,
base_url=urls,
api_key_var=self.client_config.api_key_var,
headers=self.client_config.headers,
dp_rank_count=self.client_config.dp_rank_count,
)
return self._clients
self._train_clients = setup_clients(url_config, client_type=self.train_client_type) if urls else []
self._eval_clients = setup_clients(url_config, client_type=self.eval_client_type) if urls else []
@property
def has_clients(self) -> bool:
return len(self.clients) > 0
def train_clients(self) -> list[vf.ClientConfig]:
self._rebuild_clients()
return self._train_clients
async def get_next_client(self) -> vf.ClientConfig:
"""Get next client in round-robin fashion."""
while not self.has_clients:
@property
def eval_clients(self) -> list[vf.ClientConfig]:
self._rebuild_clients()
return self._eval_clients
async def get_eval_client(self) -> vf.ClientConfig:
"""Get next eval client in round-robin fashion."""
while not self.eval_clients:
await asyncio.sleep(self.sync_interval)
client = self._clients[self._client_index % len(self._clients)]
self._client_index += 1
client = self._eval_clients[self._eval_index % len(self._eval_clients)]
self._eval_index += 1
return client
@property
@@ -439,7 +438,8 @@ class ElasticInferencePool:
for ip in list(self._servers.keys()):
await self._remove_server(ip)
self._clients = []
self._train_clients = []
self._eval_clients = []
self._client_urls = []
self._started = False
+5 -1
View File
@@ -12,6 +12,7 @@ from transformers.tokenization_utils import PreTrainedTokenizer
from wandb.errors import CommError
from prime_rl.configs.shared import WandbConfig, WandbWithExtrasConfig
from prime_rl.utils.chat_template import deserialize_tool_calls
from prime_rl.utils.config import BaseConfig
from prime_rl.utils.logger import get_logger
from prime_rl.utils.monitor.base import Monitor, sample_items_for_logging
@@ -195,7 +196,10 @@ class WandbMonitor(Monitor):
if not completion:
continue
if isinstance(completion, list):
completion = self.tokenizer.apply_chat_template(completion, tokenize=False)
try:
completion = self.tokenizer.apply_chat_template(deserialize_tool_calls(completion), tokenize=False)
except Exception:
completion = str(completion)
sample = {
"step": step,
"env": env_name,
+54 -54
View File
@@ -185,12 +185,12 @@ def test_adapter_state_creation():
def test_adapter_matches_when_no_adapter_desired():
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
# No adapter desired (base model inference)
assert pool._adapter_matches_desired(None) is True
assert pool._adapter_matches_desired(AdapterState("x", Path("/x"), 0)) is True
@@ -198,12 +198,12 @@ def test_adapter_matches_when_no_adapter_desired():
def test_adapter_matches_by_path():
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.path = Path("/weights/step_100")
pool._desired.step = 100
@@ -216,12 +216,12 @@ def test_adapter_matches_by_path():
def test_adapter_matches_by_step_when_nonzero():
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.path = Path("/weights/step_100")
pool._desired.step = 100
@@ -232,12 +232,12 @@ def test_adapter_matches_by_step_when_nonzero():
def test_adapter_does_not_match_by_zero_step():
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.path = Path("/weights/step_0")
pool._desired.step = 0
@@ -248,12 +248,12 @@ def test_adapter_does_not_match_by_zero_step():
def test_adapter_returns_false_when_no_adapter_loaded():
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.path = Path("/weights/step_100")
pool._desired.step = 100
@@ -266,12 +266,12 @@ def test_adapter_returns_false_when_no_adapter_loaded():
def test_get_loaded_adapter_finds_correct_adapter_when_multiple_loaded():
"""Test that _get_loaded_adapter returns the adapter matching desired name, not the first one."""
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
# Set the desired adapter name
pool._desired.name = "rft-target-run"
@@ -317,12 +317,12 @@ def test_get_loaded_adapter_finds_correct_adapter_when_multiple_loaded():
def test_get_loaded_adapter_returns_none_when_desired_adapter_not_found():
"""Test that _get_loaded_adapter returns None when desired adapter is not in the list."""
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.name = "rft-missing-run"
pool._desired.path = Path("/data/outputs/missing_run/broadcasts/step_5")
@@ -348,12 +348,12 @@ def test_get_loaded_adapter_returns_none_when_desired_adapter_not_found():
def test_get_loaded_adapter_parses_step_from_path():
"""Test that _get_loaded_adapter correctly parses step number from path."""
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.name = "my-lora"
@@ -377,12 +377,12 @@ def test_get_loaded_adapter_parses_step_from_path():
def test_get_loaded_adapter_handles_step_dash_format():
"""Test that _get_loaded_adapter parses step-N format (with dash)."""
with patch("prime_rl.utils.elastic.get_logger"):
pool = ElasticInferencePool(
hostname="test.hostname",
client_config=MagicMock(),
model_name="base-model",
port=8000,
)
mock_config = MagicMock()
mock_config.elastic.hostname = "test.hostname"
mock_config.elastic.port = 8000
mock_config.elastic.sync_interval = 5.0
mock_config.router_url = None
pool = ElasticInferencePool(client_config=mock_config, model_name="base-model")
pool._desired.name = "my-lora"