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].
Possible issue with Semantic correctness of KV caches.
The shape of KVcache for mobileVLM:
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].