Skip to content

Commit

Permalink
feat(ai): account for num_inference_steps inT2I latency inference sco…
Browse files Browse the repository at this point in the history
…re calculation (#3074)

* fix(ai): Fix accuracy of T2I latency score when num_inference_steps provided

* refactor(ai): update numInferenceSteps default

This commit ensures that the same numInferenceSteps default value is
used as the one set in
https://github.com/livepeer/ai-worker/blob/31fe460a45e1d9e908d3a1bdcfdd8822c3889214/runner/app/routes/text_to_image.py#L28.

---------

Co-authored-by: Elite Encoder <[email protected]>
  • Loading branch information
rickstaa and eliteprox authored Jun 5, 2024
1 parent 6f9426b commit 6535844
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@ func submitTextToImage(ctx context.Context, params aiRequestParams, sess *AISess
balUpdate.Status = ReceivedChange
}

// TODO: Refine this rough estimate in future iterations
numImages := 1
// TODO: Refine this rough estimate in future iterations.
// TODO: Default values for the number of images and inference steps are currently hardcoded.
// These should be managed by the nethttpmiddleware. Refer to issue LIV-412 for more details.
numImages := float64(1)
if req.NumImagesPerPrompt != nil {
numImages = *req.NumImagesPerPrompt
numImages = float64(*req.NumImagesPerPrompt)
}
numInferenceSteps := float64(50)
if req.NumInferenceSteps != nil {
numInferenceSteps = float64(*req.NumInferenceSteps)
}
sess.LatencyScore = took.Seconds() / float64(outPixels) / float64(numImages)
sess.LatencyScore = took.Seconds() / float64(outPixels) / (numImages * numInferenceSteps)

return resp.JSON200, nil
}
Expand Down

0 comments on commit 6535844

Please sign in to comment.