Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'build_regex_from_object' from 'outlines.fsm.json_schema' #203

Closed
nopepper opened this issue Feb 18, 2024 · 7 comments · Fixed by #219
Closed

Comments

@nopepper
Copy link

Description

Running python -m sglang.launch_server yields this error. I was running it in a container, which I'll describe below.

outlines-server-1  | Traceback (most recent call last):
outlines-server-1  |   File "<frozen runpy>", line 198, in _run_module_as_main
outlines-server-1  |   File "<frozen runpy>", line 88, in _run_code
outlines-server-1  |   File "/usr/local/lib/python3.11/site-packages/sglang/launch_server.py", line 3, in <module>
outlines-server-1  |     from sglang.srt.server import ServerArgs, launch_server
outlines-server-1  |   File "/usr/local/lib/python3.11/site-packages/sglang/srt/server.py", line 25, in <module>
outlines-server-1  |     from sglang.srt.constrained import disable_cache
outlines-server-1  |   File "/usr/local/lib/python3.11/site-packages/sglang/srt/constrained/__init__.py", line 4, in <module>
outlines-server-1  |     from outlines.fsm.json_schema import build_regex_from_object
outlines-server-1  | ImportError: cannot import name 'build_regex_from_object' from 'outlines.fsm.json_schema' (/usr/local/lib/python3.11/site-packages/outlines/fsm/json_schema.py)
outlines-server-1 exited with code 1

Reproducing

Here's the dockerfile, super simple:

FROM python:3.11
RUN pip install sglang[all]
ENTRYPOINT [ "python", "-m", "sglang.launch_server" ]

Running:

docker build  --rm -t sglang-server .
docker run sglang-server --model-path mistralai/Mistral-7B-Instruct-v0.2

Notes

I also tried this with the python 3.10 image, same issue. It also didn't work outside of docker.

@nopepper
Copy link
Author

Update: this seems to work again when installing from source, so the bug might be in the distribution.

@nbbull
Copy link

nbbull commented Feb 19, 2024

i meet the same problem

@Xingxiangrui
Copy link

+1 for this. I meet the same problem when I use llava-v1.6-mistral-7b

@crissed53
Copy link

crissed53 commented Feb 19, 2024

The error is caused by wrong outlines version (#196) in the latest release(0.1.12).

The workaround is to manually specify the version constraint of the outlines package by:

pip install "sglang[all]" "outlines<=0.0.30"

@hnyls2002
Copy link
Collaborator

This is caused by the outlines API change, and we temporarily pin the outlines' version here #196.

Thanks @crissed53.

@surak
Copy link

surak commented Feb 20, 2024

Pinning the outlines breaks up everything around it.

@MonadKai
Copy link

MonadKai commented Feb 21, 2024

Downgrade outlines to the project specified version, e.g.

# for sglang 0.1.12
pip install outlines==0.0.27

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 a pull request may close this issue.

7 participants