defaultScale (MLXLMCommon/SuScaledRoPE.swift)

PhoneClaw · Packages/InferenceKit/Libraries/MLXLMCommon/SuScaledRoPE.swift · swift · Apache-2.0
ai, tag:embed-classified

Swift module implementing Su Scaled Rotary Position Embedding for MLX models.

// Source: https://github.com/kellyvv/PhoneClaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import Foundation
import MLX
import MLXNN

// port of https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/models/rope_utils.py

/// Su Scaled Rotary Position Embedding.
public class SuScaledRoPE: Module, OffsetLayer, ArrayOffsetLayer {
    let dimensions: Int
    let originalMaxPositionEmbeddings: Int
    let _freqs: MLXArray
    let _scale: Float

    public init(
        dimensions: Int,
        base: Float = 10000.0,
        maxPositionEmbeddings: Int = 131072,
        originalMaxPositionEmbeddings: Int = 4096,
        shortFactor: [Float] = [1.0],
        longFactor: [Float] = [1.

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key