Skip to content

Commit

Permalink
fix(ai): improve selection algorithm
Browse files Browse the repository at this point in the history
This commit modifies the selection algorithm to continue retrying for a
duration of one second instead of stopping after four attempts. This
change addresses issues encountered with the current algorithm's
performance in environments with 15 nodes on the network, ensuring more
robust and reliable operation until further optimizations can be
implemented.
  • Loading branch information
rickstaa committed Apr 23, 2024
1 parent 865314d commit a69500c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/http"
"path/filepath"
"strings"
"time"

"github.com/livepeer/ai-worker/worker"
"github.com/livepeer/go-livepeer/clog"
Expand All @@ -21,7 +22,7 @@ import (
"github.com/livepeer/lpms/stream"
)

const maxProcessingRetries = 4
const maxProcessingRetryDuration = 500 * time.Millisecond
const defaultTextToImageModelID = "stabilityai/sdxl-turbo"
const defaultImageToImageModelID = "stabilityai/sdxl-turbo"
const defaultImageToVideoModelID = "stabilityai/stable-video-diffusion-img2vid-xt"
Expand Down Expand Up @@ -312,7 +313,8 @@ func processAIRequest(ctx context.Context, params aiRequestParams, req interface
var resp *worker.ImageResponse

tries := 0
for tries < maxProcessingRetries {
retryDuration := time.Now().Add(maxProcessingRetryDuration)
for time.Now().Before(retryDuration) {
tries++

sess, err := params.sessManager.Select(ctx, cap, modelID)
Expand Down

0 comments on commit a69500c

Please sign in to comment.