sgl-project / sglang

SGLang is a structured generation language designed for large language models (LLMs). It makes your interaction with models faster and more controllable.
Apache License 2.0
2.75k stars 176 forks source link

Fix missing numpy dependency in pyproject.toml #524

Closed fpreiss closed 2 weeks ago

fpreiss commented 2 weeks ago

numpy is currently listed as an optional dependency. With the current version on pypi and on the master branch, sglang will fail to import without numpy installed. See the log output below:

Python 3.11.9 (main, May 27 2024, 20:31:01) [GCC 14.1.1 20240507] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sglang
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fpreiss/Downloads/github/sglang/python/sglang/__init__.py", line 4, in <module>
    from sglang.api import (
  File "/home/fpreiss/Downloads/github/sglang/python/sglang/api.py", line 7, in <module>
    from sglang.backend.base_backend import BaseBackend
  File "/home/fpreiss/Downloads/github/sglang/python/sglang/backend/base_backend.py", line 4, in <module>
    from sglang.lang.interpreter import StreamExecutor
  File "/home/fpreiss/Downloads/github/sglang/python/sglang/lang/interpreter.py", line 34, in <module>
    from sglang.utils import (
  File "/home/fpreiss/Downloads/github/sglang/python/sglang/utils.py", line 15, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

This commit proposes a simple fix by requiring numpy in the pyproject.toml.