fix(gpu-service): pick sliced candidate for slice-only instance types

This commit is contained in:
jialin
2026-07-22 15:52:17 +08:00
parent fe0bab041b
commit 9386f0872b
@@ -275,7 +275,7 @@ export const pickCandidateForAccelerator = <
>( >(
tiers: tiers:
| { | {
onceMaxRequest: { accelerator?: string }; onceMaxRequest: { accelerator?: string; acceleratorSliced?: string };
candidates?: C[] | null; candidates?: C[] | null;
}[] }[]
| undefined | undefined
@@ -305,9 +305,14 @@ export const pickCandidateForAccelerator = <
// count === 0 ? parseQuantity(tier.onceMaxRequest.accelerator) > count; this is CPU-only case. // count === 0 ? parseQuantity(tier.onceMaxRequest.accelerator) > count; this is CPU-only case.
for (const tier of sorted) { for (const tier of sorted) {
const acceleratorCount = parseQuantity(tier.onceMaxRequest?.accelerator); const acceleratorCount = parseQuantity(tier.onceMaxRequest?.accelerator);
const fits = acceleratable // Sliced mode requests a fraction of a single card, so the tier's
? acceleratorCount >= count // whole-card accelerator count (0 for a slice-only type) can't gate it;
: acceleratorCount === 0; // fit on the tier's sliced capacity instead.
const fits = sliced
? parseQuantity(tier.onceMaxRequest?.acceleratorSliced) > 0
: acceleratable
? acceleratorCount >= count
: acceleratorCount === 0;
if (!fits) continue; if (!fits) continue;
const candidate = tier.candidates?.find(hasResources); const candidate = tier.candidates?.find(hasResources);
if (candidate) return candidate; if (candidate) return candidate;