Repository navigation
fix parameters pass through for trtllm #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -363,13 +363,7 @@ def _add_trtllm_stub_args(parser: argparse.ArgumentParser) -> None: | |
| """ | ||
| group = parser.add_argument_group("TensorRT-LLM Options") | ||
| group.add_argument("--model", type=str, help="Model path (HuggingFace ID or local path)") | ||
| group.add_argument("--tp-size", type=int, help="Tensor parallel size (overrides config file)") | ||
| group.add_argument( | ||
| "--config", | ||
| type=str, | ||
| required=False, | ||
| help="Config file path (YAML, optional - must contain tensor_parallel_size if provided)", | ||
| ) | ||
| group.add_argument("--tp_size", type=int, help="Tensor parallel size (overrides config file)") | ||
|
|
||
|
|
||
| BACKEND_ARG_ADDERS = { | ||
|
|
@@ -482,7 +476,10 @@ def parse_serve_args( | |
| _import_backend_args(backend, parser) | ||
| RouterArgs.add_cli_args(parser, use_router_prefix=True, exclude_host_port=True) | ||
|
|
||
| args = parser.parse_args(argv) | ||
| if backend == "trtllm": | ||
| args, _ = parser.parse_known_args(argv) | ||
|
Comment on lines
+479
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎.
Comment on lines
+479
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using Useful? React with 👍 / 👎. |
||
| else: | ||
| args = parser.parse_args(argv) | ||
| return backend, args, backend_args | ||
|
Comment on lines
+479
to
483
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Log the discarded tokens from Unknown args in pass 2 are silently dropped into ♻️ Proposed change if backend == "trtllm":
- args, _ = parser.parse_known_args(argv)
+ args, unknown = parser.parse_known_args(argv)
+ if unknown:
+ logger.debug(
+ "trtllm: ignoring unrecognized args in pass-2 parse (will be forwarded via backend_args): %s",
+ unknown,
+ )
else:
args = parser.parse_args(argv)🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,9 +158,12 @@ class TestImportBackendArgs: | |
| def test_trtllm_adds_model_arg(self): | ||
| parser = argparse.ArgumentParser() | ||
| _import_backend_args("trtllm", parser) | ||
| args = parser.parse_args(["--model", "/path/to/model", "--config", "/path/to/config.yml"]) | ||
| args, backend_args = parser.parse_known_args( | ||
| ["--model", "/path/to/model", "--config", "/path/to/config.yml"] | ||
| ) | ||
| assert args.model == "/path/to/model" | ||
| assert args.config == "/path/to/config.yml" | ||
| assert "--config" in backend_args | ||
| assert "/path/to/config.yml" in backend_args | ||
|
Comment on lines
158
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find the serve.py file and examine the implementations
echo "=== Looking for serve.py ==="
fd -t f "serve.py" bindings/python
echo ""
echo "=== Finding _add_trtllm_stub_args ==="
rg -A 20 "def _add_trtllm_stub_args" bindings/python
echo ""
echo "=== Finding _get_tp_size ==="
rg -A 10 "def _get_tp_size" bindings/pythonRepository: lightseekorg/smg Length of output: 5081 🏁 Script executed: #!/bin/bash
# Get the full TrtllmWorkerLauncher._get_tp_size implementation
echo "=== Full TrtllmWorkerLauncher._get_tp_size ==="
rg -A 30 "class TrtllmWorkerLauncher" bindings/python/src/smg/serve.py | grep -A 30 "_get_tp_size"
echo ""
echo "=== Check if args.config is referenced in TrtllmWorkerLauncher._get_tp_size ==="
sed -n '/class TrtllmWorkerLauncher/,/^class /p' bindings/python/src/smg/serve.py | grep -A 25 "def _get_tp_size" | head -30Repository: lightseekorg/smg Length of output: 2147 🏁 Script executed: #!/bin/bash
# Search for tp_size coverage in tests
echo "=== Searching for tp_size in test file ==="
rg "tp_size" bindings/python/tests/test_serve.py
echo ""
echo "=== Full TestAddTrtllmStubArgs test ==="
sed -n '/class TestAddTrtllmStubArgs/,/^class /p' bindings/python/tests/test_serve.py | head -30Repository: lightseekorg/smg Length of output: 2537 Correctly reflects The switch to Note: 🤖 Prompt for AI Agents |
||
|
|
||
| def test_sglang_import_error(self): | ||
| """sglang is not installed in test env, so parser.error should be called.""" | ||
|
|
@@ -304,7 +307,7 @@ def test_two_pass_extracts_backend_first(self): | |
| def test_unknown_arg_rejected_in_pass2(self): | ||
| """Unknown args should be rejected by the full parser in pass 2.""" | ||
| with pytest.raises(SystemExit): | ||
| parse_serve_args(["--backend", "trtllm", "--totally-unknown-flag"]) | ||
| parse_serve_args(["--backend", "sglang", "--totally-unknown-flag"]) | ||
|
Comment on lines
307
to
+310
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Using The previous To genuinely test pass-2 unknown-arg rejection, mock 🛠️ Suggested fix def test_unknown_arg_rejected_in_pass2(self):
"""Unknown args should be rejected by the full parser in pass 2."""
- with pytest.raises(SystemExit):
- parse_serve_args(["--backend", "sglang", "--totally-unknown-flag"])
+ # Patch _import_backend_args so the backend loads successfully, letting
+ # pass-2 parse_args be the one to reject the unknown flag.
+ with patch("smg.serve._import_backend_args"):
+ with pytest.raises(SystemExit):
+ parse_serve_args(["--backend", "sglang", "--totally-unknown-flag"])🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--tp-sizeflag spelling for TensorRT-LLMChanging the stub flag from
--tp-sizeto--tp_sizebreaks existing CLI usage and silently drops TP size in the orchestrator path: users passing--tp-sizenow leaveargs.tp_sizeunset, soTrtllmWorkerLauncher._get_tp_size()falls back to defaults while the raw token is only forwarded inbackend_args. In multi-worker runs this mis-sizesCUDA_VISIBLE_DEVICESand can cause incorrect GPU allocation or worker startup failures.Useful? React with 👍 / 👎.