Skip to content

Conversation

@xingliu14
Copy link
Collaborator

@xingliu14 xingliu14 commented Nov 9, 2025

Description

Created envs.py to centrally store environment variables.
Replaced MODEL_IMPL_TYPE and USE_MOE_EP_KERNEL usages to use the envs.
Addressing #1016.

Tests

pytest /home/liuxing_google_com/tpu-inference/tests/worker/tpu_worker_test.py -v
pytest /home/liuxing_google_com/tpu-inference/tests/models/common/test_model_loader.py -v

Checklist

Before submitting this PR, please make sure:

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have made or will make corresponding changes to any relevant documentation.

@xingliu14 xingliu14 force-pushed the env_var branch 2 times, most recently from 85aa68d to 38a2547 Compare November 9, 2025 02:16
@kyuyeunk kyuyeunk self-requested a review November 9, 2025 03:02
@kyuyeunk
Copy link
Collaborator

kyuyeunk commented Nov 9, 2025

Thanks! So this PR only creates env.py file? But this PR does make changes so that our existing code make use of this new file right? Can you also add that feature and everything works correctly?

@xingliu14 xingliu14 force-pushed the env_var branch 2 times, most recently from 3c07b53 to 737eed5 Compare November 10, 2025 21:09
@xingliu14
Copy link
Collaborator Author

xingliu14 commented Nov 10, 2025

I am planning to create the env file for review and gradually refactor the env var usages. I replaced USE_MOE_EP_KERNEL in this PR.

@kyuyeunk
Copy link
Collaborator

Personally, MODEL_IMPL_TYPE is one of environment variable that I use very frequently and there's a test for it in here as well: https://github.com/vllm-project/tpu-inference/blob/main/tests/models/common/test_model_loader.py

I.e., you can test out the feature with

pytest -v tests/models/common/test_model_loader.py

Can you apply this feature into MODEL_IMPL_TYPE and see if unit test all passes?

@xingliu14
Copy link
Collaborator Author

Replaced MODEL_IMPL_TYPE in all 3 files: model_loader.py, tpu_worker_jax.py and tpu_jax.py and their tests. Verified by pytest test_model_loader.py and tpu_worker_jax_test.py.

@kyuyeunk
Copy link
Collaborator

Thank you, will approve when the CI passes: https://buildkite.com/tpu-commons/tpu-inference-ci/builds/5201

@kyuyeunk
Copy link
Collaborator

CI looks good, but please resolve merge conflicts.

Also, please remove JAX_RANDOM_WEIGHTS from the list as we have removed it in the latest PR: #1017

- Fix boolean environment variables: use bool(int(...)) instead of bool(os.getenv(..., False))
  - Correctly converts '0' to False and '1' to True
  - Fixed JAX_RANDOM_WEIGHTS, SKIP_JAX_PRECOMPILE, NEW_MODEL_DESIGN

- Standardize to use os.getenv() consistently across all variables

- Improve docstrings:
  - Clarify __getattr__ comment: function is wrapped with functools.cache()
  - Clarify enable_envs_cache() comment: explains caching behavior and lifecycle

- Type annotations in TYPE_CHECKING now accurately reflect runtime behavior

Signed-off-by: Xing Liu <xingliu14@gmail.com>
Signed-off-by: Xing Liu <xingliu14@gmail.com>
Signed-off-by: Xing Liu <xingliu14@gmail.com>
Signed-off-by: Xing Liu <xingliu14@gmail.com>
Signed-off-by: Xing Liu <xingliu14@gmail.com>
@xingliu14
Copy link
Collaborator Author

Done.

@kyuyeunk
Copy link
Collaborator

Thanks! Running CI: https://buildkite.com/tpu-commons/tpu-inference-ci/builds/5238

Let me know when it's finished. I'll give approval when it all looks good.

@xingliu14
Copy link
Collaborator Author

The CI failed, while the main branch CI also failed for the same tests, I may wait until the error be fixed.

@kyuyeunk kyuyeunk merged commit b8fcb0b into vllm-project:main Nov 12, 2025
3 checks passed
}


def __getattr__(name: str) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add test coverage like what vllm.main do?

https://github.com/vllm-project/vllm/blob/main/tests/test_envs.py

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. I initially thought that existing unit test that utilizes these environment variables has passed as a sufficient coverage test. But it's probably a good idea to add a separate test as well.

@xingliu14, can you add a unit test like the one reference here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll add test on the follow up PR.

@QiliangCui
Copy link
Collaborator

Please take this as example and add test coverage for envs.py
https://github.com/vllm-project/vllm/blob/main/tests/test_envs.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants