Declare this machine's GPUs from serve, and refuse a bad limit as a flag
GPU count is not detected, so FLOW_GPUS was 0 on a fresh install and a node asking for one was silently clamped to zero and ran concurrently with every other. Setting the variable serialised them, but it was an environment variable only — `serve` had --max-runs and --max-workers and no --gpus. The clamp warning now names the flag when nothing here declares a card. The same flags are written into the environment before the settings are built, so a value they refused died in a pydantic import naming no flag. They are checked where they are typed instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Hra4ndWMCLU5F3KjUuVAc
This commit is contained in:
+28
-3
@@ -21,6 +21,7 @@ import os
|
||||
import secrets
|
||||
import socket
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -228,9 +229,26 @@ CONCURRENCY_FLAGS = {
|
||||
"max_workers": "FLOW_MAX_WORKERS",
|
||||
"max_cascades": "FLOW_MAX_CASCADES",
|
||||
"max_runs": "FLOW_MAX_RUNS",
|
||||
"gpus": "FLOW_GPUS",
|
||||
}
|
||||
|
||||
|
||||
def _at_least(minimum: int) -> Callable[[str], int]:
|
||||
"""A flag's value, checked here rather than by the settings.
|
||||
|
||||
These are written into the environment before the settings are built, so a
|
||||
number they refuse dies inside a pydantic import with no flag named in it.
|
||||
"""
|
||||
|
||||
def parse(text: str) -> int:
|
||||
value = int(text)
|
||||
if value < minimum:
|
||||
raise argparse.ArgumentTypeError(f"is {value}, needs at least {minimum}")
|
||||
return value
|
||||
|
||||
return parse
|
||||
|
||||
|
||||
#: What `serve` listens on when nobody says. Taken often enough — another
|
||||
#: engine, another framework's dev server — that dying on it is the first
|
||||
#: thing a zero-config start would hit.
|
||||
@@ -426,25 +444,32 @@ def _parser() -> argparse.ArgumentParser:
|
||||
)
|
||||
serve.add_argument(
|
||||
"--max-runs",
|
||||
type=int,
|
||||
type=_at_least(1),
|
||||
default=None,
|
||||
metavar="N",
|
||||
help="batch runs driven at once (default 4, FLOW_MAX_RUNS)",
|
||||
)
|
||||
serve.add_argument(
|
||||
"--max-cascades",
|
||||
type=int,
|
||||
type=_at_least(1),
|
||||
default=None,
|
||||
metavar="N",
|
||||
help="cascades in flight at once (default 4, FLOW_MAX_CASCADES)",
|
||||
)
|
||||
serve.add_argument(
|
||||
"--max-workers",
|
||||
type=int,
|
||||
type=_at_least(1),
|
||||
default=None,
|
||||
metavar="N",
|
||||
help="python worker processes (default 4, FLOW_MAX_WORKERS)",
|
||||
)
|
||||
serve.add_argument(
|
||||
"--gpus",
|
||||
type=_at_least(0),
|
||||
default=None,
|
||||
metavar="N",
|
||||
help="GPUs on this machine a node may be given (default 0, FLOW_GPUS)",
|
||||
)
|
||||
serve.set_defaults(func=cmd_serve)
|
||||
|
||||
enroll = subparsers.add_parser(
|
||||
|
||||
Reference in New Issue
Block a user