-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathIQuantizeModule.cs
More file actions
38 lines (32 loc) · 1.12 KB
/
IQuantizeModule.cs
File metadata and controls
38 lines (32 loc) · 1.12 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.ML.GenAI.Core;
public interface IQuantizeModule
{
public void Int8();
/// <summary>
/// Quantize using BitsAndBytes.FP4
/// </summary>
/// <param name="config"><see cref="Quantize4BitConfig"/></param>
public void Quantize4Bit(Quantize4BitConfig config);
}
/// <summary>
/// Quantize configuration for 4-bit quantization.
/// </summary>
public record Quantize4BitConfig
{
public Quantize4BitConfig(string quantizedDType = "fp4", int blockSize = 64)
{
QuantizedDType = quantizedDType;
BlockSize = blockSize;
}
/// <summary>
/// Quantized data type, can be "fp4" or "nf4".
/// </summary>
public string QuantizedDType { get; init; }
/// <summary>
/// Block size for quantization, can be [64, 128, 256, 512, 1024]. The larger the size, the faster the speed and the lower the precision.
/// </summary>
public int BlockSize { get; init; }
}