[Bugfix][Model] Allow Run:ai memory_limit sentinel values (#47337)
Signed-off-by: Ting Sun <suntcrick@gmail.com>
Ting SUN committed
Jul 5, 2026 at 07:08 UTC
91b56473005ccc9a0d009619b5494a9c306380ee
2 files changed
+24
-16
tests/model_executor/model_loader/runai_streamer_loader/test_runai_model_streamer_loader.py
+1
-1
@@ -119,6 +119,6 @@ def test_runai_invalid_extra_config_leaves_environ_untouched():
119
# os.environ (all values are validated before any global mutation).
120
with patch.dict(os.environ, {}, clear=False):
121
os.environ.pop("RUNAI_STREAMER_CONCURRENCY", None)
122
- with pytest.raises(ValueError, match="memory_limit must be a positive integer"):
122
+ with pytest.raises(ValueError, match="memory_limit must be an integer >= -1"):
123
_runai_loader({"concurrency": 16, "memory_limit": -5})
124
assert "RUNAI_STREAMER_CONCURRENCY" not in os.environ
vllm/model_executor/model_loader/runai_streamer_loader.py
+23
-15
@@ -47,21 +47,29 @@ class RunaiModelStreamerLoader(BaseModelLoader):
47
# Validate every value before mutating os.environ, so a later
48
# invalid key cannot leave an earlier one partially applied.
49
env_updates: dict[str, str] = {}
50
- for key, env_var in (
51
- ("concurrency", "RUNAI_STREAMER_CONCURRENCY"),
52
- ("memory_limit", "RUNAI_STREAMER_MEMORY_LIMIT"),
53
- ):
54
- if key in extra_config:
55
- value = extra_config[key]
56
- if (
57
- isinstance(value, bool)
58
- or not isinstance(value, int)
59
- or value <= 0
60
- ):
61
- raise ValueError(
62
- f"{key} must be a positive integer, got {value!r}"
63
- )
64
- env_updates[env_var] = str(value)
50
+ if "concurrency" in extra_config:
51
+ concurrency = extra_config["concurrency"]
52
+ if (
53
+ isinstance(concurrency, bool)
54
+ or not isinstance(concurrency, int)
55
+ or concurrency <= 0
56
+ ):
57
+ raise ValueError(
58
+ f"concurrency must be a positive integer, got {concurrency!r}"
59
+ )
60
+ env_updates["RUNAI_STREAMER_CONCURRENCY"] = str(concurrency)
61
+
62
+ if "memory_limit" in extra_config:
63
+ memory_limit = extra_config["memory_limit"]
64
+ if (
65
+ isinstance(memory_limit, bool)
66
+ or not isinstance(memory_limit, int)
67
+ or memory_limit < -1
68
+ ):
69
+ raise ValueError(
70
+ f"memory_limit must be an integer >= -1, got {memory_limit!r}"
71
+ )
72
+ env_updates["RUNAI_STREAMER_MEMORY_LIMIT"] = str(memory_limit)
73
os.environ.update(env_updates)
74
75
runai_streamer_s3_endpoint = os.getenv("RUNAI_STREAMER_S3_ENDPOINT")