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
153 additions
and
20 deletions
+153
-20
test/infinicore/ops/isfinite.py
test/infinicore/ops/isfinite.py
+1
-1
test/infinicore/ops/isin.py
test/infinicore/ops/isin.py
+1
-1
test/infinicore/ops/isneginf.py
test/infinicore/ops/isneginf.py
+1
-1
test/infinicore/ops/isposinf.py
test/infinicore/ops/isposinf.py
+1
-1
test/infinicore/ops/kl_div.py
test/infinicore/ops/kl_div.py
+1
-1
test/infinicore/ops/kron.py
test/infinicore/ops/kron.py
+1
-1
test/infinicore/ops/kthvalue.py
test/infinicore/ops/kthvalue.py
+1
-1
test/infinicore/ops/kv_caching.py
test/infinicore/ops/kv_caching.py
+134
-0
test/infinicore/ops/l1_loss.py
test/infinicore/ops/l1_loss.py
+1
-1
test/infinicore/ops/ldexp.py
test/infinicore/ops/ldexp.py
+1
-1
test/infinicore/ops/leaky_relu.py
test/infinicore/ops/leaky_relu.py
+1
-1
test/infinicore/ops/lerp.py
test/infinicore/ops/lerp.py
+1
-1
test/infinicore/ops/linear.py
test/infinicore/ops/linear.py
+1
-2
test/infinicore/ops/local_response_norm.py
test/infinicore/ops/local_response_norm.py
+1
-1
test/infinicore/ops/log.py
test/infinicore/ops/log.py
+1
-1
test/infinicore/ops/log10.py
test/infinicore/ops/log10.py
+1
-1
test/infinicore/ops/log1p.py
test/infinicore/ops/log1p.py
+1
-1
test/infinicore/ops/log2.py
test/infinicore/ops/log2.py
+1
-1
test/infinicore/ops/log_softmax.py
test/infinicore/ops/log_softmax.py
+1
-1
test/infinicore/ops/logaddexp.py
test/infinicore/ops/logaddexp.py
+1
-1
No files found.
test/infinicore/ops/isfinite.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/isin.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/isneginf.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/isposinf.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/kl_div.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, reduction_or_None, log_target_bool_or_None)
...
...
test/infinicore/ops/kron.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: (a_shape, b_shape, a_strides_or_None, b_strides_or_None)
...
...
test/infinicore/ops/kthvalue.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/kv_caching.py
0 → 100644
View file @
784139b9
import
sys
import
os
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
TensorSpec
,
TensorInitializer
,
TestCase
,
GenericTestRunner
,
is_broadcast
,
)
# ==============================================================================
# Operator-specific configuration
# ==============================================================================
# Test cases format: (shape (bs, nkvh, seq_len, hd), strides)
_TEST_CASES_DATA
=
[
((
1
,
1
,
8
,
1
),
None
),
((
1
,
8
,
32
,
32
),
None
),
((
8
,
8
,
64
,
32
),
None
),
((
1
,
32
,
8
,
64
),
(
32768
,
1024
,
64
,
1
)),
((
4
,
8
,
32
,
16
),
(
65536
,
8192
,
256
,
16
)),
((
8
,
16
,
64
,
128
),
(
8388608
,
524288
,
8192
,
1
)),
]
# Tolerance configuration
_TOLERANCE_MAP
=
{
infinicore
.
float16
:
{
"atol"
:
0
,
"rtol"
:
0
},
infinicore
.
bfloat16
:
{
"atol"
:
0
,
"rtol"
:
0
},
infinicore
.
float32
:
{
"atol"
:
0
,
"rtol"
:
0
},
}
# Data types to test
_TENSOR_DTYPES
=
[
infinicore
.
float16
,
infinicore
.
bfloat16
,
infinicore
.
float32
]
def
parse_test_cases
():
test_cases
=
[]
for
data
in
_TEST_CASES_DATA
:
import
random
cache_shape
=
data
[
0
]
kv_shape
=
(
cache_shape
[
0
],
cache_shape
[
1
],
random
.
randint
(
1
,
cache_shape
[
2
]),
cache_shape
[
3
],
)
past_shape
=
(
cache_shape
[
0
],)
strides
=
data
[
1
]
past_length
=
random
.
randint
(
0
,
cache_shape
[
2
]
-
kv_shape
[
2
])
for
dtype
in
_TENSOR_DTYPES
:
tolerance
=
_TOLERANCE_MAP
.
get
(
dtype
,
{
"atol"
:
0
,
"rtol"
:
0
})
cache_spec
=
TensorSpec
.
from_tensor
(
cache_shape
,
strides
,
dtype
)
kv_spec
=
TensorSpec
.
from_tensor
(
kv_shape
,
None
,
dtype
)
past_kv_lengths_spec
=
TensorSpec
.
from_tensor
(
past_shape
,
None
,
infinicore
.
int64
,
init_mode
=
TensorInitializer
.
RANDINT
,
low
=
past_length
,
high
=
past_length
+
1
,
)
test_cases
.
append
(
TestCase
(
inputs
=
[
cache_spec
,
cache_spec
,
kv_spec
,
kv_spec
,
past_kv_lengths_spec
,
],
kwargs
=
{},
output_spec
=
None
,
comparison_target
=
[
0
,
1
],
tolerance
=
tolerance
,
description
=
f
"KV Caching"
,
)
)
return
test_cases
def
torch_kv_caching
(
k_cache
,
v_cache
,
k
,
v
,
past_kv_lengths
):
batch_size
,
num_kv_heads
,
_
,
head_dim
=
k_cache
.
shape
seq_len
=
k
.
shape
[
2
]
for
b
in
range
(
batch_size
):
past_len
=
past_kv_lengths
[
b
].
item
()
for
h
in
range
(
num_kv_heads
):
k_cache
[
b
,
h
,
past_len
:
past_len
+
seq_len
,
:]
=
k
[
b
,
h
,
:,
:]
v_cache
[
b
,
h
,
past_len
:
past_len
+
seq_len
,
:]
=
v
[
b
,
h
,
:,
:]
return
k_cache
,
v_cache
def
infinicore_kv_caching
(
k_cache
,
v_cache
,
k
,
v
,
past_kv_lengths
):
infinicore
.
kv_caching
(
k_cache
,
v_cache
,
k
,
v
,
past_kv_lengths
)
return
k_cache
,
v_cache
class
OpTest
(
BaseOperatorTest
):
def
__init__
(
self
):
super
().
__init__
(
"KV Caching"
)
def
get_test_cases
(
self
):
return
parse_test_cases
()
def
torch_operator
(
self
,
*
args
,
**
kwargs
):
return
torch_kv_caching
(
*
args
,
**
kwargs
)
def
infinicore_operator
(
self
,
*
args
,
**
kwargs
):
return
infinicore_kv_caching
(
*
args
,
**
kwargs
)
def
main
():
test_runner
=
GenericTestRunner
(
OpTest
)
test_runner
.
run_and_exit
()
if
__name__
==
"__main__"
:
main
()
test/infinicore/ops/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, reduction_or_None)
...
...
test/infinicore/ops/ldexp.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
# ldexp(input, other) computes input * (2**other)
...
...
test/infinicore/ops/leaky_relu.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/lerp.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/linear.py
View file @
784139b9
...
...
@@ -3,6 +3,7 @@ import sys
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
))
import
infinicore
import
torch
from
framework
import
(
BaseOperatorTest
,
...
...
@@ -12,8 +13,6 @@ from framework import (
is_broadcast
,
)
import
infinicore
# ==============================================================================
# Operator-specific configuration
# ==============================================================================
...
...
test/infinicore/ops/local_response_norm.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, size, alpha_or_None, beta_or_None, k_or_None)
...
...
test/infinicore/ops/log.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/log10.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/log1p.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/log2.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/log_softmax.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/logaddexp.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
,
...
...
Prev
1
…
18
19
20
21
22
23
24
25
26
…
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