From 164429efff5600c8650624539ec571952bc2bf8b Mon Sep 17 00:00:00 2001 From: Andy Ye Date: Fri, 24 Jul 2026 22:24:17 +0000 Subject: [PATCH] fix(rollout): make engine port range start configurable via MILES_ROLLOUT_START_PORT The engine port scan starts at a hardcoded 15000, and the free-port probe misses servers bound to a specific interface. Two miles runs on one host therefore claim the same port range, and the second run's weight sync lands on the first run's engines (surfacing as "Invalid device_uuid"). Shifting the scan start per run keeps the ranges disjoint. Default is unchanged. Co-Authored-By: Claude Fable 5 --- miles/ray/rollout.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/miles/ray/rollout.py b/miles/ray/rollout.py index dedc7033..673d4ea7 100644 --- a/miles/ray/rollout.py +++ b/miles/ray/rollout.py @@ -1,6 +1,7 @@ import itertools import logging import multiprocessing +import os import random import time from pathlib import Path @@ -547,7 +548,10 @@ def _allocate_rollout_engine_addr_and_ports_normal(*, args, num_engines, rollout def get_addr_and_ports(engine): # use small ports to prevent ephemeral port between 32768 and 65536. # also, ray uses port 10002-19999, thus we avoid near-10002 to avoid racing condition - start_port = 15000 + # MILES_ROLLOUT_START_PORT: shift the range so concurrent miles runs + # on one host don't collide (the free-port probe can miss servers + # bound to a specific interface). + start_port = int(os.environ.get("MILES_ROLLOUT_START_PORT", "15000")) def port(consecutive=1): nonlocal start_port