Skip to content

Implement requirements-independent offers cache#3091

Merged
r4victor merged 24 commits intomasterfrom
pr_offers_with_availability_cache
Sep 15, 2025
Merged

Implement requirements-independent offers cache#3091
r4victor merged 24 commits intomasterfrom
pr_offers_with_availability_cache

Conversation

@r4victor
Copy link
Copy Markdown
Collaborator

Part of #3021

This PR reworks how dstack caches backend offers. Common get_offers_cached() is dropped. For most backends for which offers do not depend on requirements (or offers can be adjusted as in case with disk), it introduces ComputeWithAllOffersCached class that implements caching of all offers with availability and requirements post-filtering. This allows reusing cache when getting offers for different requirements. For cudo, vastai, kubernetes, the old behavior is preserved via ComputeWithFilteredOffersCached.

Upsides:

Downsides:

  • When cache is cold, requesting offers may be slower since backend salways collect all offers. In my testing, I observed time dstack apply -b aws --gpu H100 goes from ~15s to ~20s, time dstack apply -b gcp --gpu H100 goes from ~10s to ~15s.

This implementation is for transitioning period. The plan is to experiment with fleet selection logic considering fleet offers, and see if it works well. Then, implement requirements-independent cache for cudo, vastai (requires caching provider's API calls, which currently can be done in gpuhunt only). Then move offers collection into dstack and simplify the code.

Tested offers for all backends except for cloudrift.

r4victor and others added 23 commits September 10, 2025 10:56
…rements

Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
…vation handling

Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
…rs method

Co-authored-by: aider (bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0) <aider@aider.chat>
@r4victor r4victor requested a review from jvstme September 11, 2025 11:20

class {{ backend_name }}Compute(
# TODO: Choose ComputeWith* classes to extend and implement
# ComputeWithAllOffersCached,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) I think ComputeWithFilteredOffersCached could be a good default for the template, since it works for all backends. Guidance on how to choose between ComputeWithAllOffersCached and ComputeWithFilteredOffersCached could also be helpful, unless we expect to move away from this model before anyone contributes the next backend.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea is to drop ComputeWithFilteredOffersCached soon – all providers should implement requirements-independent cache.

@r4victor r4victor merged commit 90fc7c9 into master Sep 15, 2025
28 checks passed
@r4victor r4victor deleted the pr_offers_with_availability_cache branch September 15, 2025 07:18
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