Skip to content

fix(hardware): detect Apple Silicon under Rosetta 2 in GPU probe (BE-3435)#568

Open
mattmillerai wants to merge 1 commit into
matt/be-3399-hardware-blockfrom
matt/be-3435-rosetta-gpu-probe
Open

fix(hardware): detect Apple Silicon under Rosetta 2 in GPU probe (BE-3435)#568
mattmillerai wants to merge 1 commit into
matt/be-3399-hardware-blockfrom
matt/be-3435-rosetta-gpu-probe

Conversation

@mattmillerai

Copy link
Copy Markdown
Collaborator

ELI-5

If you run an Intel-flavored Python on a modern Apple Mac (via Apple's Rosetta 2 translator), the machine lies and says it's an old Intel chip. Our hardware probe believed the lie and reported "no GPU" — even though the Mac has a perfectly capable Apple GPU. This teaches the probe to ask macOS one extra question ("am I being translated?") so it correctly recognizes the Apple chip underneath and reports its unified-memory GPU.

What & why

comfy_cli/hardware.py:_detect_gpu keyed Apple Silicon unified-memory detection on machine == 'arm64'. An x86_64 Python running under Rosetta 2 on an Apple Silicon Mac reports platform.machine() == 'x86_64', so the unified-memory block was skipped and the machine fell through to the NVIDIA/AMD probes (which find nothing) — a capable GPU reported as gpu: null.

Fix: a small _is_apple_silicon(machine) helper keeps the native arm64 fast path and, when machine != 'arm64', falls back to sysctl -n sysctl.proc_translated (via the existing _run helper). A value of '1' means the process is translated, which only happens on Apple Silicon, so the apple/unified block is used.

Notes for the reviewer

  • Chesterton's Fence — this deliberately broadens an existing check. The original machine == 'arm64' guard was introduced (intentionally minimal) in the base PR feat: add cross-platform hardware block to comfy env --json (BE-3399) #562 (BE-3399); this ticket (BE-3435) is the scoped follow-up to broaden it. The old and new conditions differ only in the newly-matched state — machine != 'arm64' and proc_translated == '1', i.e. exactly Apple Silicon under Rosetta. On a genuine Intel Mac the sysctl.proc_translated OID is absent, _run returns None, None == '1' is False, so Intel behavior is unchanged (the existing test_intel_mac_has_no_apple_gpu still passes).
  • Never-raise contract preserved: _is_apple_silicon only calls _run (which never raises and is timeout-bounded) plus a string compare, and it runs inside _detect_gpu's existing try/except.
  • Under Rosetta, arch is still honestly reported as x86_64 (that's what the process is); only the gpu block is corrected. The model comes from machdep.cpu.brand_string, which returns the real Apple chip name even under translation.
  • New unit test mocks _run to return '1' for the sysctl.proc_translated key and asserts the unified block.

Stacking

Opened stacked on matt/be-3399-hardware-block (#562)hardware.py does not exist on main yet; it lands with #562. GitHub will retarget this PR to main when #562 merges; the diff here is just the net Rosetta change.

Testing

  • pytest tests/comfy_cli/test_hardware.py → 20 passed
  • ruff check + ruff format --check on the touched files → clean

…3435)

An x86_64 Python running under Rosetta 2 on an Apple Silicon Mac reports
platform.machine() == 'x86_64', so _detect_gpu skipped the unified-memory
block and fell through to the NVIDIA/AMD probes, reporting gpu: null on a
capable machine. Add _is_apple_silicon(), which keeps the native arm64 fast
path and falls back to sysctl.proc_translated == '1' (via the existing _run
helper) to recognize the translated case. Genuine Intel Macs lack that
sysctl key, so _run returns None and they still fall through unchanged.

Preserves the never-raise contract (_run never raises; the whole probe stays
wrapped). Adds a unit test mocking _run for the Rosetta case.
@mattmillerai mattmillerai added agent-coded PR authored by the agent-work loop cursor-review Request Cursor bot review labels Jul 18, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f8999a72-234b-444c-8596-ac3a9025d909

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch matt/be-3435-rosetta-gpu-probe
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch matt/be-3435-rosetta-gpu-probe

Comment @coderabbitai help to get the list of available commands.

@mattmillerai
mattmillerai marked this pull request as ready for review July 18, 2026 01:59
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Cursor Review — Consolidated panel

Triggered by @mattmillerai.

✅ No high-signal findings.

Panel: 6/8 reviewers contributed findings.

Reviewers that did not contribute: kimi-k2.5:adversarial (empty), kimi-k2.5:edge-case (empty)

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

Labels

agent-coded PR authored by the agent-work loop cursor-review Request Cursor bot review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant