Repository navigation
[TRTLLM-18143][feat] Add get_env_flag, a strict parser for on/off env switches - #21212
yijingl-nvidia wants to merge 2 commits into
Conversation
a0a3c93 to
23046d3
Compare
|
/bot run |
|
PR_Github #81726 [ run ] triggered by Bot. Commit: |
|
PR_Github #81726 [ run ] completed with state
|
|
PR_Github #82908 [ run ] triggered by Bot. Commit: |
|
All review comments so far are addressed: each of the 56 review threads has a reply and is resolved. The current head, 070b062, is rebased on main, and CI is running on it. |
|
PR_Github #82881 [ run ] completed with state |
|
PR_Github #82908 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #82997 [ run ] triggered by Bot. Commit: |
erictsai-nv
left a comment
There was a problem hiding this comment.
modeling_v2 changes LGTM; they are mechanical and the unset path is unchanged. Nit: qwen4_exp still parses TRTLLM_MODELING_V2_PLE_HOST_OFFLOAD and TRTLLM_MODELING_V2_MOE_PREFILL_COPY by hand.
|
PR_Github #82997 [ run ] completed with state
|
d227dd2 to
bd2434e
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #83127 [ run ] triggered by Bot. Commit: |
get_env_flag reads an on/off environment variable the same way everywhere. Unset or blank gives the caller's default, 1/true/yes/on and 0/false/no/off (any case, surrounding whitespace ignored) give True and False, and any other value raises a ValueError that names the variable. A typo then fails loudly instead of silently selecting the other code path. The Kimi K3 merge-back PRs that follow read their switches with it. Signed-off-by: Harshil Vagadia <[email protected]> Signed-off-by: Yijing Li <[email protected]>
- Overloads give get_env_flag(name, True) the type bool, so callers with a bool default need no Optional check. - The docstring lists the args, return values and the ValueError. - The error message is built from the accepted value lists. - Tests add type hints, check the whole error message and reject the one-letter forms y and t. Signed-off-by: Yijing Li <[email protected]>
bd2434e to
c62f4ed
Compare
|
/bot run |
|
PR_Github #83137 [ run ] triggered by Bot. Commit: |
|
PR_Github #83127 [ run ] completed with state |
|
PR_Github #83137 [ run ] completed with state |
Description
This PR adds
get_env_flag(name, default)totensorrt_llm/_utils.py, one strict parser for on/off environment switches.Before this PR, each module parsed its switches by hand. Most turned on only for the exact string
1, soX=truemeant off. Some used!= "0", soX=falsemeant on. A typo silently picked one of the two paths.get_env_flagreads a switch the same way wherever it is used:default.1/true/yes/onreturn True, and0/false/no/offreturn False, in any case and with surrounding whitespace ignored.ValueErrorthat names the variable.This PR changes no existing switch. The Kimi K3 merge-back PRs that follow read their new switches with
get_env_flag. The first commit is @hvagadia's fromfeat/k3_26.08.Why this PR is smaller than before
The first version of this PR did much more. Besides adding
get_env_flag, it moved 182 existing switches in 121 files over to it, read some per-request switches once at startup, and gaveTRTLLM_ENABLE_PDLone shared helper. That touched about 195 files across most of the codebase, and GitHub asked for approval from about 15 code owner teams and people. A change that wide is hard to review well in one sitting and close to impossible to get fully approved.So this PR now only adds the parser. The full conversion is kept in draft #21819. Existing switches will move to
get_env_flaga few functions or one module at a time, in small PRs that each need only the owners of the code they touch. The first-round comments onget_env_flagitself are addressed here; the comments on the conversion carry over to #21819.Test Coverage
1 test file added:
tests/unittest/utils/test_get_env_flag.py: CPU only, listed inl0_cpu.yml.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.