8000 feat: Hybrid unified/recurrent cache by gabe-l-hart · Pull Request #13276 · ggml-org/llama.cpp · GitHub
[go: up one dir, main page]

Skip to content

feat: Hybrid unified/recurrent cache #13276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0e9f0e0
tests: Initial unit tests for memory hierarchy
gabe-l-hart May 20, 2025
b656613
build: Add build step for test-memory on non-windows builds
gabe-l-hart May 20, 2025
9a15f27
fix(tests): Fix constructors in tests for signature changes after rebase
gabe-l-hart May 27, 2025
d74d76a
tests(wip): More robust test for unified cache
gabe-l-hart May 23, 2025
114f2ce
feat: Add can_seq_rm API to llama_kv_cache API
gabe-l-hart May 27, 2025
13efcf3
feat: Move layer_filter_cb up to llama_kv_cache
gabe-l-hart May 20, 2025
6625248
feat: Add layer filter to recurrent cache
gabe-l-hart May 20, 2025
76771e8
feat: Initial implementation of llama_kv_cache_hybrid
gabe-l-hart May 20, 2025
f031fb8
feat: Add llama_model_is_hybrid API call
gabe-l-hart May 9, 2025
298e147
feat: Add c++ side constants for attention layer indices hparam
gabe-l-hart May 9, 2025
f472373
feat: Add support for distinguishing recurrent vs non-recurrent layer…
gabe-l-hart May 9, 2025
404783b
feat: Auto-fill hparams.recurrent_layer_arr based on whether the mode…
gabe-l-hart May 9, 2025
53ef2d4
feat: Instantiate hybrid cache for hybrid models (currently none)
gabe-l-hart May 20, 2025
e6ff93a
refactor: rename *_is_hybrid -> *_is_hybrid_recurrent
gabe-l-hart May 20, 2025
226955b
fix: Fix indexing into k_l for recurrent cache with filter
gabe-l-hart May 20, 2025
1fb08da
fix: Use per-layer sizing everywhere in kv caches
gabe-l-hart May 14, 2025
04fe482
fix: Remove unused kv cache methods after rebase
gabe-l-hart May 23, 2025
db9a618
fix(tests): Fix constructors in tests for signature changes after rebase
gabe-l-hart May 23, 2025
8aee2e7
feat: Add split_equal to init(...) signature
gabe-l-hart May 27, 2025
a4cc4aa
fix: Overhaul hybrid cache for refactor part3 (::init interface)
gabe-l-hart May 27, 2025
58994f6
tests(wip): Comment out broken test for now and fix other constructor…
gabe-l-hart May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: rename *_is_hybrid -> *_is_hybrid_recurrent
The implementation of the hybrid cache intentionally does not specify the
types of the child caches, so there was a naming mismatch with these
predicate functions that used "hybrid" to imply "hybrid recurrent."

Branch: HybridCache

Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
  • Loading branch information
gabe-l-hart committed May 27, 2025
commit e6ff93a201a664b775d3406cc46e8dc60d2f1c85
2 changes: 1 addition & 1 deletion include/llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ extern "C" {
LLAMA_API bool llama_model_is_recurrent(const struct llama_model * model);

// Returns true if the model is hybrid-recurrent (like Jamba, Bamba, etc.)
LLAMA_API bool llama_model_is_hybrid(const struct llama_model * model);
LLAMA_API bool llama_model_is_hybrid_recurrent(const struct llama_model * model);

// Returns 0 on success
LLAMA_API uint32_t llama_model_quantize(
Expand Down
2 changes: 1 addition & 1 deletion src/llama-arch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ bool llm_arch_is_recurrent(const llm_arch & arch) {
}
}

bool llm_arch_is_hybrid(const llm_arch & arch) {
bool llm_arch_is_hybrid_recurrent(const llm_arch & arch) {
// TODO: There are currently no hybrid models! Once there are, this will be
// the place to identify them
switch (arch) {
Expand Down
2 changes: 1 addition & 1 deletion src/llama-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,4 @@ llm_arch llm_arch_from_string(const std::string & name);
const llm_tensor_info & llm_tensor_info_for(llm_tensor tensor);

bool llm_arch_is_recurrent(const llm_arch& arch);
bool llm_arch_is_hybrid(const llm_arch& arch);
bool llm_arch_is_hybrid_recurrent(const llm_arch& arch);
6 changes: 3 additions & 3 deletions src/llama-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13210,7 +13210,7 @@ llama_memory_i * llama_model::create_memory(const llama_memory_params & params,
// checks
default:
{
if (llm_arch_is_hybrid(arch)) {
if (llm_arch_is_hybrid_recurrent(arch)) {
// make vectors of recurrent and non-recurrent layer indices
std::vector<size_t> recurrent_layers;
std::vector<size_t> unified_layers;
Expand Down Expand Up @@ -13859,8 +13859,8 @@ bool llama_model_is_recurrent(const llama_model * model) {
return llm_arch_is_recurrent(model->arch);
}

bool llama_model_is_hybrid(const llama_model * model) {
return llm_arch_is_hybrid(model->arch);
bool llama_model_is_hybrid_recurrent(const llama_model * model) {
return llm_arch_is_hybrid_recurrent(model->arch);
}

const std::vector<std::pair<std::string, ggml_tensor *>> & llama_internal_get_tensor_map(const llama_model * model) {
Expand Down
0