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
infinilm
Commits
2390104c
Commit
2390104c
authored
Dec 26, 2025
by
PanZezhong
Browse files
issue/125 add pybind for paged attention cache config
parent
8cf62baa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
csrc/pybind11/cache/cache.hpp
csrc/pybind11/cache/cache.hpp
+18
-1
python/infinilm/cache/cache.py
python/infinilm/cache/cache.py
+13
-0
No files found.
csrc/pybind11/cache/cache.hpp
View file @
2390104c
...
...
@@ -30,6 +30,23 @@ inline void bind_cache(py::module &m) {
.
def
(
"__repr__"
,
[](
const
infinilm
::
cache
::
StaticKVCacheConfig
&
)
{
return
"<StaticKVCacheConfig>"
;
});
py
::
class_
<
infinilm
::
cache
::
PagedKVCacheConfig
,
infinilm
::
cache
::
CacheConfig
,
std
::
shared_ptr
<
infinilm
::
cache
::
PagedKVCacheConfig
>>
(
m
,
"PagedKVCacheConfig"
)
.
def
(
py
::
init
<
size_t
,
size_t
>
(),
py
::
arg
(
"max_kv_memory_bytes"
),
py
::
arg
(
"block_size"
)
=
16
)
.
def
(
"max_kv_memory_bytes"
,
&
infinilm
::
cache
::
PagedKVCacheConfig
::
max_kv_memory_bytes
)
.
def
(
"block_size"
,
&
infinilm
::
cache
::
PagedKVCacheConfig
::
block_size
)
.
def
(
"__repr__"
,
[](
const
infinilm
::
cache
::
PagedKVCacheConfig
&
)
{
return
"<PagedKVCacheConfig>"
;
});
}
}
// namespace infinilm::cache
\ No newline at end of file
}
// namespace infinilm::cache
python/infinilm/cache/cache.py
View file @
2390104c
...
...
@@ -11,3 +11,16 @@ class CacheConfig(_infinilm.CacheConfig):
class
StaticKVCacheConfig
(
CacheConfig
,
_infinilm
.
StaticKVCacheConfig
):
def
__init__
(
self
,
max_batch_size
:
int
=
1
,
max_cache_len
:
int
=
0
):
_infinilm
.
StaticKVCacheConfig
.
__init__
(
self
,
max_batch_size
,
max_cache_len
)
class
PagedKVCacheConfig
(
CacheConfig
,
_infinilm
.
PagedKVCacheConfig
):
def
__init__
(
self
,
max_kv_memory_bytes
:
int
,
block_size
:
int
=
16
,
):
_infinilm
.
PagedKVCacheConfig
.
__init__
(
self
,
max_kv_memory_bytes
,
block_size
,
)
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