Skip to content

Possible issue with the semantic correctness of KV caches. #4

Description

@eomiso

Possible issue with Semantic correctness of KV caches.

The shape of KVcache for mobileVLM:

The KV Cache size : [batch, num_kv_heads, past_seq_len, head_dim]

Current CoreML, iOS code initializes KVcache with size [1, 16, 1, 128] and fills it with zeros(src/mobilevlm/iOS/mobilevlm/mobilevlm/Core/Manager/bufferManager.swift:48). Then when the prefill happens, the shape would become [1, 16, 1 + seq_len, 128]. The prefill starts with the dummy kvcache passed on from the swift code.
If the dummy kvcache is required by the iOS, then the attention_mask should make sure that the dummy kvcache is unattended.

current attention_mask: [1, 1, 1, 1, ...] (len: curEmbed.shape[1].intValue + 1 ). This should be changed to [0, 1, 1, .... 1].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions