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
2390a2bc
"examples/pytorch/label_propagation/model.py" did not exist on "5de4edd1fa9ed144c8218415be85677297bbb494"
Unverified
Commit
2390a2bc
authored
Jun 26, 2025
by
Meng, Peng
Committed by
GitHub
Jun 25, 2025
Browse files
Add Tencent HunYuanMoEV1 model support (#7549)
parent
16d76b9f
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
828 additions
and
9 deletions
+828
-9
python/sglang/srt/layers/rotary_embedding.py
python/sglang/srt/layers/rotary_embedding.py
+57
-9
python/sglang/srt/models/hunyuan.py
python/sglang/srt/models/hunyuan.py
+771
-0
No files found.
python/sglang/srt/layers/rotary_embedding.py
View file @
2390a2bc
...
...
@@ -890,6 +890,43 @@ class Llama4VisionRotaryEmbedding(RotaryEmbedding):
return
query_out
.
type_as
(
query
),
key_out
.
type_as
(
key
)
class
DynamicNTKAlphaRotaryEmbedding
(
RotaryEmbedding
):
"""RotaryEmbedding extended with Dynamic NTK scaling.
Credits to the Reddit users /u/bloc97 and /u/emozilla
"""
def
__init__
(
self
,
head_size
:
int
,
rotary_dim
:
int
,
max_position_embeddings
:
int
,
base
:
int
,
is_neox_style
:
bool
,
scaling_alpha
:
float
,
dtype
:
torch
.
dtype
,
)
->
None
:
self
.
scaling_alpha
=
scaling_alpha
super
().
__init__
(
head_size
,
rotary_dim
,
max_position_embeddings
,
base
,
is_neox_style
,
dtype
)
def
_compute_cos_sin_cache
(
self
)
->
torch
.
Tensor
:
max_len
=
self
.
max_position_embeddings
base
=
self
.
base
*
self
.
scaling_alpha
**
(
self
.
rotary_dim
/
(
self
.
rotary_dim
-
2
)
)
inv_freq
=
self
.
_compute_inv_freq
(
base
)
t
=
torch
.
arange
(
max_len
,
dtype
=
torch
.
float
)
freqs
=
torch
.
einsum
(
"i,j -> ij"
,
t
,
inv_freq
)
cos
=
freqs
.
cos
()
sin
=
freqs
.
sin
()
cache
=
torch
.
cat
((
cos
,
sin
),
dim
=-
1
)
return
cache
class
MRotaryEmbedding
(
RotaryEmbedding
):
"""Rotary Embedding with Multimodal Sections."""
...
...
@@ -1234,6 +1271,17 @@ def get_rope(
)
elif
scaling_type
==
"dynamic"
:
scaling_factor
=
rope_scaling
[
"factor"
]
if
"alpha"
in
rope_scaling
:
rotary_emb
=
DynamicNTKAlphaRotaryEmbedding
(
head_size
,
rotary_dim
,
max_position
,
base
,
is_neox_style
,
rope_scaling
[
"alpha"
],
dtype
,
)
else
:
rotary_emb
=
DynamicNTKScalingRotaryEmbedding
(
head_size
,
rotary_dim
,
...
...
python/sglang/srt/models/hunyuan.py
0 → 100644
View file @
2390a2bc
This diff is collapsed.
Click to expand it.
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