Restore automatic weight change logic in cluster master

- Add logic to set master weight to 0 when first client connects (unless explicitly set via command line)
- This ensures proper load balancing between local and remote workers
parent 133d777a
...@@ -368,6 +368,14 @@ class ClusterMaster: ...@@ -368,6 +368,14 @@ class ClusterMaster:
backend_type = "GPU" if has_gpu else "CPU-only" backend_type = "GPU" if has_gpu else "CPU-only"
print(f"Client {client_id} authenticated ({backend_type}) with backends: {available_backends}") print(f"Client {client_id} authenticated ({backend_type}) with backends: {available_backends}")
# Auto-weight logic: set master weight to 0 when first client connects (unless explicitly set)
if not self.weight_explicit:
non_local_clients = [cid for cid in self.clients if not self.clients[cid].get('local', False)]
if len(non_local_clients) == 1: # This is the first non-local client
print("First client connected, setting master weight to 0 for load balancing")
self.weight = 0
return {'type': 'auth_success', 'client_id': client_id} return {'type': 'auth_success', 'client_id': client_id}
def _handle_register_processes(self, message: Dict[str, Any], websocket: websockets.WebSocketServerProtocol) -> Dict[str, Any]: def _handle_register_processes(self, message: Dict[str, Any], websocket: websockets.WebSocketServerProtocol) -> Dict[str, Any]:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment