Skip to content

Integrate "get model versions" and "download specific model version" into cpp Core with max_versions#816

Open
selenayang888 wants to merge 14 commits into
mainfrom
syang/integrate-get-model-versions-into-cpp
Open

Integrate "get model versions" and "download specific model version" into cpp Core with max_versions#816
selenayang888 wants to merge 14 commits into
mainfrom
syang/integrate-get-model-versions-into-cpp

Conversation

@selenayang888

Copy link
Copy Markdown
Contributor

Porting the changes "get model versions" and "download specific model version" from C# into C++ Core now:

  1. List all available versions of a model (e.g., to see what versions of phi-4 are published).
  2. Download and use a specific older version (e.g., for reproducibility, compatibility, or regression testing).

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Jun 18, 2026 1:25am

Request Review

@selenayang888 selenayang888 marked this pull request as ready for review June 18, 2026 01:27
Copilot AI review requested due to automatic review settings June 18, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot stopped reviewing on behalf of selenayang888 due to an error June 18, 2026 01:49
Comment on lines +881 to +882
/// @param model_alias Alias of the model (e.g. "phi-4-mini"). May be NULL to return
/// all versions of all models (subject to device/EP filtering).

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.

Is there a use-case where someone needs to find all versions of all models? That seems like a problematic thing to enable given how much data could be retrieved.

If we require the alias I assume we have no need to expose pagination which is adding a lot of complexity to the code.

If a user really really needs to get all versions for all models they can iterate each alias themselves.

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.

If we can remove the complexity from public pagination the implementation for fetching all versions of an alias or model name should be pretty similar to AzureCatalogClient::FetchModelsByIds, just with a slightly different filter.

std::vector<ModelInfo> AzureCatalogClient::FetchModelsByIds(
const std::vector<std::string>& model_ids) {
if (model_ids.empty()) {
return {};
}
auto result = FetchFilterSet(BuildModelIdFilters(model_filter_, model_ids));
if (!result) {
return {};
}
return ToModelInfos(result->models, result->region);
}

Comment on lines +885 to +886
/// @param max_versions Soft upper bound on the number of variants returned.
/// Pass 0 (or any negative value) for no cap.

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.

Is the max on the versions or the variants? This feels like a really confusing value as I can think of various permutations between version and variant.

e.g. say I have model A with CPU (v1, 2, 3) and GPU variants (v 2, 3, 4).

'latest 2 versions' could be anything that is v3 or v4 (per alias), or it could be v2 and v3 for CPU and v3 and v4 for GPU (per variant).

I'm not sure which is best though. If versioning tends to be per variant, selecting the latest X for the variant might make more sense.

/// Returned list contains existing flModel handles owned by the catalog; releasing
/// the list does not invalidate the underlying model handles.
FL_API_STATUS(GetModelVersions, _In_ const flCatalog* catalog, _In_opt_ const char* model_alias,
_In_opt_ const char* variant_name, int32_t max_versions,

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: would 'model_name' be more consistent given this value comes from Info_GetName (ModelInfo.Name) doesn't it?

/// `annotations/tags/alias` filter scopes the result to that one alias; when
/// empty, no alias filter is added and every versioned model the local hardware
/// can run is returned across all its versions.
std::vector<std::vector<CatalogFilter>> BuildAllVersionsFilters(const IEpDetector& ep_detector,

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.

Can we add a param to BuildSearchFilters for 'all versions' or 'latest only' and linclude the 'labels' filter based on that instead of duplicating the logic here?

That said, shouldn't the model name be passed in here and used in the filter if provided so all filtering is server side?

return created1 > created2;
}

int CompareCaseInsensitive(const std::string& lhs, const std::string& rhs) {

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: might be good to put this in utils/string_utils.h

/// Provided with a default `{}` body so an implementation that has not yet
/// overridden it still compiles.
virtual PagedModelInfos FetchAllVersionsByAlias(
const std::string& /*model_alias*/,

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.

Would have expected the model name to be passed in here if it can be used in the filter.

Comment on lines -292 to 409
// Subsequent pages are pinned to the region that served page 1 — a filter set
// never mixes regions (continuation tokens are region-specific).
response = http_post_response_(BuildRegionalUrl(url_prefix_, url_suffix_, *pinned_region), body);

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.

AI likes randomly deleting existing comment. Was it intentional to do so?

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.

4 participants