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
e8b71445
Unverified
Commit
e8b71445
authored
Oct 26, 2025
by
DarkSharpness
Committed by
GitHub
Oct 25, 2025
Browse files
[Misc] Improve the error message of failed import (#12119)
parent
4caca1ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
sgl-kernel/python/sgl_kernel/__init__.py
sgl-kernel/python/sgl_kernel/__init__.py
+13
-1
No files found.
sgl-kernel/python/sgl_kernel/__init__.py
View file @
e8b71445
import
ctypes
import
logging
import
os
import
platform
import
shutil
from
pathlib
import
Path
from
typing
import
List
import
torch
...
...
@@ -81,6 +81,8 @@ def _load_architecture_specific_ops():
logger
.
debug
(
f
"[sgl_kernel] Found files:
{
raw_matching_files
}
"
)
logger
.
debug
(
f
"[sgl_kernel] Prioritized files:
{
matching_files
}
"
)
previous_import_errors
:
List
[
Exception
]
=
[]
# Try to load from the architecture-specific directory
if
matching_files
:
ops_path
=
Path
(
matching_files
[
0
])
# Use the first prioritized file
...
...
@@ -102,6 +104,7 @@ def _load_architecture_specific_ops():
return
common_ops
except
Exception
as
e
:
previous_import_errors
.
append
(
e
)
logger
.
debug
(
f
"[sgl_kernel] ✗ Failed to load from
{
ops_path
}
:
{
type
(
e
).
__name__
}
:
{
e
}
"
)
...
...
@@ -138,6 +141,7 @@ def _load_architecture_specific_ops():
return
common_ops
except
Exception
as
e
:
previous_import_errors
.
append
(
e
)
logger
.
debug
(
f
"[sgl_kernel] ✗ Failed to load fallback from
{
alt_path
}
:
{
type
(
e
).
__name__
}
:
{
e
}
"
)
...
...
@@ -157,8 +161,13 @@ def _load_architecture_specific_ops():
logger
.
debug
(
f
"[sgl_kernel] ✓ Module file:
{
common_ops
.
__file__
}
"
)
return
common_ops
except
ImportError
as
e
:
previous_import_errors
.
append
(
e
)
logger
.
debug
(
f
"[sgl_kernel] ✗ Standard Python import failed:
{
e
}
"
)
attempt_error_msg
=
"
\n
"
.
join
(
f
"-
{
type
(
err
).
__name__
}
:
{
err
}
"
for
err
in
previous_import_errors
)
# All attempts failed
error_msg
=
f
"""
[sgl_kernel] CRITICAL: Could not load any common_ops library!
...
...
@@ -174,6 +183,9 @@ GPU Info:
Please ensure sgl_kernel is properly installed with:
pip install --upgrade sgl_kernel
Error details from previous import attempts:
{
attempt_error_msg
}
"""
logger
.
debug
(
error_msg
)
raise
ImportError
(
error_msg
)
...
...
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