@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / e317414ce1
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 14, 05:30 UTC

Cache the environment variable check for batch invariance (#26510)

Signed-off-by: Bram Wasti <bwasti@meta.com>

Bram Wasti committed Oct 10, 2025 at 15:47 UTC e317414ce11a66f6e653ce382f5d987b0c0191bd
1 file changed +6 -3
csrc/core/batch_invariant.hpp
+6 -3
@@ -8,9 +8,12 @@ namespace vllm {
8 // vllm_kernel_override_batch_invariant(); returns true
9 // if env VLLM_KERNEL_OVERRIDE_BATCH_INVARIANT=1
10 inline bool vllm_kernel_override_batch_invariant() {
11 - std::string env_key = "VLLM_KERNEL_OVERRIDE_BATCH_INVARIANT";
12 - const char* val = std::getenv(env_key.c_str());
13 - return (val && std::atoi(val) != 0) ? 1 : 0;
11 + static bool cached = []() {
12 + std::string env_key = "VLLM_KERNEL_OVERRIDE_BATCH_INVARIANT";
13 + const char* val = std::getenv(env_key.c_str());
14 + return (val && std::atoi(val) != 0) ? 1 : 0;
15 + }();
16 + return cached;
17 }
18
19 } // namespace vllm