-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
95 lines (84 loc) · 3.59 KB
/
Copy pathProgram.cs
File metadata and controls
95 lines (84 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using LLMExperiment;
namespace GGUFDump;
public static class Program
{
public static void Main(string[] args)
{
if (args.Length >= 1)
{
//Use args as the model filename, use GgufMetadata to load it, and just dump all the dictionaries to the screen.
//Join all args together with a space in case the filename has spaces in it and the user didn't use quotation marks.
var filename = string.Join(" ", args);
if (filename.EndsWith(".json", StringComparison.OrdinalIgnoreCase)) DumpJsonKvCache(filename);
else DumpGGUF(filename);
}
else
{
Console.WriteLine("Usage: GGUFDump <filename>. Alternatively, you can drag and drop a GGUF file (or config.json) onto the executable.");
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
private static void DumpGGUF(string filename)
{
var ggufMetadata = new GgufMetadata(filename);
foreach (var dictEntry in ggufMetadata.BoolValues)
{
Console.WriteLine($"BoolValues[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Float32Values)
{
Console.WriteLine($"Float32Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Float64Values)
{
Console.WriteLine($"Float64Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Int8Values)
{
Console.WriteLine($"Int8Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Int16Values)
{
Console.WriteLine($"Int16Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Int32Values)
{
Console.WriteLine($"Int32Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.Int64Values)
{
Console.WriteLine($"Int64Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.UInt8Values)
{
Console.WriteLine($"UInt8Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.UInt16Values)
{
Console.WriteLine($"UInt16Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.UInt32Values)
{
Console.WriteLine($"UInt32Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.UInt64Values)
{
Console.WriteLine($"UInt64Values[{dictEntry.Key}] = {dictEntry.Value}");
}
foreach (var dictEntry in ggufMetadata.StringValues)
{
Console.WriteLine($"StringValues[{dictEntry.Key}] = {dictEntry.Value}");
}
Console.WriteLine("Tensors in GPU-offloading priority order:");
foreach (var tensor in ggufMetadata.GetTensorsForOffload())
{
Console.WriteLine($"{tensor.Name} ({tensor.Type}, dimensions: [{string.Join(", ", tensor.Dimensions)}])");
}
Console.WriteLine("KV cache usage per token: " + ggufMetadata.GetKvCacheKBPerToken() + " KB");
}
private static void DumpJsonKvCache(string filename)
{
Console.WriteLine("KV cache usage per token: " + GgufMetadata.GetKvCacheKBPerToken(File.ReadAllText(filename)) + " KB");
}
}