Studio: classify local video pipelines, harden video preflight, and gate custom-root sd.cpp removal on ownership

- _local_model_task now tags a local diffusers pipeline that resolves to a video
  family (LTX / Wan / Hunyuan) as text-to-video, mirroring the cached-repo
  _cached_repo_task, so supported local video pipelines surface in the Video
  On-Device picker instead of being routed to the Images picker where the image
  loader rejects them. Gated on _local_is_diffusers so only a real loadable
  pipeline dir reaches the video check.
- Video validate_load_request now rejects a local pipeline pick whose directory has
  no model_index.json before the GPU handoff, mirroring the image loader, so a bad
  local pipeline can no longer evict the resident model and only then fail deep in
  from_pretrained.
- The custom/env-mode uninstall now removes a sibling stable-diffusion.cpp only when
  it carries the Studio owner marker. install_sd_cpp_prebuilt writes the canonical
  .unsloth-studio-owned marker on install; uninstall.sh and uninstall.ps1 keep any
  unowned checkout (a user's own git clone of stable-diffusion.cpp beside a custom
  Studio root is no longer deleted). A pre-marker Studio build is left behind rather
  than a user file removed.

Adds regression tests: local video pipeline tagged text-to-video (and a video-named
non-pipeline dir stays untagged so it can never trigger a doomed pipeline load), the
video local-pipeline preflight rejection, the install ownership marker, and the
uninstall keeping an unowned sibling while removing an owned one.
This commit is contained in:
Daniel Han 2026-07-07 03:15:07 +00:00
commit d36aeb54f3
9 changed files with 98 additions and 4 deletions

View file

@ -383,10 +383,15 @@ function Uninstall-UnslothStudio {
# Native diffusion (stable-diffusion.cpp) for a custom/env-mode Studio installs beside
# the root at <parent>\stable-diffusion.cpp -- find_sd_cpp_binary resolves it from
# UNSLOTH_STUDIO_HOME.parent (sd_cpp_engine.py) -- so removing only the root leaves the
# build behind. Derive and remove the sibling, guarding the parent path the same way.
# build behind. Only remove a sibling Studio installed: <parent> is a user-chosen dir
# and "stable-diffusion.cpp" is exactly what a git clone of leejet/stable-diffusion.cpp
# produces, so require our owner marker (written by install_sd_cpp_prebuilt) before rm,
# and keep any unowned checkout. Guard the derived parent path the same way.
$customSdCpp = Join-Path (Split-Path -LiteralPath $r -Parent) "stable-diffusion.cpp"
if (_IsUnsafeRoot $customSdCpp) {
_Substep "refusing to remove unsafe path: $customSdCpp" "Yellow"
} elseif ((Test-Path -LiteralPath $customSdCpp) -and -not (Test-Path -LiteralPath (Join-Path $customSdCpp ".unsloth-studio-owned") -PathType Leaf)) {
_Substep "keeping sd.cpp without Studio owner marker: $customSdCpp" "Yellow"
} else {
_RemovePath $customSdCpp
}

View file

@ -213,10 +213,16 @@ _custom_studio_roots | while IFS= read -r _custom_root; do
# Native diffusion (stable-diffusion.cpp) for a custom/env-mode Studio installs beside
# the root at <parent>/stable-diffusion.cpp -- find_sd_cpp_binary resolves it from
# UNSLOTH_STUDIO_HOME.parent (sd_cpp_engine.py) -- so removing only the root leaves the
# build behind. Derive and remove the sibling, guarding the parent path the same way.
# build behind. Only remove a sibling Studio installed: <parent> is a user-chosen dir
# and "stable-diffusion.cpp" is exactly what `git clone` of leejet/stable-diffusion.cpp
# produces, so require our owner marker (written by install_sd_cpp_prebuilt) before rm,
# and keep any unowned checkout. A pre-marker Studio build is left behind, never a user
# file deleted. Guard the derived parent path the same way.
_custom_sd_cpp="$(dirname "$_custom_root")/stable-diffusion.cpp"
if _is_unsafe_root "$_custom_sd_cpp"; then
echo " refusing to remove unsafe path: $_custom_sd_cpp" >&2
elif [ -e "$_custom_sd_cpp" ] && [ ! -f "$_custom_sd_cpp/.unsloth-studio-owned" ]; then
echo " keeping sd.cpp without Studio owner marker: $_custom_sd_cpp" >&2
else
_remove_path "$_custom_sd_cpp"
fi