Skip to content

Metal MPS POTRF allocates an MPSCommandBuffer per wide front per refactorization (~2.1 MB host allocation on lap2d_300) #137

Closed as not planned

Description

@claude

Found while working on: T31 (PR #136)

What: ext/SparseDirectSolverMetalExt.jl, _offset_potrf_info!: every single-matrix Cholesky regime-C front at least 64 wide creates a new MPSCommandBuffer(global_queue(device())) in every (re)factorization, encodes the cached MPSMatrixDecompositionCholesky on the cached offset MPSMatrix, and commits it. The descriptors, kernels and status buffer are preallocated at allocate_numeric, but the wrapper objects are not: the PR author measured about 2.1 MB of host allocation per lap2d_300 refactorization on an M4 Max (18 wide fronts). AGENTS.md forbids allocation inside the numeric phase. Same command-buffer pattern would apply to any later MPS TRSM/GEMM binding. Expected: no host allocation per refactorization, or one command buffer per level/launch group.

Why it is out of scope: T31 review round 1 asked to record it rather than redesign the MPS path; it needs Metal hardware to measure. No task in TASKS.md owns Metal tuning after T31.

Suggested fix or plan change: encode all wide fronts of one level into one command buffer created per launch group, or reuse an encoder obtained from Metal.jl's KA command stream if Metal.jl exposes one; assert with a host allocation budget in a Metal-only test.

Activity

  1. added
    found-by-agentOpened by an implementing agent for an out-of-scope finding
    on Oct 14, 2026
  2. added
    performanceSpeed or memory of the numeric and solve phases; tracked in PERFORMANCE.md
    metalMetal extension; needs Apple hardware
    on Oct 29, 2026
  3. michel2323 commented on Oct 29, 2026

    @michel2323
    Member

    Consolidated into the Metal tracking issue (see the issue list, label metal).

  4. michel2323 commented on Oct 29, 2026

    @michel2323
    Member

    Tracking issue: #168.

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

    found-by-agentOpened by an implementing agent for an out-of-scope findingmetalMetal extension; needs Apple hardwareperformanceSpeed or memory of the numeric and solve phases; tracked in PERFORMANCE.md

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions