Skip to content
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

Updates the kvcache func in TextDecoder to work with Swift6 #289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdowd7
Copy link

@jdowd7 jdowd7 commented Jan 2, 2025

Refactors this func to address the warning:

Capture of 'keyTensorPointer' with non-sendable type 'UnsafeMutableRawBufferPointer' in a @sendable closure; this is an error in the Swift 6 language mode

  • Simplified the index calculations by treating the 4D tensors as 2D (hidden_dim × seq_length)
  • Added bounds checking to prevent out-of-range access
  • Used direct array indexing with properly calculated linear indices
  • Simplified memory copying using direct pointer access for the slices

Tested in our application and its working as expected

@ZachNagengast
Copy link
Contributor

Thanks @jdowd7! Do you have any metrics on if there is a speed difference between the two implementations?

@jdowd7
Copy link
Author

jdowd7 commented Jan 2, 2025

Thanks @jdowd7! Do you have any metrics on if there is a speed difference between the two implementations?

Not yet, will benchmark and report back when I get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants