vllm.envs
¶
Functions:
-
__getattr__–Gets environment variables lazily.
-
compile_factors–Return env vars used for torch.compile cache keys.
-
disable_envs_cache–Resets the environment variables cache. It could be used to isolate environments
-
enable_envs_cache–Enables caching of environment variables. This is useful for performance
-
env_list_with_choices–Create a lambda that validates environment variable
-
env_set_with_choices–Creates a lambda which that validates environment variable
-
env_with_choices–Create a lambda that validates environment variable against allowed choices.
-
get_env_or_set_default–Create a lambda that returns an environment variable value if set,
-
get_vllm_port–Get the port from VLLM_PORT environment variable.
-
is_set–Check if an environment variable is explicitly set.
Attributes:
-
VLLM_SKIP_MODEL_NAME_VALIDATION(bool) –If set, vLLM will skip model name validation in API requests.
VLLM_SKIP_MODEL_NAME_VALIDATION = False
module-attribute
¶
If set, vLLM will skip model name validation in API requests. This allows any model name to be accepted in the 'model' field of requests, making the server model-name agnostic. Useful for proxy/gateway scenarios.
__getattr__(name)
¶
Gets environment variables lazily.
NOTE: After enable_envs_cache() invocation (which triggered after service initialization), all environment variables will be cached.
Source code in vllm/envs.py
_is_envs_cache_enabled()
¶
_resolve_rust_cli_path()
¶
Resolve the vllm-rs binary path.
Returns None unless VLLM_USE_RUST_FRONTEND or VLLM_USE_RUST_BENCH is enabled. When enabled, resolves VLLM_RUST_FRONTEND_PATH ("auto" by default) to the actual binary path.
Source code in vllm/envs.py
compile_factors()
¶
Return env vars used for torch.compile cache keys.
Start with every known vLLM env var; drop entries in ignored_factors;
hash everything else. This keeps the cache key aligned across workers.
Source code in vllm/envs.py
2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 | |
disable_envs_cache()
¶
Resets the environment variables cache. It could be used to isolate environments between unit tests.
Source code in vllm/envs.py
enable_envs_cache()
¶
Enables caching of environment variables. This is useful for performance reasons, as it avoids the need to re-evaluate environment variables on every call.
NOTE: Currently, it's invoked after service initialization to reduce runtime overhead. This also means that environment variables should NOT be updated after the service is initialized.
Source code in vllm/envs.py
env_list_with_choices(env_name, default, choices, case_sensitive=True)
¶
Create a lambda that validates environment variable containing comma-separated values against allowed choices
Parameters:
-
(env_name¶str) –Name of the environment variable
-
(default¶list[str]) –Default list of values if not set
-
(choices¶list[str] | Callable[[], list[str]]) –List of valid string options or callable that returns list
-
(case_sensitive¶bool, default:True) –Whether validation should be case sensitive
Returns:
-
Callable[[], list[str]]–Lambda function for environment_variables
-
Callable[[], list[str]]–dict that returns list of strings
Source code in vllm/envs.py
env_set_with_choices(env_name, default, choices, case_sensitive=True)
¶
Creates a lambda which that validates environment variable containing comma-separated values against allowed choices which returns choices as a set.
Source code in vllm/envs.py
env_with_choices(env_name, default, choices, case_sensitive=True)
¶
Create a lambda that validates environment variable against allowed choices.
Parameters:
-
(env_name¶str) –Name of the environment variable
-
(default¶str | None) –Default value if not set (can be None)
-
(choices¶list[str] | Callable[[], list[str]]) –List of valid string options or callable that returns list
-
(case_sensitive¶bool, default:True) –Whether validation should be case sensitive
Returns:
Source code in vllm/envs.py
get_env_or_set_default(env_name, default_factory)
¶
Create a lambda that returns an environment variable value if set, or generates and sets a default value using the provided factory function.
Source code in vllm/envs.py
get_vllm_port()
¶
Get the port from VLLM_PORT environment variable.
Returns:
-
int | None–The port number as an integer if VLLM_PORT is set, None otherwise.
Raises:
-
ValueError–If VLLM_PORT is a URI, suggest k8s service discovery issue.
Source code in vllm/envs.py
is_set(name)
¶
Check if an environment variable is explicitly set.