livepeer / go-livepeer

Official Go implementation of the Livepeer protocol
http://livepeer.org
MIT License
538 stars 168 forks source link

feat(ai): add pipelines optimization flags #3013

Closed rickstaa closed 4 months ago

rickstaa commented 4 months ago

[!WARNING] Do not merge before https://github.com/livepeer/ai-worker/pull/61.

What does this pull request do? Explain your changes. (required)

This commit adds a new OptimizationFlags field to the aiModels config so that users can forward optimization environment variables to the ai-worker for more information see https://github.com/livepeer/ai-worker/pull/61.

Specific updates (required)

How did you test each of these updates (required)

  1. Ensured the package builds.
  2. Ensured tests.sh were succesfull.
  3. Spung up off-chain broadcaster.
  4. Spung up off-chain orchestrator with SFAST optimization flag in the models configuration file.
[
    {
        "pipeline": "image-to-video",
        "model_id": "stabilityai/stable-video-diffusion-img2vid-xt-1-1",
        "price_per_unit": 3390842,
        "warm": true,
        "optimization_flags": {
            "SFAST": "true",
            "SOME": true
        }
    }
]
  1. Let the ImageToVideo container warmup and check the container logs to see that SFAST is used and the model is pre-traced.
  2. Send a ImageToVideo request to the broadcaster and checked that it stilled worked.

Does this pull request close any open issues?

No.

Checklist:

rickstaa commented 4 months ago

@yondonfu, is there a specific reason why the binary execution proceeds even when an AIModelConfig is not specified? I encountered this issue while trying to activate flags for containers that don't start warm, as I wanted to pass Optimization flags directly to the AIWorker constructor.

https://github.com/livepeer/go-livepeer/blob/1019d429eca743218fe133602b5f4344e4766308/cmd/livepeer/starter/starter.go#L534-L605

rickstaa commented 4 months ago

Requires https://github.com/livepeer/ai-worker/pull/61.

yondonfu commented 4 months ago

@rickstaa

is there a specific reason why the binary execution proceeds even when an AIModelConfig is not specified?

I think it would sense to require a config file for -aiModels now because the config file is not only used to warm models, but also for specifying prices and determining which models to advertise during capability discovery. Prior to using the config file for configuring prices and capability discovery, the config file was left as optional because the O would just try to execute any request given a model ID. But now, since models have prices and have to be explicitly advertised, the config file is necessary.

rickstaa commented 4 months ago

@rickstaa

is there a specific reason why the binary execution proceeds even when an AIModelConfig is not specified?

I think it would sense to require a config file for -aiModels now because the config file is not only used to warm models, but also for specifying prices and determining which models to advertise during capability discovery. Prior to using the config file for configuring prices and capability discovery, the config file was left as optional because the O would just try to execute any request given a model ID. But now, since models have prices and have to be explicitly advertised, the config file is necessary.

Ah thanks for the explanation. Makes sense. I will change the behavoir!