MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / trySkipCompute

Method trySkipCompute

tui/create.go:226–289  ·  view source on GitHub ↗

trySkipCompute handles the complex compute step with its sub-phases.

()

Source from the content-addressed store, hash-verified

224
225// trySkipCompute handles the complex compute step with its sub-phases.
226func (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

Callers 1

trySkipCurrentStepMethod · 0.95

Calls 5

setDefaultDiskSizeMethod · 0.95
NeedsGPUCountPhaseMethod · 0.80
IsSpecAvailableMethod · 0.80
VCPUOptionsMethod · 0.80
GPUCountsMethod · 0.80

Tested by

no test coverage detected