feat: expose the loaded model version name through the public API - #1962
Merged
Conversation
fszontagh
added a commit
to fszontagh/stable-diffusion.cpp-restapi
that referenced
this pull request
Sep 11, 2026
Upstream picked up leejet/stable-diffusion.cpp#1962 - our sd_get_model_version_name is now part of the public C API surface. Bumps the pin to e06b2053 (3 commits since the previous head), which brings: - #1959 fix: preserve BF16 embedding weights for get_rows - #1961 fix: handle invalid option numbers - #1962 feat: expose the loaded model version name through the public API - our PR, upstreamed The CMakeLists.txt patch block now detects that both the header declaration and the .cpp body are already present in the fetched source and skips both patches automatically. Verified with a `grep -c sd_get_model_version_name` across include/*.h + src/*.cpp: 1 hit in the header, 1 in stable-diffusion.cpp, zero anywhere else. Consequence for future bumps: the patch block is now dead weight that only re-activates if a future refactor moves the definition out of upstream. Leaving it in as a safety net for now; can drop entirely after a few more upstream bumps confirm stability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
sd_get_model_version_name()so a library user can identify the architecture of a loaded model.The version is detected at load time and already logged, but is not reachable through the C API.
Requires a successfully loaded context -
new_sd_ctx()returnsNULLon a failed load, so this does not identify a model file without loading it. Returns"Unknown"instead ofNULLfor a null context or an unidentified model.Also adds the size guard
model_version_to_str[]was missing, matchingsampling_methods_str[]andscheduler_to_str[].Exposes the display name, not the
SDVersionenum, to keep the enum numbering out of the public ABI.Related Issue / Discussion
get_sd_version in C-API, closed by the stale bot rather than resolved.Additional Information
Verified by linking a plain C translation unit that includes only
stable-diffusion.h, then loading real checkpoints:clang-formatreports no change to the added lines.Checklist