Files
AIHostingTycoon/packages/game-engine/src/systems/computeSystem.ts
T
josh fc1f371c8c
CI / build-and-push (push) Successful in 29s
Overhaul rack system with split FLOPS, VRAM, cooling, interconnect, and multi-vendor SKUs
Expand from 10 to 18 rack SKUs across NVIDIA, AMD, and custom ASIC vendors, each with
distinct training vs inference FLOPS, VRAM capacity, cooling requirements, and interconnect
technology. Adds cooling hierarchy (air/liquid/immersion) that gates rack deployment, VRAM
requirements that gate model training by generation, interconnect multipliers for distributed
training scaling, and PUE-based energy cost reduction for advanced cooling. Includes save
migration from v4 to v5, 6 new research nodes, and UI updates showing split compute stats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-25 02:27:03 -04:00

62 lines
2.1 KiB
TypeScript

import type { GameState, ComputeState, InfrastructureState } from '@ai-tycoon/shared';
import { FLOPS_TO_TOKENS_MULTIPLIER } from '@ai-tycoon/shared';
export interface CapacityResult {
totalFlops: number;
totalTrainingFlops: number;
totalInferenceFlops: number;
totalVramGB: number;
trainingAllocation: number;
inferenceAllocation: number;
effectiveTrainingFlops: number;
effectiveInferenceFlops: number;
tokensPerSecondCapacity: number;
}
export function computeCapacity(state: GameState, infrastructure: InfrastructureState): CapacityResult {
const { totalTrainingFlops, totalInferenceFlops, totalVramGB } = infrastructure;
const trainingAllocation = state.compute.trainingAllocation;
const inferenceAllocation = 1 - trainingAllocation;
// Training hardware can do inference at ~50% efficiency
// Inference hardware can do training at ~30% efficiency (no NVLink, poor scaling)
const effectiveTrainingFlops =
totalTrainingFlops * trainingAllocation +
totalInferenceFlops * trainingAllocation * 0.3;
const effectiveInferenceFlops =
totalInferenceFlops * inferenceAllocation +
totalTrainingFlops * inferenceAllocation * 0.5;
const tokensPerSecondCapacity = effectiveInferenceFlops * FLOPS_TO_TOKENS_MULTIPLIER;
return {
totalFlops: totalTrainingFlops + totalInferenceFlops,
totalTrainingFlops,
totalInferenceFlops,
totalVramGB,
trainingAllocation,
inferenceAllocation,
effectiveTrainingFlops,
effectiveInferenceFlops,
tokensPerSecondCapacity,
};
}
export function finalizeCompute(capacity: CapacityResult, totalTokenDemand: number): ComputeState {
const inferenceUtilization = capacity.tokensPerSecondCapacity > 0
? Math.min(1, totalTokenDemand / capacity.tokensPerSecondCapacity)
: (totalTokenDemand > 0 ? 1 : 0);
return {
...capacity,
tokensPerSecondDemand: totalTokenDemand,
inferenceUtilization,
};
}
export function processCompute(state: GameState, infrastructure: InfrastructureState): ComputeState {
const cap = computeCapacity(state, infrastructure);
return finalizeCompute(cap, state.compute.tokensPerSecondDemand);
}