SIGN IN SIGN UP

FlashInfer: Kernel Library for LLM Serving

0 0 188 Python

fix(CI unit tests, cute_dsl, spark): set USER env var before torch._dynamo import for unmapped UIDs (#3314)

<!-- .github/pull_request_template.md -->

## ๐Ÿ“Œ Description

Summary
Follow-up to #3290. The lazy wrapper in #3290 fixed the import-time
crash (KeyError: 'getpwuid(): uid not found: 996') for all tests by
deferring torch._dynamo.disable from module load time to first call.
However, test_b12x_fused_moe still hit the same error at runtime because
it's the only test that actually calls current_cuda_stream(), which
triggers the lazy wrapper and imports torch._dynamo.

The root cause is that torch._dynamo initialization calls
getpass.getuser(), which falls back to pwd.getpwuid(os.getuid()) when no
username env var is set. In .dlfw_runners CI containers (Spark, 5090,
Thor) running with -u $(id -u):$(id -g), the host UID (996) has no
/etc/passwd entry.

This fix sets a fallback USER env var before the torch._dynamo import so
getpass.getuser() returns from its env-var check and never reaches the
failing getpwuid call.

## ๐Ÿ” Related Issues

<!-- Link any related issues here -->

## ๐Ÿš€ Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull
request, please make sure the following items are complete.

### โœ… Pre-commit Checks

- [x] I have installed `pre-commit` by running `pip install pre-commit`
(or used your preferred method).
- [x] I have installed the hooks with `pre-commit install`.
- [x] I have run the hooks manually with `pre-commit run --all-files`
and fixed any reported issues.

> If you are unsure about how to set up `pre-commit`, see [the
pre-commit documentation](https://pre-commit.com/).

## ๐Ÿงช Tests

- [x] Tests have been added or updated as needed.
- [x] All tests are passing (`unittest`, etc.).

## Reviewer Notes

<!-- Optional: anything you'd like reviewers to focus on, concerns, etc.
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved reliability in containerized environments by enhancing how
user environment information is detected, preventing failures when
running in containers.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/flashinfer-ai/flashinfer/pull/3314)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Alex Yang <aleyang@nvidia.com>
K
Ka-Hyun Nam committed
de541f13d915c8e85479bd52eed95c6c9cb37c27
Parent: a73c281
Committed by GitHub <noreply@github.com> on 5/16/2026, 11:47:39 PM