@@ -5,7 +5,6 @@ import {fork} from "node:child_process";
55import os from "os" ;
66import { CommandModule } from "yargs" ;
77import chalk from "chalk" ;
8- import bytes from "bytes" ;
98import stripAnsi from "strip-ansi" ;
109import { readGgufFileInfo } from "../../../../gguf/readGgufFileInfo.js" ;
1110import { resolveCommandGgufPath } from "../../../utils/resolveCommandGgufPath.js" ;
@@ -21,6 +20,7 @@ import {getReadablePath} from "../../../utils/getReadablePath.js";
2120import { withCliCommandDescriptionDocsUrl } from "../../../utils/withCliCommandDescriptionDocsUrl.js" ;
2221import { documentationPageUrls } from "../../../../config.js" ;
2322import { Llama } from "../../../../bindings/Llama.js" ;
23+ import { toBytes } from "../../../utils/toBytes.js" ;
2424
2525type InspectMeasureCommand = {
2626 modelPath ?: string ,
@@ -271,13 +271,13 @@ export const InspectMeasureCommand: CommandModule<object, InspectMeasureCommand>
271271 } ) ;
272272 const modelVramEstimation = modelResourceEstimation . gpuVram ;
273273 const modelVramEstimationDiffBytes = ( modelVramEstimation < result . modelVramUsage ? "-" : "" ) +
274- bytes ( Math . abs ( result . modelVramUsage - modelVramEstimation ) ) ;
274+ toBytes ( Math . abs ( result . modelVramUsage - modelVramEstimation ) ) ;
275275 const modelVramEstimationDiffText = modelVramEstimationDiffBytes . padEnd ( 9 , " " ) + " " +
276276 padStartAnsi ( "(" + renderDiffPercentageWithColors ( ( ( modelVramEstimation / result . modelVramUsage ) - 1 ) * 100 ) + ")" , 9 ) ;
277277
278278 const modelRamEstimation = modelResourceEstimation . cpuRam ;
279279 const modelRamEstimationDiffBytes = ( modelRamEstimation < result . modelRamUsage ? "-" : "" ) +
280- bytes ( Math . abs ( result . modelRamUsage - modelRamEstimation ) ) ;
280+ toBytes ( Math . abs ( result . modelRamUsage - modelRamEstimation ) ) ;
281281 const modelRamEstimationDiffText = modelRamEstimationDiffBytes . padEnd ( 9 , " " ) + " " +
282282 padStartAnsi ( "(" + renderDiffPercentageWithColors ( ( ( modelRamEstimation / result . modelRamUsage ) - 1 ) * 100 ) + ")" , 9 ) ;
283283
@@ -294,7 +294,7 @@ export const InspectMeasureCommand: CommandModule<object, InspectMeasureCommand>
294294 ? undefined
295295 : (
296296 ( contextVramEstimation < result . contextVramUsage ? "-" : "" ) +
297- bytes ( Math . abs ( result . contextVramUsage - contextVramEstimation ) )
297+ toBytes ( Math . abs ( result . contextVramUsage - contextVramEstimation ) )
298298 ) ;
299299 const contextVramEstimationDiffText = (
300300 contextVramEstimation == null || contextVramEstimationDiffBytes == null || result . contextVramUsage == null
@@ -310,7 +310,7 @@ export const InspectMeasureCommand: CommandModule<object, InspectMeasureCommand>
310310 ? undefined
311311 : (
312312 ( contextRamEstimation < result . contextRamUsage ? "-" : "" ) +
313- bytes ( Math . abs ( result . contextRamUsage - contextRamEstimation ) )
313+ toBytes ( Math . abs ( result . contextRamUsage - contextRamEstimation ) )
314314 ) ;
315315 const contextRamEstimationDiffText = (
316316 contextRamEstimation == null || contextRamEstimationDiffBytes == null || result . contextRamUsage == null
@@ -331,33 +331,33 @@ export const InspectMeasureCommand: CommandModule<object, InspectMeasureCommand>
331331 ? String ( previousContextSizeCheck )
332332 : undefined ,
333333
334- estimatedModelVram : bytes ( modelVramEstimation ) ,
335- actualModelVram : bytes ( result . modelVramUsage ) ,
334+ estimatedModelVram : toBytes ( modelVramEstimation ) ,
335+ actualModelVram : toBytes ( result . modelVramUsage ) ,
336336 modelVramEstimationDiff : modelVramEstimationDiffText ,
337337
338- estimatedModelRam : bytes ( modelRamEstimation ) ,
339- actualModelRam : bytes ( result . modelRamUsage ) ,
338+ estimatedModelRam : toBytes ( modelRamEstimation ) ,
339+ actualModelRam : toBytes ( result . modelRamUsage ) ,
340340 modelRamEstimationDiff : modelRamEstimationDiffText ,
341341
342342 estimatedContextVram : contextVramEstimation == null
343343 ? undefined
344- : bytes ( contextVramEstimation ) ,
344+ : toBytes ( contextVramEstimation ) ,
345345 actualContextVram : result . contextVramUsage == null
346346 ? undefined
347- : bytes ( result . contextVramUsage ) ,
347+ : toBytes ( result . contextVramUsage ) ,
348348 contextVramEstimationDiff : contextVramEstimationDiffText ,
349349 totalVramUsage : ( ( result . totalVramUsage / totalVram ) * 100 ) . toFixed ( 2 ) . padStart ( 5 , "0" ) + "% " +
350- chalk . gray ( "(" + bytes ( result . totalVramUsage ) + "/" + bytes ( totalVram ) + ")" ) ,
350+ chalk . gray ( "(" + toBytes ( result . totalVramUsage ) + "/" + toBytes ( totalVram ) + ")" ) ,
351351
352352 estimatedContextRam : contextRamEstimation == null
353353 ? undefined
354- : bytes ( contextRamEstimation ) ,
354+ : toBytes ( contextRamEstimation ) ,
355355 actualContextRam : result . contextRamUsage == null
356356 ? undefined
357- : bytes ( result . contextRamUsage ) ,
357+ : toBytes ( result . contextRamUsage ) ,
358358 contextRamEstimationDiff : contextRamEstimationDiffText ,
359359 totalRamUsage : ( ( result . totalRamUsage / totalRam ) * 100 ) . toFixed ( 2 ) . padStart ( 5 , "0" ) + "% " +
360- chalk . gray ( "(" + bytes ( result . totalRamUsage ) + "/" + bytes ( totalRam ) + ")" )
360+ chalk . gray ( "(" + toBytes ( result . totalRamUsage ) + "/" + toBytes ( totalRam ) + ")" )
361361 } ) ;
362362 }
363363 }
0 commit comments