Skip to content

v3.13.0 – Upstream MLX 0.33.0, Native Packed 4-Bit LLMs & Checkpoint Hardening

Choose a tag to compare

@Nodibell Nodibell released this 13 Nov 14:39
· 17 commits to main since this release

SwiftSci 3.13.0 Release Notes

SwiftSci 3.13.0 aligns the ecosystem with upstream mlx-swift 0.33.0+ while preserving full source and public API compatibility across all 15 modules, adds native packed 4-bit/8-bit quantized LLM execution and zero-configuration HuggingFace model loading (SwiftLLM), hardens binary model parsers (SafeTensorsParser, GGUFParser), supports community MLX Llama 3 tokenizer exports, eliminates batch NLEmbedding concurrency crashes (SwiftNLP), maintains 100.00% (2,540/2,540) DocC public declaration coverage, and includes the updated SwiftSci 3.13.0 Complete Engineering Handbook & Practical Cookbook (118 pages, 67 verified recipes).


🚀 Key Highlights & New Capabilities

  • Upstream mlx-swift 0.33.0 Alignment (Package.swift): Switched the mlx-swift dependency from forked crabel99/mlx-swift to upstream https://github.com/ml-explore/mlx-swift.git (from: "0.33.0"), updated wired-memory references in HardwareRouterAndMemory.md, and registered SwiftWorkflow in .spi.yml.
  • Native Packed Quantized LLM Execution (SwiftLLM):
    • TransformerDecoder.loadWeights(_:) auto-detects <module>.scales, <module>.biases, and bit-packed UInt32 weights (including across sharded checkpoints) and routes through loadQuantizedWeights(_:quantization:) so 4-bit/8-bit checkpoints stay packed on GPU via quantized_matmul instead of expanding to Float16.
    • Added AffineQuantizationConfig (including init?(configJSON:) and shape inference) and cross-shard split-tensor staging until the complete .weight, .scales, and .biases affine tensor set arrives across shard boundaries.
    • Quantized touched decoder layers individually (quantize(model: layers[layerIdx], ...) alongside non-array embedding / lmHead paths) so multi-layer sharded checkpoints with sparse layer distribution across shards load cleanly.
  • Zero-Configuration Model Download & Sharded Loading (SwiftLLM):
    • Added ModelDownloader with repository/revision identifier validation and revision-isolated local caching (<cacheDirectory>/<repo>/<revision>).
    • Added LLMConfig(huggingFaceConfigJSON:maxSeqLen:) and streaming sharded TransformerDecoder.load(directory:maxSeqLen:), validating per-layer normalization weights (input_layernorm.weight, post_attention_layernorm.weight) and pending quantized tensor sets across shards.

🛡️ Binary Parser, Tokenizer & Concurrency Hardening

  • SafeTensorsParser (SwiftLLM): Added U8, U16, U32, U64, I16, and BOOL dtypes plus strict bounds checking against hostile header sizes, negative or inverted data_offsets, out-of-range dimensions (0 ... Int32.max), element-count overflow, and payload byte-length mismatches.
  • GGUFParser & QuantizedTensor (SwiftLLM): Fixed 1-byte boolean metadata alignment (previously skipped as 4 bytes), added range/overflow checks on arrays, strings, dimensions, and offsets, corrected Q8_0 block-32 type mapping (case 8), and fixed unsigned exponent underflow in halfToFloat ((exp + 112) << 23) during FP16 dequantization.
  • BPETokenizer (SwiftNLP): Updated BPETokenizer(llama3TokenizerJSON:) to accept flattened bare ByteLevel post_processor configurations written by community MLX exports while continuing to reject missing <|begin_of_text|> tokens or unsupported offset flags.
  • AppleSentenceEmbeddingEngine (SwiftNLP): Serialized NLEmbedding vector lookups via NSLock and switched embedBatch(_:) to sequential cancellable execution, eliminating CoreFoundation SIGSEGV crashes on batches exceeding 16 texts.

📊 Benchmark Baseline & API Compatibility

  • Audited Benchmark Parity vs 3.12.0: No changes were made to CPU, SwiftDataFrame, SwiftStats, SwiftPreprocessing, SwiftForecast, or classical SwiftML code paths; all audited 3.12.0 Methodology v2 tabular and ML timings carry forward unchanged.
  • Source & Public API Compatibility: Checked across all 15 modules against v3.12.0 (swift package diagnose-api-breaking-changes v3.12.0: no breaking changes detected).

📦 Installation

Add SwiftSci 3.13.0 to your Package.swift:

dependencies: [
    .package(url: "https://github.com/Nodibell/SwiftSci.git", from: "3.13.0")
]

Or target individual modular libraries:

.target(
    name: "MyTarget",
    dependencies: [
        .product(name: "SwiftDataFrame", package: "SwiftSci"),
        .product(name: "SwiftML", package: "SwiftSci"),
        .product(name: "SwiftLLM", package: "SwiftSci"),
    ]
)

📚 Attached Documentation

  • SwiftSci_Handbook_3.13.0.pdf — Complete Engineering Handbook & Practical Cookbook (118 pages, 67 verified recipes)
  • SwiftSci_Handbook_3.13.0.epub — E-reader edition

Full Changelog: v3.12.0...v3.13.0