Skip to content

[BUG] VJP should be Sendable #475

Description

@davidkoski

Two parter, see ml-explore/mlx-swift-lm#616

public func CustomFunction(
    @MLXCustomFunctionBuilder.Builder _ build: () -> ([MLXArray]) -> [MLXArray]
) -> ([MLXArray]) -> [MLXArray] {
    build()
}

should produce Sendable ouputs -- these are pure functions.

Also VJP:

public func VJP(_ f: @escaping ([MLXArray], [MLXArray]) -> [MLXArray]) -> MLXCustomFunctionComponent
{
    .vjp(f)
}

should have a 3 parameter mode with outputs, see:

    std::optional<std::function<std::vector<array>(
        const std::vector<array>&,
        const std::vector<array>&,
        const std::vector<array>&)>> fun_vjp /* = std::nullopt */,

this can be used with:

public func depends(input: MLXArray, dependencies: [MLXArray]) -> MLXArray {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions