Skip to content

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

Description

@tengqm

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 <module>
    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:

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions