Skip to content

Misc. bug: seq_rm does not support seq_id < 0, documentation claiming the value is supported #15104

@MrJackSpade

Description

@MrJackSpade

Name and Version

Applicable on Commit (fd1234c)

Operating systems

Windows

Which llama.cpp modules do you know to be affected?

libllama (core library)

Command line

Problem description & steps to reproduce

 // Removes all tokens that belong to the specified sequence and have positions in [p0, p1)
 // Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails
 // seq_id < 0 : match any sequence
 // p0 < 0     : [0,  p1]
 // p1 < 0     : [p0, inf)
 LLAMA_API bool llama_memory_seq_rm(
         llama_memory_t mem,
           llama_seq_id seq_id,
              llama_pos p0,
              llama_pos p1);

Above documentation claims that seq_id < 0 can be provided to clear all sequences in a position, however this fails due to the following ASSERT at runtime

bool llama_kv_cache_unified::seq_rm(llama_seq_id seq_id, llama_pos p0, llama_pos p1) {
    GGML_ASSERT(seq_id >= 0 && (size_t) seq_id < seq_to_stream.size());

    auto & cells = v_cells[seq_to_stream[seq_id]];
    auto & head  = v_heads[seq_to_stream[seq_id]];

    uint32_t new_head = cells.size();

First Bad Commit

This ASSERT appears to have been added as part of (225e7a1)

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions