diff --git a/tools/ui/src/lib/constants/index.ts b/tools/ui/src/lib/constants/index.ts index c2749a95eb..95a9d9bbec 100644 --- a/tools/ui/src/lib/constants/index.ts +++ b/tools/ui/src/lib/constants/index.ts @@ -46,6 +46,7 @@ export * from './model-id.constants'; export * from './model-loading.constants'; export * from './models-discover.constants'; export * from './models-discover-download.constants'; +export * from './model-compatibility.constants'; export * from './huggingface.constants'; export * from './precision.constants'; export * from './pwa.constants'; diff --git a/tools/ui/src/lib/constants/model-compatibility.constants.ts b/tools/ui/src/lib/constants/model-compatibility.constants.ts new file mode 100644 index 0000000000..21ab78ae2b --- /dev/null +++ b/tools/ui/src/lib/constants/model-compatibility.constants.ts @@ -0,0 +1,32 @@ +/** + * Model memory-fit constants. + * + * Mirrors the app's compatibility check (Model+Compatibility.swift): + * budget = RAM x RAM_BUDGET_RATIO - RAM_OVERHEAD_MB + * weightBytes = fileBytes x QUANT_WEIGHT + * a file fits when weightBytes <= budget. Kept here so the estimation util and + * any caller share one source. + */ +// LLAMA-APP-REUSE: hardware compatibility budget (mirrors Model+Compatibility.swift) + +/** Bytes in one mebibyte (MiB), used to convert a file size to MB. */ +export const MIB_BYTES = 1_048_576; + +/** MB in one GB. */ +export const MB_PER_GB = 1024; + +/** Overhead multiplier applied to the file size when estimating weight memory. */ +export const QUANT_WEIGHT = 1.05; + +/** Share of RAM the app allows the model to occupy. */ +export const RAM_BUDGET_RATIO = 0.75; + +/** Fixed RAM overhead (MB) reserved for the system and KV cache. */ +export const RAM_OVERHEAD_MB = 2048; + +/** + * Memory tiers Macs ship with (GB). Tiers past 512 extrapolate Apple's step + * pattern so builds too big for any current Mac still show an honest + * requirement instead of silently omitting the line. + */ +export const MAC_MEM_TIERS = [8, 16, 24, 32, 48, 64, 96, 128, 192, 256, 512, 768, 1024]; diff --git a/tools/ui/src/lib/utils/model-compatibility.ts b/tools/ui/src/lib/utils/model-compatibility.ts index 164be26f23..18063b1976 100644 --- a/tools/ui/src/lib/utils/model-compatibility.ts +++ b/tools/ui/src/lib/utils/model-compatibility.ts @@ -9,22 +9,14 @@ * device-specific budgets are deliberately ignored - callers present the * requirement and let the user judge. */ -// LLAMA-APP-REUSE: hardware compatibility estimation - -const MIB_BYTES = 1_048_576; -const MB_PER_GB = 1024; -/** Overhead multiplier applied to the file size when estimating weight memory. */ -const QUANT_WEIGHT = 1.05; -/** Share of RAM the app allows the model to occupy. */ -const RAM_BUDGET_RATIO = 0.75; -/** Fixed RAM overhead (MB) reserved for the system and KV cache. */ -const RAM_OVERHEAD_MB = 2048; -/** - * Memory tiers Macs ship with (GB). Tiers past 512 extrapolate Apple's step - * pattern so builds too big for any current Mac still show an honest - * requirement instead of silently omitting the line. - */ -const MAC_MEM_TIERS = [8, 16, 24, 32, 48, 64, 96, 128, 192, 256, 512, 768, 1024]; +import { + MAC_MEM_TIERS, + MB_PER_GB, + MIB_BYTES, + QUANT_WEIGHT, + RAM_BUDGET_RATIO, + RAM_OVERHEAD_MB +} from '$lib/constants'; /** * Estimated runtime memory (bytes) for a model of the given file size: