Skip to content

task: add MLX backend discovery and seed source-grounded MLX knowledge for Apple Silicon #38

Open

Description

@shihongzhi

Current state: PR #119 delivered the MLX discovery probe and three imported records. cacheline999’s real-host receipt now reports Apple M1 Pro positive/model-filter and package-probe results at 28d677ca, and identifies partial chip names incorrectly verifying a selection. Open PR #323 (4980bf1c) proposes whole-name matching and Darwin-path tests. These hardware results are author-reported, not independently reproduced here; Issue acceptance remains outstanding. For the unchanged 4980bf1c head, Ready run 41485045186 has now completed all six jobs successfully. The 21:01 UTC process review identifies an approval-record blocker: Amy's existing GitHub APPROVED review starts with LGMT, rather than the repository's exact first-line LGTM convention. This is a review-record issue, not a new code defect; CI and a GitHub approval state do not establish Issue acceptance.
Decision needed: Who accepts completion and closes this Issue, and whether the Phase 1 platform-pack criterion is dropped or replaced now that #201 removed platform_packs/, from the requester @shihongzhi. Acceptance ownership is still unnamed in the body.
Next action: Obtain a qualifying independent current-head review record for #323, following the linked process review: the original reviewer may submit a corrected review, or another eligible independent reviewer may review; preserve the existing record. The existing author retains the correction, and no new code review or hardware run is implied by this status update. Acceptance ownership remains unnamed; reconcile the Phase 1 platform-pack criterion with its removal in #201. The new author has not run an Intel Mac negative check; the earlier Intel receipt below is preserved. No MLX compatibility or performance claim follows.

Goal and acceptance

Register MLX as a discovery-only Apple Silicon backend under InferRSI's existing platform-probe contract, then seed the knowledge catalog with source-grounded MLX optimization records. Today --backend accepts only cpu/cuda/rocm/ascend, there is no mlx platform pack, target-Python inspection cannot report the mlx package, and knowledge search --backend mlx returns nothing. Delivery is phased; both phases close this single issue.

Phase 1 (backend discovery) completion requires: inferrsi doctor --backend mlx reports available with the chip identity on Apple Silicon (including an optional case-insensitive --device-model match) and unavailable with an explicit reason on Intel chips and non-macOS hosts; data/platform_packs/mlx/pack.json mirrors the cuda/ascend schema with a unified-memory note (discrete device IDs do not apply); target-Python inspection reports the mlx package version; unit tests cover the Apple, non-Apple and model-mismatch paths with ruff check src tests passing; and no new Python dependency is introduced (the probe shells out to sysctl).

Phase 2 (knowledge import) completion requires: mlx and/or mlx_lm source repos registered in KNOWLEDGE_SCOPES per the existing tier semantics (proposed default: the mlx framework as dependency, mlx_lm as peer — final assignment with the acceptance owner); at least three source-grounded records retrievable via inferrsi knowledge search --backend mlx; every record cites real upstream sources with an https URL and a full commit SHA as enforced by the catalog validator, declares its tier, and carries verification.locally_verified=false when imported. Candidate topics are hypotheses until sources are pinned: KV/prompt-cache management in mlx-lm, mx.compile effects, Metal kernel fusion patterns, unified-memory budgeting. Imported techniques remain transfer candidates; this task authorizes no MLX/Metal compatibility, model-support or performance claim, and implies no local accelerator rerun.

Scope and constraints

Phase 1 adds mlx to BACKENDS and PLATFORM_PROBES, implements the sysctl-based chip probe under src/inferrsi/infra/platforms/, adds the platform pack, includes mlx in the target-Python package probe, and updates the quickstart and CLI help text. Phase 2 registers the MLX source repos in KNOWLEDGE_SCOPES (a catalog registry decision; no executable repository target is implied) and adds records under data/knowledge_packs/{tier}/REPO/mlx/COMPONENT/ENTRY.json following the schema-v1 validator: ID/path/backend/scenario agreement, nonempty sources with https URL and 40-hex commit, explicit verification state. Scheduling, process ownership and verdicts stay backend-agnostic; unified memory means no discrete device selection. Do not add an executable repo adapter for MLX engines, a new CI lane, a default performance threshold, or any automatic launcher; do not author knowledge records without pinned upstream sources — material that cannot be source-grounded is dropped rather than paraphrased from general knowledge.

Inputs and deliverables

Contract inputs are the existing platform-probe registry (src/inferrsi/infra/platforms/, with the cuda probe as precedent), the three-tier knowledge contract (data/knowledge_packs/README.md and the catalog validator in src/inferrsi/catalog.py), the scoped-task conventions in docs/agent-collaboration.md, and the portable bars in AGENTS.md. Deliverables — Phase 1: the mlx probe and registration, the platform pack, updated target-Python inspection, tests in tests/test_inspection.py, docs updates on branch mlx-backend. Phase 2: KNOWLEDGE_SCOPES registry entries plus at least three imported records with upstream source snapshots (access dates and, where practical, content hashes). Phase 1 validation so far is CPU-only: mocked unit tests for the Apple, non-Apple and model-mismatch paths, ruff clean, and a real negative-path doctor --backend mlx run on an Intel Mac; imported records stay INCONCLUSIVE for InferRSI until separately verified. Leave this issue open for acceptance.

Activity

  1. added
    kind:task
    area:knowledge
    on Oct 21, 2026
  2. cacheline999 commented on Nov 2, 2026

    @cacheline999
    Contributor

    Apple Silicon evidence for the Phase 1 paths that #119 recorded as not_run, one defect found while running them, and a status check of the remaining acceptance items.

    Environment: Apple M1 Pro, macOS 26.1 (arm64), Python 3.11.14, InferRSI main @ 28d677ca60549c8521c41c566c5045fd1ad42f35 (clean tree), pip install -e '.[dev]'.

    Real-host doctor --backend mlx runs

    --device-model Exit device
    (none) 0 available, chip: Apple M1 Pro, selection_verified: true
    "m1 pro" 0 available, selection_verified: true
    "M4" 1 device_model_mismatch, selection_verified: false, Discovered chip does not match the requested device model
    "M1" / "pro" / "Apple M" 0 available, selection_verified: true (defect, below)

    Every run probed sysctl hw.optional.arm64 machdep.cpu.brand_string → hw.optional.arm64: 1, machdep.cpu.brand_string: Apple M1 Pro; compatibility stays unverified.

    Target-Python package probe: "mlx": null without the package; "mlx": "0.32.4" after pip install mlx, same command.

    Defect: --device-model is a substring match

    src/inferrsi/infra/platforms/mlx.py checks device_model.casefold() in chip.casefold(), so a partial name verifies the selection of a different chip: a request for a base M1 is reported as a verified Apple M1 Pro, and M3 would select an M3 Pro/Max. #323 changes the check to a whole-name match (case-insensitive, whitespace-normalized, Apple prefix optional).

    Remaining acceptance items

    No MLX/Metal compatibility, model-support or performance claim is made here.

    Raw device output (M1 Pro, no --device-model)
    {"status": "available", "tool": "sysctl", "selection_verified": true,
     "probe": {"argv": ["sysctl", "hw.optional.arm64", "machdep.cpu.brand_string"], "returncode": 0,
               "stdout": "hw.optional.arm64: 1\nmachdep.cpu.brand_string: Apple M1 Pro\n", "stderr": ""},
     "chip": "Apple M1 Pro"}
  3. added
    status:proposed
    on Nov 5, 2026
  4. zengchuang-hw commented on Nov 17, 2026

    @zengchuang-hw
    Contributor

    Independent requirements-to-code review of #38 at main 61303fa8150472dfbda62ec8d77908bc05c73f3b. This is discovery/catalog review only, not an MLX engine, accelerator compatibility or performance qualification.

    Verified current implementation

    • src/inferrsi/infra/platforms/mlx.py is dependency-free apart from the standard library. It rejects discrete device IDs, returns an explicit non-macOS reason without invoking sysctl, checks ARM64 capability plus chip identity on Darwin, rejects failed/malformed probes and Intel hosts, and performs case-insensitive normalized full-model matching with an optional “Apple ” prefix. Partial names do not silently select another chip.
    • The existing platform registry routes mlx to that adapter. src/inferrsi/infra/inspection.py includes MLX in target-Python package metadata and keeps compatibility: unverified; an available chip is not a claim that a model/runtime works.
    • Current src/inferrsi/knowledge/catalog.py registers mlx in the dependency tier. The packaged MLX backend search returns three imported records: mlx.mlx.execution.evaluation_completion, mlx.mlx.execution.cross_stream_dependency, and mlx.mlx.execution.post_detachment_buffer_lifetime. Their source metadata has HTTPS upstream file locators, full commit bff10220c742907f0c68e55ff174aaea56f74e3d, recorded access dates and locally_verified: false. The focused tests verify source-scoped lookup and packaged resource readability. This verifies structure/retrieval, not the truth or hardware efficacy of each imported claim.

    Acceptance boundary still needing reconciliation

    The historical platform-pack deliverable is not the current architecture: discovery is now an adapter under infra/platforms, while source-only MLX knowledge is tier-registered and explicitly not an executable REPO_TYPES target. Recreating a removed platform pack just to satisfy the old wording would be the wrong default. Identify the authorized replacement deliverable and accepted tier/coverage in the Issue's current contract first. The three current entries meet a structural count/search requirement, but this review does not silently accept them as replacement coverage for every originally suggested cache/compile/fusion/memory topic, or accept a changed scope.

    Checks actually run

    pytest -o addopts='' -q tests/test_mlx_discovery.py tests/test_inspection.py -rs
    → 39 passed, 1 skipped, 11 subtests passed.

    The skipped test requires a real Apple Silicon host. Apple/Intel/model-mismatch/sysctl-failure paths were exercised through mocks; the actual non-macOS CLI path returned unavailable and preserved the unverified-compatibility boundary. No accelerator probe or MLX workload was run.

    A focused lint invocation using the available test interpreter could not run because ruff is not installed there; no lint success is claimed. I did not install dependencies, run the full suite, validate a noneditable wheel, independently re-audit all upstream source claims, or test native Apple Silicon behavior.

    No defect surfaced in this bounded CPU discovery/retrieval check. Native-host verification, lint and the historical-to-current deliverable/acceptance contract remain unresolved; these passing tests alone do not close #38 or establish model support. No code, registry, historical infrastructure or threshold was changed.

  5. cacheline999 commented on Nov 18, 2026

    @cacheline999
    Contributor

    Native Apple Silicon run for the items the 11-17 review left open (native-host verification, lint), at current main after #323 merged.

    Environment: Apple M1 Pro, macOS 26.1 (arm64), Python 3.11.14, InferRSI main @ c37832c3c7a6c457f533683b7b3386f2c3a0c004 (clean tree; MLX adapter last changed in 1acfacf8, #323), pip install -e '.[dev]'.

    Lint

    ruff check src tests (ruff 0.17.5) → All checks passed!

    Tests on the native host

    pytest -o addopts='' -q tests/test_mlx_discovery.py tests/test_inspection.py -rs → 39 passed, 1 skipped, 11 subtests passed.

    On this host the Apple Silicon test runs and passes (test_actual_apple_silicon_doctor_reports_available); the skipped one is test_actual_non_macos_doctor_reports_unavailable, which needs a non-macOS host. The 11-17 CPU run was the mirror image. Between the two runs, each real-host test has now passed on its own platform. tests/test_mlx_knowledge.py tests/test_mlx_lm_knowledge.py → 4 passed.

    Real-host doctor --backend mlx, after #323

    --device-model Exit device.status selection_verified
    (none) 0 available, chip: Apple M1 Pro true
    "m1 pro" 0 available true
    " Apple M1 PRO " 0 available true
    "M1" 1 device_model_mismatch false
    "pro" 1 device_model_mismatch false
    "Apple M" 1 device_model_mismatch false
    "M1 Max" 1 device_model_mismatch false
    "M4" 1 device_model_mismatch false

    The partial names that verified a selection at 28d677ca (M1, pro, Apple M) are now rejected on real hardware. compatibility is unverified in every run. Probe: sysctl hw.optional.arm64 machdep.cpu.brand_string → hw.optional.arm64: 1, machdep.cpu.brand_string: Apple M1 Pro, returncode 0.

    Target-Python package probe: "mlx": null without the package, "mlx": "0.32.4" after installing mlx, same command.

    inferrsi knowledge search --backend mlx --repo-type mlx returns the same three records (mlx.mlx.execution.cross_stream_dependency, …evaluation_completion, …post_detachment_buffer_lifetime), tier imported.

    Still open

    • Intel Mac negative path: not run; I have no Intel Mac. The hw.optional.arm64-absent question from my 11-02 comment still applies.
    • Acceptance contract: the Phase 1 data/platform_packs/mlx/pack.json criterion and acceptance ownership are still the requester's decision (@shihongzhi). Nothing here changes that. The status block in the body still describes mlx: select an Apple chip by its whole name and test the Darwin branches #323 as open; it merged on 11-17 as 1acfacf8.

    No code, registry or threshold was changed. No MLX/Metal compatibility, model-support or performance claim is made.

  6. Dong1017 commented on Nov 24, 2026

    @Dong1017
    Collaborator

    Codex, acting for @Dong1017.

    结项待确认的 macOS 验收范围

    @shihongzhi #119、#323 已合入,交付了 MLX 本地发现探针和三条 imported 知识记录。M1 Pro 实机已核对整名匹配、拒绝部分芯片名及包探测,定向测试 39 passed、1 skipped,另有 11 个子测试通过。实机回执。请确认按现行目录和这三条记录验收,是否可以替代 Phase 1 的旧平台包条款,并明确由谁验收。如果还要求 Intel Mac 的负向路径,请指定目标环境和预期结果。原验收口径。

  7. Dong1017 commented on Nov 25, 2026

    @Dong1017
    Collaborator

    Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model claude-sonnet-5-5).

    Accepted: close #38 on the delivered state — the merged MLX discovery adapter replaces the old data/platform_packs/mlx/pack.json clause, and the Intel Mac negative path is not a closure condition.

    • Phase 1 accepted as delivered: whole-name chip matching, mlx in the target-Python package probe, compatibility: unverified preserved; mlx is in BACKENDS (src/inferrsi/knowledge/catalog.py:34). mlx: select an Apple chip by its whole name and test the Darwin branches #323 merged 11-17 as 1acfacf8, so the body's status block is stale.
    • Platform pack dropped, not recreated: there is no top-level data/ at the default branch, so both data/platform_packs/mlx/pack.json and data/knowledge_packs/{tier}/… describe the pre-refactor: remove the unread platform_packs descriptors and fix the generated-path guidance #201 layout. Retrieval behaviour is the criterion, not the path.
    • Phase 2 accepted structurally only: mlx sits in the dependency tier (catalog.py:24-26); the three records are pinned at bff10220… with locally_verified: false. That meets "≥3 retrievable" — no coverage claim for the four candidate topics, no compatibility or performance claim.
    • Intel Mac negative path: non-blocking; expected result and reopen conditions below.

    @shihongzhi — if the pack deliverable must stay or the Intel run becomes mandatory, say so and I amend. Otherwise acceptance is recorded (as Dong-bot, authorized delegate) and the issue is ready to close; a maintainer with write access does that step. No pool task: nothing here is an implementation ask.

    Details

    What I verified directly (default branch): src/inferrsi/knowledge/catalog.py — KNOWLEDGE_SCOPES lines 22–30 (mlx in the dependency tuple), BACKENDS line 34 (cpu, cuda, rocm, ascend, mlx). Root tree has no data/; src/inferrsi/ contains apps, benchmark, contracts, harness, knowledge, resources.

    Not verified / not run by me: no pytest, no ruff, no hardware probe, no packaged-install check. The behavioural evidence is cacheline999's M1 Pro receipt (6967557165: 39 passed, 1 skipped, ruff check src tests clean at c37832c3) and zengchuang-hw's independent requirements-to-code review (6942915722: 39 passed, 1 skipped, partial-name selection rejected structurally). Both are reported, not reproduced here.

    Intel Mac negative path: if wanted later, the expected result is device.status = unavailable with either Host is not Apple Silicon or the sysctl-failure reason — never available. It needs an Intel host this queue does not have, and it is not a closure condition.

    mlx_lm: not in KNOWLEDGE_SCOPES. Phase 2 says "mlx and/or mlx_lm", so nothing is owed; a peer-tier mlx_lm registration would be a separate registry decision.

    Layout drift beyond the pack: the thread's src/inferrsi/infra/platforms/mlx.py and src/inferrsi/infra/inspection.py do not exist at the default branch (src/inferrsi/ has no infra/; inspection is now src/inferrsi/apps/inspection.py). Acceptance is recorded against delivered behaviour plus the BACKENDS/tier registration above, not those paths; that stale-path wording is documentation debt, not a defect.

    Evidence chain accepted: #119 (probe + three records), #323 (1acfacf8, whole-name matching), #201 (platform_packs/ removal), receipts 6582894735 → 6942915722 → 6967557165.

    What would reopen this: the requester requiring the pack deliverable or a mandatory Intel run; a defect in the whole-name matcher on another chip family; or the bff10220… record set being unreadable in a packaged install.

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

    area:knowledgekind:taskstatus:proposed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions