Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
d2815879
Unverified
Commit
d2815879
authored
Feb 27, 2025
by
Enrique Shockwave
Committed by
GitHub
Feb 27, 2025
Browse files
Improve: Support xgrammar 0.1.14 (#3593)
parent
b0df5d24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
python/pyproject.toml
python/pyproject.toml
+1
-1
python/sglang/srt/constrained/xgrammar_backend.py
python/sglang/srt/constrained/xgrammar_backend.py
+1
-4
No files found.
python/pyproject.toml
View file @
d2815879
...
@@ -35,7 +35,7 @@ runtime_common = [
...
@@ -35,7 +35,7 @@ runtime_common = [
"torchao>=0.7.0"
,
"torchao>=0.7.0"
,
"uvicorn"
,
"uvicorn"
,
"uvloop"
,
"uvloop"
,
"xgrammar==0.1.1
0
"
,
"xgrammar==0.1.1
4
"
,
"ninja"
,
"ninja"
,
"transformers==4.48.3"
,
"transformers==4.48.3"
,
"llguidance>=0.6.15"
"llguidance>=0.6.15"
...
...
python/sglang/srt/constrained/xgrammar_backend.py
View file @
d2815879
...
@@ -19,7 +19,6 @@ from typing import List, Tuple
...
@@ -19,7 +19,6 @@ from typing import List, Tuple
import
torch
import
torch
from
xgrammar
import
(
from
xgrammar
import
(
CompiledGrammar
,
CompiledGrammar
,
Grammar
,
GrammarCompiler
,
GrammarCompiler
,
GrammarMatcher
,
GrammarMatcher
,
TokenizerInfo
,
TokenizerInfo
,
...
@@ -135,9 +134,7 @@ class XGrammarGrammarBackend(BaseGrammarBackend):
...
@@ -135,9 +134,7 @@ class XGrammarGrammarBackend(BaseGrammarBackend):
return
None
return
None
elif
key_type
==
"regex"
:
elif
key_type
==
"regex"
:
try
:
try
:
ctx
=
self
.
grammar_compiler
.
compile_grammar
(
ctx
=
self
.
grammar_compiler
.
compile_regex
(
key_string
)
Grammar
.
from_regex
(
key_string
)
)
except
RuntimeError
as
e
:
except
RuntimeError
as
e
:
logging
.
warning
(
f
"Skip invalid regex: regex=
{
key_string
}
,
{
e
=
}
"
)
logging
.
warning
(
f
"Skip invalid regex: regex=
{
key_string
}
,
{
e
=
}
"
)
return
None
return
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment