11// Copyright © 2025 Apple Inc.
22
33import Foundation
4+ import MLX
45
56/// Base ``LanguageModel`` configuration -- provides `modelType`
67/// and `quantization` (used in loading the model).
@@ -18,20 +19,15 @@ public struct BaseConfiguration: Codable, Sendable {
1819
1920 public let groupSize : Int
2021 public let bits : Int
21- public var quantMethod : String ? = nil
22- public var linearClass : String ? = nil
23- public var quantizationMode : String ? = nil
24- public var mode : String ? = nil
22+ private var _mode : QuantizationMode ? = nil
23+ public var mode : QuantizationMode { _mode ?? . affine }
2524
26- public var asTuple : ( Int , Int ) { ( groupSize, bits) }
25+ public var asTuple : ( Int , Int , QuantizationMode ) { ( groupSize, bits, mode ) }
2726
2827 enum CodingKeys : String , CodingKey {
2928 case groupSize = " group_size "
3029 case bits = " bits "
31- case quantMethod = " quant_method "
32- case linearClass = " linear_class "
33- case quantizationMode = " quantization_mode "
34- case mode = " mode "
30+ case _mode = " mode "
3531 }
3632 }
3733
@@ -115,10 +111,11 @@ public struct BaseConfiguration: Codable, Sendable {
115111 switch key. stringValue {
116112 case Quantization . CodingKeys. groupSize. rawValue: continue
117113 case Quantization . CodingKeys. bits. rawValue: continue
118- case Quantization . CodingKeys. quantMethod. rawValue: continue
119- case Quantization . CodingKeys. linearClass. rawValue: continue
120- case Quantization . CodingKeys. quantizationMode. rawValue: continue
121- case Quantization . CodingKeys. mode. rawValue: continue
114+ case Quantization . CodingKeys. _mode. rawValue: continue
115+
116+ // additional keys that are not layer instructions, see
117+ // mlx-community/bitnet-b1.58-2B-4T-4bit
118+ case " quant_method " , " linear_class " , " quantization_mode " : continue
122119
123120 default :
124121 if let f = try ? container. decode ( Bool . self, forKey: key) {
0 commit comments