Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
studio: fetch the XPU triton wheel with --dest, not pip's -d (#10073)
Wayne Sletcher32dcc75c1620
diff --git a/studio/setup.ps1 b/studio/setup.ps1index efbbc36bcdc..1ff9b43aa30 100644--- a/studio/setup.ps1+++ b/studio/setup.ps1@@ -5507,12 +5507,14 @@ if ($stackExit -eq 0 -and $XpuIndexUrl) {$_tritonTmp = Join-Path ([System.IO.Path]::GetTempPath()) "unsloth_triton_xpu_$([guid]::NewGuid().ToString('N').Substring(0,8))"try {New-Item -ItemType Directory -Force -Path $_tritonTmp -ErrorAction SilentlyContinue | Out-Null+ # Fast-Download is an advanced function, so PowerShell binds `-d` to `-Debug`+ # instead of forwarding it to pip. Use the long `--dest` flag (#10018).if ($script:UnslothVerbose) {- Fast-Download --no-deps --only-binary=:all: -d $_tritonTmp $_tritonXpuSpec --index-url $XpuIndexUrl | ForEach-Object { Redact-InstallOutput "$_" } | Out-Host+ Fast-Download --no-deps --only-binary=:all: --dest $_tritonTmp $_tritonXpuSpec --index-url $XpuIndexUrl | ForEach-Object { Redact-InstallOutput "$_" } | Out-Host$tritonDlExit = $LASTEXITCODE$tritonDlOutput = ""} else {- $tritonDlOutput = Fast-Download --no-deps --only-binary=:all: -d $_tritonTmp $_tritonXpuSpec --index-url $XpuIndexUrl | Out-String+ $tritonDlOutput = Fast-Download --no-deps --only-binary=:all: --dest $_tritonTmp $_tritonXpuSpec --index-url $XpuIndexUrl | Out-String$tritonDlExit = $LASTEXITCODE}# The exit code alone is not enough: no wheel on disk means nothing to install from.diff --git a/tests/studio_setup_ps1/Studio.Setup.FastWrapperFlags.Tests.ps1 b/tests/studio_setup_ps1/Studio.Setup.FastWrapperFlags.Tests.ps1new file mode 100644index 00000000000..f4125eb0a08--- /dev/null+++ b/tests/studio_setup_ps1/Studio.Setup.FastWrapperFlags.Tests.ps1@@ -0,0 +1,132 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.+<#+ Fast-* wrappers are advanced PowerShell functions. Short flags such as pip's+ `-d` can bind to common parameters such as `-Debug` instead of reaching pip.+ These tests require long flags at call sites and verify `--dest` is forwarded.+#>++BeforeAll {+ . (Join-Path $PSScriptRoot 'Get-FunctionSource.ps1')++ $candidates = @(+ $env:SETUP_PS1_PATH,+ (Join-Path $PSScriptRoot '..\..\studio\setup.ps1')+ ) | Where-Object { $_ }+ $script:SetupPs1 = $candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1+ if (-not $script:SetupPs1) { throw "Could not locate studio/setup.ps1 (set SETUP_PS1_PATH)." }+ Write-Host "setup.ps1 under test: $script:SetupPs1"++ $script:SetupText = Get-Content -Raw -LiteralPath $script:SetupPs1++ # Follow the common parameters declared by the current PowerShell host.+ $script:CommonParameterNames = [System.Management.Automation.Internal.CommonParameters].GetProperties().Name++ # Collect wrapper invocations, excluding declarations and comments.+ $script:WrapperCallLines = @(+ ($script:SetupText -split "`r?`n") |+ ForEach-Object -Begin { $n = 0 } -Process {+ $n+++ [pscustomobject]@{ Number = $n; Text = $_ }+ } |+ Where-Object {+ $_.Text -match 'Fast-(Install|Uninstall|Download)\b' -and+ $_.Text -notmatch '^\s*#' -and+ $_.Text -notmatch '^\s*function\s+Fast-'+ }+ )++ function Test-BindsAsCommonParameter {+ param([Parameter(Mandatory)][string]$Token)+ # Unique matches are swallowed; ambiguous matches fail binding.+ $bare = $Token.TrimStart('-')+ if (-not $bare) { return $false }+ return [bool](@($script:CommonParameterNames | Where-Object {+ $_.StartsWith($bare, [System.StringComparison]::OrdinalIgnoreCase)+ }).Count)+ }+}++Describe 'Fast-* wrappers are advanced functions (why short flags are unsafe)' {+ It 'declares ValueFromRemainingArguments on all three wrappers' {+ foreach ($fn in @('Fast-Install', 'Fast-Uninstall', 'Fast-Download')) {+ $src = Get-FunctionSource -Path $script:SetupPs1 -Name $fn+ $src | Should -Not -BeNullOrEmpty -Because "$fn must exist to be tested"+ $src | Should -Match 'ValueFromRemainingArguments' -Because "$fn forwards its arguments verbatim"+ }+ }++ It 'swallows -d as -Debug instead of forwarding it' {+ # Match the wrappers' advanced-function parameter binding.+ function script:Probe-Args { param([Parameter(ValueFromRemainingArguments=$true)]$Args_) return , @($Args_) }++ $withShort = Probe-Args --no-deps -d 'C:\tmp' 'pkg==1.0'+ $withShort | Should -Not -Contain '-d' -Because '-d binds to the common parameter -Debug'+ $withShort.Count | Should -Be 3++ $withLong = Probe-Args --no-deps --dest 'C:\tmp' 'pkg==1.0'+ $withLong | Should -Contain '--dest' -Because 'a long flag is not a parameter-name token'+ $withLong.Count | Should -Be 4+ }+}++Describe 'No Fast-* call site passes a short flag the binder would capture (#10018)' {+ It 'finds the wrapper call sites at all' {+ # Prevent a refactor from making the scan vacuous.+ $script:WrapperCallLines.Count | Should -BeGreaterThan 10+ }++ It 'passes no single-dash flag that prefixes a common parameter' {+ $offenders = foreach ($line in $script:WrapperCallLines) {+ # Start at the wrapper name so flags on piped cmdlets are excluded.+ $call = $line.Text.Substring($line.Text.IndexOf('Fast-'))+ foreach ($m in [regex]::Matches($call, '(?<![\w-])-(?<name>[A-Za-z]{1,2})(?=\s|$)')) {+ $token = "-$($m.Groups['name'].Value)"+ if (Test-BindsAsCommonParameter -Token $token) {+ "setup.ps1:$($line.Number): '$token' binds as a common parameter -- use the long flag"+ }+ }+ }+ ($offenders -join "`n") | Should -BeNullOrEmpty+ }++ It 'fetches the XPU triton wheel with --dest' {+ $destCalls = @($script:WrapperCallLines | Where-Object { $_.Text -match 'Fast-Download' -and $_.Text -match '--dest' })+ $destCalls.Count | Should -Be 2 -Because 'the swap fetches through both the verbose and the quiet branch'+ foreach ($line in $destCalls) {+ $line.Text | Should -Match '--dest\s+\$_tritonTmp' -Because 'the wheel must land in the staged temp dir'+ }+ }+}++Describe 'Fast-Download forwards the destination through to pip' {+ BeforeAll {+ $src = Get-FunctionSource -Path $script:SetupPs1 -Name 'Fast-Download'+ if (-not $src) { throw "Function 'Fast-Download' not found in $script:SetupPs1 - cannot test the real code." }+ . ([scriptblock]::Create($src))+ }++ It 'reaches pip with --dest and the directory adjacent' {+ # Shadow the external command to capture the wrapper's arguments.+ function script:python { $script:PipArgs = @($args); return '' }+ $script:PipArgs = @()++ Fast-Download --no-deps --only-binary=:all: --dest 'C:\tmp\stage' 'triton-xpu==3.6.0' --index-url 'https://example.invalid/xpu' | Out-Null++ $script:PipArgs | Should -Contain '--dest'+ $idx = [array]::IndexOf($script:PipArgs, '--dest')+ $script:PipArgs[$idx + 1] | Should -Be 'C:\tmp\stage' -Because "pip reads the directory as the value of --dest"+ $script:PipArgs[0..2] -join ' ' | Should -Be '-m pip download'+ }++ It 'loses the directory when the short flag is used (the #10018 failure)' {+ function script:python { $script:PipArgs = @($args); return '' }+ $script:PipArgs = @()++ Fast-Download --no-deps --only-binary=:all: -d 'C:\tmp\stage' 'triton-xpu==3.6.0' --index-url 'https://example.invalid/xpu' | Out-Null++ $script:PipArgs | Should -Not -Contain '-d' -Because 'the binder took it as -Debug'+ $script:PipArgs | Should -Contain 'C:\tmp\stage'+ [array]::IndexOf($script:PipArgs, 'C:\tmp\stage') | Should -BeGreaterThan 2+ }+}