-
Notifications
You must be signed in to change notification settings - Fork 135
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
shutdown (reason: CPU time limit reached) #2
Comments
Thanks for reporting @KristianRykkje - we're seeing a couple of other reports about this. Will get back when I have more info! |
@KristianRykkje reporting back: On the hosted cloud platform, CPU time is currently limited on edge functions to 100ms on the free tier - but note this is talking about actual time executing instructions on the CPU, not the total wall-clock time. Looks like this CPU limit is reached before all your embeddings finished generating. To solve this I would first try adjusting the batch size on the embed trigger to somewhere in the 1-5 range - hopefully this will allow the embedding generation to complete before hitting the limit.
|
I lowered the batch size in this repo to 5 to help address this: #5 Going to close this for now, but feel free to report back and let me know if this solved the issue for you. |
@KristianRykkje sorry to hear that didn't fix it - I'm surprised a batch size of 1 continued to fail. I'll take a further look to see if I can understand why. As for what the problem is - did my explanation about CPU limits above make sense? You're unfortunately hitting those limits during inference which causes the Edge Function to exit early. I'm going to continue looking into this to see why a batch size of even 1 still fails. |
@gregnr thank you for reopening the issue. I am very much looking forward to taking it to production use :) No sorry, I think I was confused with the problem maybe being the trigger or the edge function. You of course wrote that it was the edge function so that's my bad. 😅 |
@KristianRykkje our edge function team has adjusted the way CPU limits are enforced which I'm hoping will fix this issue. Would you mind redeploying your edge functions and letting me know if you continue experiencing the CPU limit? |
@gregnr Thanks for the awesome tutorial Greg. Unfortunately I just ran the edge function by following the video and even set it to 2 and still hitting the CPU limit. |
This is the log @gregnr :
|
I still get the Any ideas how I can fix it? Or is it a bug? The image is from a tried batching with 1, I tried with 5 as well. |
I am getting the exact same issue. I have a pro subscription so not sure what else i can do. |
Still getting this issue. I'm trying to figure out how to incorporate this PR to make it work but there is no clear direction on how to achieve either tweaking the limits or making this code work without rewriting the logic completely. For my use case I actually want to upload documents myself and not users. So I'll just proceed to do embedding locally on-the-fly, but from my brief research there seems to be no way to get around this issue without taking the embedding outside of edge functions. |
Hi @gregnr. I researched this and my information may be useful. First of all, I updated xenova/transformers from 2.6.1 to 2.13.4. Then I tried to compare batch size 1 and 10. When using 1 I got the next error |
Thanks everyone for reporting. @Skrekliam - this CDN error is interesting (never seen this one yet). Let's open a new issue for this and discuss there if it persists. With respect to CPU limits, I'm currently working with the edge function team to see what other options are available - thanks for your patience. |
I migrated my function that was running into CPU limits to Deno deploy and it seems to be working well. For what it's worth. |
this is what i have experienced. for my use case, i make a network call to openai for embeddings and was able to resolve it. |
Hi @sreeshas Could you please share the code snippets from Thanks! |
Hi @gregnr - amazing tutorial - thank you! I am developing this locally and have run into the exact same issues as everyone else: "CPU time limit reached." I am on the pro plan. I have tried adjusting the batch size to 1, but this also has not worked. Everything else up to this point is working as expected. The only problem is this embedding function timing out. Just wanted to check if there is a fix for this? |
Was there any outcome from the discussion with the edge functions team? |
Hey folks, thanks for your patience (and thanks for sharing @jmn, @sreeshas, @johnonline35). The edge function team is working on a way to perform inference natively within the runtime itself, which means faster load times (ie. because models can be cached), faster inference (inference is performed natively), and less CPU usage. There is experimental support in the latest versions. Since these are early stages, definitely consider this version of the API unstable and likely to change. Mainly just wanted to provide an update so that you know what's coming up. I'll continue to post updates as things stabilize. In the mean time if you're in a crunch to get this working ASAP, @sreeshas's suggestion of using a third party embedding API (like OpenAI) should work well. OpenAI's latest models can shorten output dimensions, which means you can continue to use a smaller dimension size if that's important to you (or you can take advantage of faster vector search techniques like adaptive retrieval - see the linked post for more details!). |
Hi everyone, and thank you @gregnr for the fantastic workshop! I have been building on this project locally for the past few weeks. I had no problems with CPU time limit, even after increasing the length of my segments. However, yesterday, I decided to move from local to hosted, following the "🚀 Going to prod" steps at the end. I immediately encountered the CPU time limit, which persists when I switch back to local development. I'm a stuck with it! I'm going to follow the suggestion to try OpenAI's latest models as a workaround. I thought it was too much of a coincidence that the issue cropped up when moving to hosted, so hoping this nugget of info is helpful. 😊 |
Hi, I'm facing the same issue but running completely local. I'd follow the video, doing a complete project from scratch and also clone this repo.
I'd also try to just return a const generateEmbedding = await pipeline(
'feature-extraction',
'Supabase/gte-small'
); I have a GPU in my local machine that I already did run LLMs and other tools, everything worked well. But when using the |
Good news everyone, the native Supabase inference engine is now available 🚀 This means:
Background/recap
How to upgradeThe exact changes needed to use these APIs can be found in this PR: tl;dr
I'm going to close this issue now, but please do reach out if you continue to experience CPU limits. |
Hi @gregnr, first of all thanks for the great video and high quality codes! Unfortunately this error still persists after using the Edge-Runtime's Supabase.ai API from CLI with batch set to 3. What's more, I'm getting another error that says We intent to use this codebase in production, but are a little worried about this. Can you reopen the issue and possibly ask them for a solution? Using supabase-edge-runtime-1.59.0 (compatible with Deno v1.45.2) |
@JanDoeTian Can you try deploying your function to a Supabase project? Do you still get the same CPU time limit error? Also, how many records per batch you got? |
Hi @JanDoeTian and future readers,
|
Hey Kelly, Thank you so much for the detailed explanation & insights, I gave it a detailed read and really enjoyed it. There is something I disagree with you, correct me if I'm wrong because I'm not expert. You mentioned: I guess what troubled me a little is that the author of this repo manages to run edge function with the given dataset sucessfully but when I deploy the exact same codebase it fails. Is there anyway to push Supabase team to change their pricing model on the edge function in a way to allow a flexible CPU-time limit? Because it seems that using Automated recover jobs are an anti-pattern. Best. |
Hi Laktek, @laktek I'm running with only 1-row and still observing cpu-time limit. I have run a few more experiments and have some observations to share:
|
Hi @JanDoeTian
If something happens, like in your case by CPU limit exceed or other kind of fail (network, memory etc...) we may lost this particular section. So my point was about how we can deal with fails, because they will always occur and our system should be prepared to recover unprocessed sections. The current use case is about document embedding but I already did applied the same strategies in other kind of situations, like document conversion, image extraction, etc...
It can occurs when we try to invoke a lot of requests at same time, I'd face the same issues while I was embedding on self-host (with GPU support). Using the strategies that I mentioned before I could process a lot of embeddings more than 1 million. |
Thanks Kelly, it makes sense, appreciate the insights from your experiences. I guess I'll use a separate table to do embedding and move the succesful ones to the destination table! |
Hi @JanDoeTian, I found some useful information about the following question:
In this issue supabase/edge-runtime#408 , Nyannyacha did explain about how edge functions are handled in dev. |
Bug report
Describe the bug
First of all, thank you for this great resource!
Trying to follow along the video you posted a few days ago, but when I upload a md file and the edge functions start I get a
shutdown (reason: CPU time limit reached)
I am using the same rome (sample_files) you used in the video.
One key difference is that I am not running it locally, but in the cloud (in supabase.com)
To Reproduce
npx supabase db push
npm run dev
Expected behavior
To not throw a warning and shutdown before all the rows has been processed.
Screenshots
System information
Additional context
The text was updated successfully, but these errors were encountered: