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
fef3a6b6
Unverified
Commit
fef3a6b6
authored
Nov 04, 2025
by
Ben Barsdell
Committed by
GitHub
Nov 03, 2025
Browse files
Restore torch defaults between sgl-kernel tests (#11131)
parent
173e0f70
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
sgl-kernel/tests/conftest.py
sgl-kernel/tests/conftest.py
+14
-0
sgl-kernel/tests/test_torch_defaults_reset.py
sgl-kernel/tests/test_torch_defaults_reset.py
+16
-0
No files found.
sgl-kernel/tests/conftest.py
0 → 100644
View file @
fef3a6b6
import
pytest
import
torch
# This ensures the torch defaults don't get left in modified states between
# tests (e.g., when a test fails before restoring the original value), which
# can cause subsequent tests to fail.
@
pytest
.
fixture
(
autouse
=
True
)
def
reset_torch_defaults
():
orig_default_device
=
torch
.
get_default_device
()
orig_default_dtype
=
torch
.
get_default_dtype
()
yield
torch
.
set_default_dtype
(
orig_default_dtype
)
torch
.
set_default_device
(
orig_default_device
)
sgl-kernel/tests/test_torch_defaults_reset.py
0 → 100644
View file @
fef3a6b6
import
pytest
import
torch
def
test_change_torch_defaults
():
torch
.
set_default_device
(
"cpu:0"
)
torch
.
set_default_dtype
(
torch
.
float16
)
def
test_check_torch_defaults
():
assert
torch
.
get_default_device
()
==
torch
.
device
(
"cpu"
)
assert
torch
.
get_default_dtype
()
==
torch
.
float32
if
__name__
==
"__main__"
:
pytest
.
main
([
__file__
])
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