flagos-ai / flagos-ai/FlagTree

[iluvatar] runtime path imports pytest: triton/spec/iluvatar/triton/testing.py::nvsmi reaches triton._internal_testing

Open Beginner friendly
#1,142 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
350
Forks
149
Avg merge
2d 4h
Merged PRs (30d)
81

Description

### Summary

`triton/spec/iluvatar/triton/testing.py::nvsmi` imports `triton._internal_testing` for `is_corex`, and that module does `import pytest` at module level. `nvsmi` is reachable from a **production** call path (no test involvement), so on an iluvatar box without pytest, serving a model dies with `ModuleNotFoundError: No module named 'pytest'`.

### Version

`flagtree==0.6.1+iluvatar3.6` (the wheel installed into `flagos-runtime-iluvatar-corex4.5.0:2.1.2`, python 3.12).

### Call path

```
flag_gems _iluvatar mm/addmm tuned configs carry
prune_configs_by={"perf_model": estimate_matmul_time, ...}
-> triton/runtime/autotuner.py::prune_configs
-> triton/ops/matmul_perf_model.py::estimate_matmul_time
-> triton/ops/matmul_perf_model.py::get_tflops
-> triton/ops/matmul_perf_model.py::get_tensorcore_tflops
-> triton/ops/matmul_perf_model.py::get_clock_rate_in_khz
-> triton/spec/iluvatar/triton/testing.py::nvsmi <-- here
-> from triton._internal_testing import is_corex
-> triton/_internal_testing.py:31 import pytest <-- fails
```

Observed while serving Qwen3-4B on sglang 0.5.18 (decode attention autotuning):

```
File "/opt/flagtree/triton/ops/matmul_perf_model.py", line 14, in get_clock_rate_in_khz
return nvsmi(['clocks.max.sm'])[0] * 1e3
File "/opt/flagtree/triton/spec/iluvatar/triton/testing.py", line 8, in nvsmi
from triton._internal_testing import is_corex
File "/opt/flagtree/triton/_internal_testing.py", line 31, in
import pytest
ModuleNotFoundError: No module named 'pytest'
```

### Why it is a packaging defect rather than a caller problem

The equivalent helper in the vendor triton this stack also ships (`triton==3.2.0+corex.4.5.0.20260804`) defines `is_corex()` locally in `triton/testing.py` and imports nothing from `_internal_testing`:

```python
def is_corex():
import torch
return hasattr(torch, "corex") and torch.corex == True
```

So the spec overlay reaches into a test-support module for a one-line predicate, and by doing so drags a test framework into the runtime dependency set of every flagtree+iluvatar install.

### Suggested fix

Define `is_corex()` locally in `triton/spec/iluvatar/triton/testing.py` (as vendor triton does), or move `is_corex` out of `_internal_testing.py` into a module that does not import pytest.

### Workaround in use

Installing `pytest` into the image. FlagOS carries it until this is fixed — tracked as an explicit app dependency with a pointer back to this issue.

Contributor guide

Open the contributing guide

Research direction

Start with triton/spec/iluvatar/triton/testing.py::nvsmi and compare its is_corex dependency with the vendor triton testing.py implementation described in the issue. Check triton/_internal_testing.py to confirm the pytest import path, then verify that the production nvsmi call path can load without pytest; done means the runtime no longer requires pytest for this path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.