trySkipCompute handles the complex compute step with its sub-phases.
()
| 224 | |
| 225 | // trySkipCompute handles the complex compute step with its sub-phases. |
| 226 | func (m *createModel) trySkipCompute() bool { |
| 227 | if m.presets == nil { |
| 228 | return false |
| 229 | } |
| 230 | |
| 231 | gpuType := m.config.GPUType |
| 232 | needsCount := m.specs.NeedsGPUCountPhase(gpuType) |
| 233 | |
| 234 | if !needsCount { |
| 235 | // Single-GPU type: numGPUs is always 1 |
| 236 | m.config.NumGPUs = 1 |
| 237 | m.setDefaultDiskSize() |
| 238 | if !m.specs.IsSpecAvailable(gpuType, 1) { |
| 239 | return false |
| 240 | } |
| 241 | if m.presets.VCPUs == nil { |
| 242 | return false |
| 243 | } |
| 244 | if slices.Contains(m.specs.VCPUOptions(gpuType, 1), *m.presets.VCPUs) { |
| 245 | m.config.VCPUs = *m.presets.VCPUs |
| 246 | return true |
| 247 | } |
| 248 | return false |
| 249 | } |
| 250 | |
| 251 | // Multi-GPU type: need both num-gpus and vcpus to fully skip |
| 252 | if m.presets.NumGPUs != nil && m.presets.VCPUs != nil { |
| 253 | if slices.Contains(m.specs.GPUCounts(gpuType), *m.presets.NumGPUs) && m.specs.IsSpecAvailable(gpuType, *m.presets.NumGPUs) { |
| 254 | vcpuOpts := m.specs.VCPUOptions(gpuType, *m.presets.NumGPUs) |
| 255 | if len(vcpuOpts) == 1 { |
| 256 | // Single vCPU option: auto-select it. |
| 257 | m.config.NumGPUs = *m.presets.NumGPUs |
| 258 | m.setDefaultDiskSize() |
| 259 | m.config.VCPUs = vcpuOpts[0] |
| 260 | return true |
| 261 | } |
| 262 | if slices.Contains(vcpuOpts, *m.presets.VCPUs) { |
| 263 | m.config.NumGPUs = *m.presets.NumGPUs |
| 264 | m.setDefaultDiskSize() |
| 265 | m.config.VCPUs = *m.presets.VCPUs |
| 266 | return true |
| 267 | } |
| 268 | } |
| 269 | return false |
| 270 | } |
| 271 | |
| 272 | // Only num-gpus provided |
| 273 | if m.presets.NumGPUs != nil { |
| 274 | if slices.Contains(m.specs.GPUCounts(gpuType), *m.presets.NumGPUs) && m.specs.IsSpecAvailable(gpuType, *m.presets.NumGPUs) { |
| 275 | m.config.NumGPUs = *m.presets.NumGPUs |
| 276 | m.setDefaultDiskSize() |
| 277 | // If single vCPU option, auto-select it too |
| 278 | vcpuOpts := m.specs.VCPUOptions(gpuType, *m.presets.NumGPUs) |
| 279 | if len(vcpuOpts) == 1 { |
| 280 | m.config.VCPUs = vcpuOpts[0] |
| 281 | return true |
| 282 | } |
| 283 | m.gpuCountPhase = false |
no test coverage detected