v2: Apply tokenizer UTF-8 fix + Engine writeFloats helper
- Tokenizer fix: collect <0xXX> bytes and decode as UTF-8 (fixes Chinese/non-ASCII character decoding) - BPETokenizer + HuggingFaceTokenizer: both updated - Engine.swift: added writeFloats() utility method - FloatWeights struct added to Layer.swift (bf16 support) - attnQBits/KBits/VBits/OBits detection added to Model.swift - bf16 layer weight support from commit 48c0347 cherry-picked
This commit is contained in:
@@ -716,9 +716,13 @@ readers = readersDict
|
||||
print(" layer_scalar: NOT FOUND (using 1.0)")
|
||||
}
|
||||
|
||||
// Detect quantization bits from weight shape (supports both uniform 4-bit and 8-bit MLP/router)
|
||||
// Detect quantization bits from weight shape (supports both uniform 4-bit and 8-bit MLP/router)
|
||||
let mlpGateBits = detectBits(for: "mlp.gate_proj", expectedInDim: hiddenSize, defaultBits: 4)
|
||||
let mlpDownBits = detectBits(for: "mlp.down_proj", expectedInDim: intermediate, defaultBits: 4)
|
||||
let attnQBits = detectBits(for: "self_attn.q_proj", expectedInDim: hiddenSize, defaultBits: 4)
|
||||
let attnKBits = detectBits(for: "self_attn.k_proj", expectedInDim: hiddenSize, defaultBits: 4)
|
||||
let attnVBits = detectBits(for: "self_attn.v_proj", expectedInDim: hiddenSize, defaultBits: 4)
|
||||
let attnOBits = detectBits(for: "self_attn.o_proj", expectedInDim: hiddenSize, defaultBits: 4)
|
||||
|
||||
// Try bf16 weights first (for bf16 models)
|
||||
let qpFloat = try fw("self_attn.q_proj")
|
||||
|
||||
Reference in New Issue
Block a user