Skip to content

Commit c059e6c

Browse files
authored
[TRTC-121] [feat] Add recipe selector UI to complement the recipe database (#10125)
Signed-off-by: Venky Ganesh <23023424+venkywonka@users.noreply.github.com>
1 parent a9eb5af commit c059e6c

File tree

11 files changed

+1124
-71
lines changed

11 files changed

+1124
-71
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
from __future__ import annotations
5+
6+
import sys
7+
from pathlib import Path
8+
9+
from docutils import nodes
10+
from docutils.parsers.rst import Directive, directives
11+
from sphinx.util import logging
12+
13+
LOGGER = logging.getLogger(__name__)
14+
15+
16+
class TRTLLMConfigSelector(Directive):
17+
"""Embed the interactive config selector widget."""
18+
19+
has_content = False
20+
option_spec = {
21+
"models": directives.unchanged,
22+
"config_db": directives.unchanged,
23+
}
24+
25+
def run(self):
26+
models = (self.options.get("models") or "").strip()
27+
config_db = (self.options.get("config_db") or "").strip()
28+
29+
attrs = ['data-trtllm-config-selector="1"']
30+
if models:
31+
attrs.append(f'data-models="{models}"')
32+
if config_db:
33+
attrs.append(f'data-config-db="{config_db}"')
34+
35+
html = f"<div {' '.join(attrs)}></div>"
36+
return [nodes.raw("", html, format="html")]
37+
38+
39+
def _ensure_repo_root_on_syspath() -> Path:
40+
repo_root = Path(__file__).resolve().parents[3]
41+
if str(repo_root) not in sys.path:
42+
sys.path.insert(0, str(repo_root))
43+
return repo_root
44+
45+
46+
def _write_config_db_json(app) -> None:
47+
builder = getattr(app, "builder", None)
48+
if not builder:
49+
return
50+
if builder.name not in {"html", "dirhtml"}:
51+
return
52+
53+
_ensure_repo_root_on_syspath()
54+
from examples.configs.database.database import DATABASE_LIST_PATH
55+
from scripts.generate_config_table import generate_json
56+
57+
out_static = Path(builder.outdir) / "_static"
58+
out_static.mkdir(parents=True, exist_ok=True)
59+
out_path = out_static / "config_db.json"
60+
generate_json(Path(DATABASE_LIST_PATH), output_file=out_path)
61+
LOGGER.info("Wrote config selector database: %s", out_path)
62+
63+
64+
def _on_build_finished(app, exception) -> None:
65+
if exception is not None:
66+
return
67+
_write_config_db_json(app)
68+
69+
70+
def setup(app):
71+
app.add_css_file("config_selector.css")
72+
app.add_js_file("config_selector.js")
73+
app.add_directive("trtllm_config_selector", TRTLLMConfigSelector)
74+
# Generate config_db.json into the HTML output _static directory at build time.
75+
app.connect("build-finished", _on_build_finished)
76+
return {"version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True}

docs/source/_includes/note_sections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
4141
.. note::
4242

43-
The configs here are specifically optimized for a target ISL/OSL (Input/Output Sequence Length) of 1024/1024. If your traffic pattern is different, refer to the :ref:`Comprehensive Configuration Database` section below which covers a larger set of traffic patterns and performance profiles.
43+
The configs here are specifically optimized for a target ISL/OSL (Input/Output Sequence Length) of 1024/1024. If your traffic pattern is different, refer to the :ref:`Preconfigured Recipes` section below which covers a larger set of traffic patterns and performance profiles.
4444

4545
.. end-note-quick-start-isl-osl
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
.trtllm-config-selector {
2+
border: 1px solid rgba(0, 0, 0, 0.08);
3+
border-radius: 10px;
4+
padding: 16px;
5+
margin: 16px 0;
6+
}
7+
8+
.trtllm-config-selector__header {
9+
margin-bottom: 12px;
10+
}
11+
12+
.trtllm-config-selector__subtitle {
13+
font-size: 0.95rem;
14+
opacity: 0.8;
15+
margin-top: 4px;
16+
}
17+
18+
.trtllm-config-selector__form {
19+
display: grid;
20+
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
21+
gap: 12px;
22+
margin-top: 12px;
23+
}
24+
25+
.trtllm-config-selector__label {
26+
display: flex;
27+
align-items: center;
28+
gap: 8px;
29+
font-size: 0.85rem;
30+
margin-bottom: 6px;
31+
opacity: 0.9;
32+
}
33+
34+
.trtllm-config-selector__step {
35+
flex: 0 0 auto;
36+
width: 16px;
37+
height: 16px;
38+
display: inline-flex;
39+
align-items: center;
40+
justify-content: center;
41+
border-radius: 999px;
42+
font-size: 0.68rem;
43+
font-weight: 600;
44+
letter-spacing: 0.01em;
45+
border: 1px solid rgba(127, 127, 127, 0.18);
46+
background: rgba(127, 127, 127, 0.06);
47+
color: inherit;
48+
opacity: 0.65;
49+
}
50+
51+
.trtllm-config-selector__labelText {
52+
line-height: 1.2;
53+
}
54+
55+
.trtllm-config-selector__select {
56+
width: 100%;
57+
padding: 8px 10px;
58+
border-radius: 8px;
59+
border: 1px solid rgba(0, 0, 0, 0.18);
60+
background: transparent;
61+
}
62+
63+
.trtllm-config-selector__output {
64+
margin-top: 14px;
65+
}
66+
67+
.trtllm-config-selector__cmd {
68+
margin: 0;
69+
padding: 10px 12px;
70+
border-radius: 10px;
71+
border: 1px solid rgba(0, 0, 0, 0.12);
72+
overflow-x: auto;
73+
white-space: pre-wrap;
74+
overflow-wrap: anywhere;
75+
position: relative;
76+
padding-right: 54px; /* room for inline copy button */
77+
}
78+
79+
.trtllm-config-selector__meta {
80+
margin-top: 8px;
81+
font-size: 0.9rem;
82+
opacity: 0.85;
83+
}
84+
85+
.trtllm-config-selector__yamlDetails {
86+
margin-top: 12px;
87+
}
88+
89+
.trtllm-config-selector__yamlSummary {
90+
cursor: pointer;
91+
font-weight: 600;
92+
}
93+
94+
.trtllm-config-selector__yamlBox {
95+
margin-top: 10px;
96+
}
97+
98+
.trtllm-config-selector__yamlPre {
99+
margin: 0;
100+
padding: 10px 12px;
101+
border-radius: 10px;
102+
border: 1px solid rgba(0, 0, 0, 0.12);
103+
overflow-x: auto;
104+
max-height: 520px;
105+
position: relative;
106+
padding-right: 54px; /* room for inline copy button */
107+
}
108+
109+
.trtllm-config-selector__copyInline {
110+
position: absolute;
111+
top: 8px;
112+
right: 8px;
113+
font-size: 0.85rem;
114+
padding: 6px 10px;
115+
border-radius: 10px;
116+
border: 1px solid rgba(0, 0, 0, 0.12);
117+
background: rgba(255, 255, 255, 0.9);
118+
cursor: pointer;
119+
}
120+
121+
.trtllm-config-selector__copyInline:disabled {
122+
opacity: 0.5;
123+
cursor: not-allowed;
124+
}
125+
126+
.trtllm-config-selector__copyInline:hover:not(:disabled) {
127+
background: rgba(255, 255, 255, 1);
128+
}
129+
130+
.trtllm-config-selector__configLink {
131+
text-decoration: underline;
132+
}
133+
134+
.yaml-key {
135+
font-weight: 600;
136+
}
137+
138+
.yaml-comment {
139+
opacity: 0.7;
140+
}
141+
142+
.yaml-punct,
143+
.yaml-bool,
144+
.yaml-num,
145+
.yaml-str {
146+
opacity: 0.9;
147+
}
148+
149+
.trtllm-config-selector__error {
150+
margin-top: 10px;
151+
font-size: 0.9rem;
152+
opacity: 0.85;
153+
}

0 commit comments

Comments
 (0)