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
jerrrrry
infinicore
Commits
784139b9
Unverified
Commit
784139b9
authored
Feb 13, 2026
by
thatPepe
Committed by
GitHub
Feb 13, 2026
Browse files
Merge pull request #990 from InfiniTensor/demo131
Demo-131 Cuda graph with optimized paged attention
parents
3c8fb3c0
1d6527cb
Changes
582
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
146 additions
and
22 deletions
+146
-22
test/infinicore/ops/rope.py
test/infinicore/ops/rope.py
+2
-4
test/infinicore/ops/rot90.py
test/infinicore/ops/rot90.py
+1
-1
test/infinicore/ops/round.py
test/infinicore/ops/round.py
+1
-1
test/infinicore/ops/rrelu.py
test/infinicore/ops/rrelu.py
+1
-1
test/infinicore/ops/scaled_dot_product_attention.py
test/infinicore/ops/scaled_dot_product_attention.py
+1
-1
test/infinicore/ops/scatter.py
test/infinicore/ops/scatter.py
+1
-1
test/infinicore/ops/scatter_add.py
test/infinicore/ops/scatter_add.py
+1
-1
test/infinicore/ops/scatter_reduce.py
test/infinicore/ops/scatter_reduce.py
+1
-1
test/infinicore/ops/select_op.py
test/infinicore/ops/select_op.py
+1
-1
test/infinicore/ops/select_scatter.py
test/infinicore/ops/select_scatter.py
+1
-1
test/infinicore/ops/selu.py
test/infinicore/ops/selu.py
+1
-1
test/infinicore/ops/sgn.py
test/infinicore/ops/sgn.py
+1
-1
test/infinicore/ops/sign.py
test/infinicore/ops/sign.py
+1
-1
test/infinicore/ops/signbit.py
test/infinicore/ops/signbit.py
+1
-1
test/infinicore/ops/silu.py
test/infinicore/ops/silu.py
+1
-1
test/infinicore/ops/silu_and_mul.py
test/infinicore/ops/silu_and_mul.py
+126
-0
test/infinicore/ops/sinh.py
test/infinicore/ops/sinh.py
+1
-1
test/infinicore/ops/slice_scatter.py
test/infinicore/ops/slice_scatter.py
+1
-1
test/infinicore/ops/slogdet.py
test/infinicore/ops/slogdet.py
+1
-1
test/infinicore/ops/smooth_l1_loss.py
test/infinicore/ops/smooth_l1_loss.py
+1
-1
No files found.
test/infinicore/ops/rope.py
View file @
784139b9
...
...
@@ -3,7 +3,8 @@ import sys
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
infinicore
from
infinicore.nn.functional
import
RopeAlgo
import
torch
from
framework
import
(
BaseOperatorTest
,
...
...
@@ -12,9 +13,6 @@ from framework import (
GenericTestRunner
,
is_broadcast
,
)
from
infinicore.nn.functional
import
RopeAlgo
import
infinicore
# ==============================================================================
# Operator-specific configuration
...
...
test/infinicore/ops/rot90.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/round.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/rrelu.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/scaled_dot_product_attention.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (q_shape, k_shape, v_shape, attn_mask_or_None, dropout_p, is_causal)
...
...
test/infinicore/ops/scatter.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/scatter_add.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/scatter_reduce.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/select_op.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (input_shape, input_strides_or_None, dim, index)
...
...
test/infinicore/ops/select_scatter.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/selu.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/sgn.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None)
...
...
test/infinicore/ops/sign.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None)
...
...
test/infinicore/ops/signbit.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (in_shape, in_strides_or_None)
...
...
test/infinicore/ops/silu.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/silu_and_mul.py
0 → 100644
View file @
784139b9
import
sys
import
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
,
is_broadcast
,
)
# ==============================================================================
# Operator-specific configuration
# ==============================================================================
# Test cases format: (input_shape)
# The operator splits the last dimension: Input (..., 2*d) -> Output (..., d)
_TEST_CASES_DATA
=
[
(
2
,
4
),
(
1024
,
1024
),
(
2
,
4
,
8
),
(
1
,
22016
),
(
2
,
4
,
256
),
(
2
,
4
,
16
,
256
),
]
# Tolerance configuration for different precisions
_TOLERANCE_MAP
=
{
infinicore
.
float16
:
{
"atol"
:
1e-3
,
"rtol"
:
1e-3
},
infinicore
.
float32
:
{
"atol"
:
1e-5
,
"rtol"
:
1e-5
},
infinicore
.
bfloat16
:
{
"atol"
:
5e-3
,
"rtol"
:
1e-2
},
}
_TENSOR_DTYPES
=
[
infinicore
.
float16
,
infinicore
.
bfloat16
,
infinicore
.
float32
]
def
parse_test_cases
():
"""
Parse SiLUAndMul test case data.
Input shape: [..., 2*d], Output shape: [..., d]
Note: In-place is not supported due to shape mismatch between input and output.
"""
test_cases
=
[]
for
input_shape
in
_TEST_CASES_DATA
:
# Calculate output shape based on SwiGLU logic
output_shape
=
list
(
input_shape
)
output_shape
[
-
1
]
//=
2
output_shape
=
tuple
(
output_shape
)
for
dtype
in
_TENSOR_DTYPES
:
tolerance
=
_TOLERANCE_MAP
.
get
(
dtype
,
{
"atol"
:
1e-5
,
"rtol"
:
1e-4
})
input_spec
=
TensorSpec
.
from_tensor
(
input_shape
,
None
,
dtype
)
output_spec
=
TensorSpec
.
from_tensor
(
output_shape
,
None
,
dtype
)
# Case 1: Functional style (allocates new memory for output)
test_cases
.
append
(
TestCase
(
inputs
=
[
input_spec
],
kwargs
=
{},
output_spec
=
None
,
comparison_target
=
None
,
tolerance
=
tolerance
,
description
=
f
"SiLUAndMul_Functional_
{
dtype
}
"
,
)
)
# Case 2: Explicit output tensor style (uses pre-allocated buffer)
test_cases
.
append
(
TestCase
(
inputs
=
[
input_spec
],
kwargs
=
None
,
output_spec
=
output_spec
,
comparison_target
=
"out"
,
tolerance
=
tolerance
,
description
=
f
"SiLUAndMul_OutParam_
{
dtype
}
"
,
)
)
return
test_cases
class
OpTest
(
BaseOperatorTest
):
"""SiLUAndMul operator test (SwiGLU activation)"""
def
__init__
(
self
):
super
().
__init__
(
"SiLUAndMul"
)
def
get_test_cases
(
self
):
return
parse_test_cases
()
def
torch_operator
(
self
,
input
,
out
=
None
,
**
kwargs
):
"""
PyTorch SwiGLU reference implementation:
Formula: SiLU(gate) * up, where [gate, up] = split(input)
"""
d
=
input
.
shape
[
-
1
]
//
2
# Split the last dimension into two equal parts
gate
,
up
=
torch
.
split
(
input
,
[
d
,
d
],
dim
=-
1
)
result
=
torch
.
nn
.
functional
.
silu
(
gate
)
*
up
if
out
is
not
None
:
out
.
copy_
(
result
)
return
out
return
result
def
infinicore_operator
(
self
,
input
,
out
=
None
,
**
kwargs
):
"""InfiniCore SiLUAndMul implementation wrapper"""
import
infinicore.nn.functional
as
F
return
F
.
silu_and_mul
(
input
,
out
=
out
)
def
main
():
"""Main entry point for the test runner"""
runner
=
GenericTestRunner
(
OpTest
)
runner
.
run_and_exit
()
if
__name__
==
"__main__"
:
main
()
test/infinicore/ops/sinh.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/slice_scatter.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
...
...
test/infinicore/ops/slogdet.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (matrix_shape, strides_or_None)
...
...
test/infinicore/ops/smooth_l1_loss.py
View file @
784139b9
...
...
@@ -3,8 +3,8 @@ import os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
torch
import
infinicore
import
torch
from
framework
import
BaseOperatorTest
,
TensorSpec
,
TestCase
,
GenericTestRunner
# Test cases format: (input_shape, target_shape, input_strides_or_None, beta_or_None, reduction_or_None)
...
...
Prev
1
…
22
23
24
25
26
27
28
29
30
Next
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