How titaniummonkey/llm_hardware_calculator works
Project type and purpose
• This is a single-page web application (SPA) built with React, TypeScript, Tailwind CSS, and Vite.
• Purpose: Provide a VRAM and storage requirements calculator for large language models (LLMs), fetching metadata from the Hugging Face API or accepting manual parameters.
File structure
• Top-level files show it’s a frontend project (package.json, Vite configs, ESLint, Tailwind).
• src/ contains:
• App.tsx and main.tsx – application entry point and React root
• components/ – UI components (ModelInput, ManualInput, RequirementsDisplay, Calculator, etc.)
• utils/ – calculation and data-extraction logic
• types/ – TypeScript interfaces (model parameters)
• No server or backend folder: all processing runs in the browser, using fetch to call external services.
README for additional insights
• Confirms tech stack (React 18, TS, Tailwind, Vite) and key modules (Model Input, Manual Input, Calculation Engine, GPU Compatibility).
• Describes runtime behavior: real-time updates, API key support, multi-GPU logic, overhead calculations.
Main components and interactions
a. Frontend Application
• Browser (client) loading a static bundle served by Vite or any static host
• React App container (App.tsx)
• UI Components:
• ModelInput: handles Hugging Face URL/key input and calls Hugging Face REST API
• ManualInput: user-entered LLM parameters
• Calculator/Calculation Engine: core logic (in utils) computing VRAM/storage and GPU compatibility
• RequirementsDisplay & GpuCompatibilityList: render results
• ThemeProvider and layout / styling modules (Tailwind CSS)
b. External Services
• Hugging Face API – REST endpoint for model metadata
c. Data Flow
1. User enters a Hugging Face link & optional API key in ModelInput
2. App dispatches fetch() to Hugging Face API → returns model size, quantization, context length
3. or User enters parameters in ManualInput
4. Both paths pass data to Calculation Engine (utils/calculationUtils.ts)
5. Calculation Engine uses extractionUtils, formatUtils, types/model.ts to produce VRAM & storage numbers and candidate GPU lists
6. Results passed to RequirementsDisplay and GpuCompatibilityList for rendering
Architectural patterns & design principles
• Component-based UI (React) separating presentation (components) from logic (utils).
• Unidirectional data flow: Props/state flow down, callbacks bubble up.
• Single responsibility: each component has a clear domain (input vs. display).
• Layered separation:
• Presentation layer (components)
• Business logic layer (calculation/utils)
• API integration layer (fetch in ModelInput)