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
c001deba
Unverified
Commit
c001deba
authored
Oct 26, 2025
by
fzyzcjy
Committed by
GitHub
Oct 26, 2025
Browse files
Make bmm batch invariant injection optional (#12118)
parent
b4d2da10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
python/sglang/srt/batch_invariant_ops/batch_invariant_ops.py
python/sglang/srt/batch_invariant_ops/batch_invariant_ops.py
+9
-5
No files found.
python/sglang/srt/batch_invariant_ops/batch_invariant_ops.py
View file @
c001deba
...
@@ -524,7 +524,9 @@ def is_batch_invariant_mode_enabled():
...
@@ -524,7 +524,9 @@ def is_batch_invariant_mode_enabled():
return
_batch_invariant_MODE
return
_batch_invariant_MODE
def
enable_batch_invariant_mode
():
def
enable_batch_invariant_mode
(
enable_bmm
:
bool
=
True
,
):
global
_batch_invariant_MODE
,
_batch_invariant_LIB
,
_original_torch_bmm
global
_batch_invariant_MODE
,
_batch_invariant_LIB
,
_original_torch_bmm
if
_batch_invariant_MODE
:
if
_batch_invariant_MODE
:
return
return
...
@@ -537,11 +539,13 @@ def enable_batch_invariant_mode():
...
@@ -537,11 +539,13 @@ def enable_batch_invariant_mode():
"aten::_log_softmax"
,
_log_softmax_batch_invariant
,
"CUDA"
"aten::_log_softmax"
,
_log_softmax_batch_invariant
,
"CUDA"
)
)
_batch_invariant_LIB
.
impl
(
"aten::mean.dim"
,
mean_batch_invariant
,
"CUDA"
)
_batch_invariant_LIB
.
impl
(
"aten::mean.dim"
,
mean_batch_invariant
,
"CUDA"
)
_batch_invariant_LIB
.
impl
(
"aten::bmm"
,
bmm_batch_invariant
,
"CUDA"
)
# Also monkeypatch torch.bmm directly as a fallback
if
enable_bmm
:
_original_torch_bmm
=
torch
.
bmm
_batch_invariant_LIB
.
impl
(
"aten::bmm"
,
bmm_batch_invariant
,
"CUDA"
)
torch
.
bmm
=
bmm_batch_invariant
# Also monkeypatch torch.bmm directly as a fallback
_original_torch_bmm
=
torch
.
bmm
torch
.
bmm
=
bmm_batch_invariant
def
disable_batch_invariant_mode
():
def
disable_batch_invariant_mode
():
...
...
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