Skip to content

llama.cpp prebuilt: accept upstream win-rocm bundles, run native arm64 under Rosetta, source-build on Jetson - #14373

Merged
danielhanchen merged 10 commits into
mainfrom
llama-prebuilt-win-rocm-rosetta-jetson
Oct 20, 2026
Merged

danielhanchen merged 10 commits into
mainfrom
llama-prebuilt-win-rocm-rosetta-jetson

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Three host edges where the llama.cpp prebuilt selector picks the wrong bundle.

What changes

  • Windows AMD, upstream release path:
    • ggml-org now publishes llama-<tag>-bin-win-rocm-<ver>-x64.zip instead of win-hip-radeon-x64. Both names are accepted: the legacy name first, then rocm versions newest first, still as install kind windows-hip.
    • A ROCm host with no usable HIP bundle now tries win-vulkan-x64 before win-cpu-x64. It never does so when any NVIDIA adapter is present (including one the ROCm torch route set aside) or a HIP visibility mask is set, since Vulkan ignores both. An Intel iGPU or a non-ROCm AMD card beside the ROCm card does not lift that guard.
    • The fork's manifest path is unchanged.
  • macOS under Rosetta:
    • An x86_64 Python on Apple Silicon is treated as arm64, so it installs the Metal macos-arm64 bundle instead of the Metal-off macos-x64 build.
    • Detection is sysctl -n hw.optional.arm64 == 1; the check is bounded and never raises.
    • Python wheel selection is untouched.
  • Jetson:
    • On Tegra (/etc/nv_tegra_release, or nvidia,tegra in the device tree) with a driver CUDA below 13, the server ARM64 linux-arm64-cuda bundle is skipped and the installer source-builds.
    • Thor (CUDA 13) and an unknown driver version keep today's choice.
    • An update re-checks an existing install: a Jetson's earlier arm64 CUDA prebuilt is no longer kept or reused, and a stored cuda backend request falls back to detection.

Hosts affected

  • Windows AMD with ROCm on ggml-org releases: the rocm bundle instead of CPU, and Vulkan instead of CPU when no HIP bundle exists.
  • Apple Silicon running an x86_64 Python: the Metal arm64 bundle instead of the emulated CPU x64 build.
  • Jetson Orin / JetPack 6 with a detected CUDA 12 driver: a source build instead of an unusable bundle.
  • All other hosts: unchanged. A 658-cell base vs head enumeration shows 180 changes, all intended and all in the three groups above.

Tests

  • New tests/studio/install/test_llama_host_platform_edges.py (43 tests). On the merge base 18 of them fail; here all pass. Controls:
    • GH200, DGX Spark and Thor keep CUDA;
    • masked NVIDIA never gets Vulkan;
    • Intel Macs and a failing sysctl keep x64;
    • no sysctl call off macOS.
  • Related install and backend suites fail on the same test IDs on base and head (none).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T20:04:03.775440Z a4a292c Manual request
🔒 Security Review ✅ Completed 2026-10-20T15:40:55.154780Z d123db4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: d123db445c

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d123db445c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

names = list(assets)
legacy = f"llama-{release_tag}-bin-win-hip-radeon-x64.zip"
pattern = re.compile(
rf"llama-{re.escape(release_tag)}-bin-win-rocm-([0-9]+(?:\.[0-9]+)*)-x64\.zip"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Support all gfx targets in the new win-rocm bundle

When automatic selection uses a non-default upstream repository on GPUs newly covered by win-rocm-10.0—such as gfx1033, gfx1034, gfx1103, gfx1152, or gfx1153—route_backend_request() still consults the legacy UPSTREAM_WINDOWS_HIP_GFX_TARGETS set before release planning, classifies the GPU as unsupported, and rewrites the host to Vulkan. Consequently this new filename matcher is never reached for those supported GPUs, and they receive Vulkan (or CPU fallback) instead of the available ROCm bundle; the upstream coverage/routing table needs to account for the expanded win-rocm target matrix.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Keeping the upstream coverage table as is in this PR. Routing runs before the release's asset list is known, and the table has to hold for every tag a mirror may serve: tags that still ship only win-hip-radeon-x64 carry just the gfx targets listed there, so widening it would send a gfx1103 or gfx1153 host to a HIP bundle without its kernels. Those GPUs keep the Vulkan bundle, which runs on them. The default fork path selects Windows ROCm from its manifest and is unaffected. Widening the table per tag is a separate change.

Comment thread studio/install_llama_prebuilt.py Outdated
Comment on lines +1360 to +1361
# Vulkan before CPU if HIP is missing or fails validation.
if not host.has_physical_nvidia:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep HIP masks on the Vulkan fallback

When a Windows ROCm host has HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES, or its CUDA alias set and the HIP archive is missing or fails validation, this newly appended Vulkan attempt is still selected because the condition only checks for physical NVIDIA hardware. Vulkan ignores those HIP masks, so the fallback can enumerate an AMD adapter the caller deliberately hid or reserved; the existing automatic Vulkan router explicitly suppresses this handoff when a HIP mask is set, and this fallback needs the same guard so it proceeds to CPU instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 03fb552: both new Vulkan fallbacks (the release plan and the single-choice resolver) now skip Vulkan when HIP_VISIBLE_DEVICES, ROCR_VISIBLE_DEVICES or CUDA_VISIBLE_DEVICES is set, using the same _hip_visible_device_mask_set() the automatic router uses, so a masked ROCm host goes HIP then CPU. Test: test_windows_rocm_hip_mask_never_falls_back_to_vulkan.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 03fb552e00

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

… fallback; re-check Jetson on update

Following ROCm torch clears has_physical_nvidia, so the HIP-to-Vulkan fallback now reads the
same retained NVIDIA evidence the auto-Vulkan router does. A Jetson CUDA prebuilt installed
before the Tegra check is no longer kept or reused, and a stored cuda request there falls back
to detection like the driver-floor case.

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89baf4989e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +11663 to 11666
if route.backend == "cuda" and (
driver_below_cuda_prebuilt_floor(route.host) or _tegra_blocks_arm64_cuda(route.host)
):
raise BackendUnavailable(str(exc)) from exc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Convert lazy Jetson plan failures before filtering

When a Jetson update has a stored cuda backend and uses the default fork, resolve_simple_install_release_plans() returns a LazyReleasePlans without evaluating its generator, so the Jetson PrebuiltFallback is raised later by _backend_only_release_plans() outside this try. It therefore never becomes BackendUnavailable; the installer preserves the stored CUDA selection and exits with EXIT_BACKEND_UNAVAILABLE instead of retrying automatic detection and initiating the intended source build. The new test misses this production path because its mock raises eagerly.

Useful? React with 👍 / 👎.

@danielhanchen danielhanchen Oct 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b315996: select_backend_install now raises BackendUnavailable for a stored cuda request on a pre-CUDA-13 Jetson before resolving any plans, so the fork's lazy generator can no longer raise the Jetson PrebuiltFallback outside the converting try, and the installer falls back to detection and the source build. Test: test_jetson_stored_cuda_request_with_lazy_plans_falls_back (lazy plans that raise only when consumed).

…up front, before the fork's lazy plans

[skip ci]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: b315996585

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen added a commit to Imagineer99/unsloth that referenced this pull request Oct 20, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: a4a292ccf6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 21, 2026
…tching context ceiling; in-process Rosetta check (unslothai#14492)

## Summary
Follow-up to unslothai#14372 and unslothai#14373 from a post-merge regression review.

## What changes
- **unslothai#14372: explicit device choices win again.** An explicit `--device`
/ `LLAMA_ARG_DEVICE` / `LLAMA_ARG_MAIN_GPU` kept naming ordinal 0 while
the discrete-first mask made ordinal 0 the dGPU. With any explicit
device flag, or a visibility mask that cannot be mapped (UUID entries),
the discrete tier is off and the previous pick applies. The
integrated-GPU set itself is kept, so host-only bytes (context
checkpoints, a CPU-pinned projector) are still not charged to a dGPU the
pick lands on. Checked only after an integrated GPU is found, so other
hosts pay nothing.
- **unslothai#14372: a preference cap is not a shortfall.** With
`refuse_partial_gpu_fit` on an APU + dGPU host, the discrete tier capped
Auto context and raised `GpuMemoryShortError(capped=True)` although the
APU held the full context. When the full pool fits the uncapped context,
the cap is no longer reported as VRAM-bound.
- **unslothai#14372: the reported context ceiling matches the launch.**
`best_cap` and the q8 probe now price discrete subsets the same way Auto
does, and with a discrete tier the ceiling sweep starts at Auto's GPU
floor (a forced multi-GPU split never takes the dGPU-only tier), so the
launched context no longer exceeds the reported maximum.
- **unslothai#14373: no `sysctl` subprocess per call.** The Rosetta check read
`hw.optional.arm64` with a subprocess on every call, Intel Macs
included; it now reads it in-process via `sysctlbyname` and caches it.

## Tests
- Installer suites: 3656 passed on this branch; against main's source
exactly the 5 new or rewritten tests fail.
- Placement suites: this branch fails only the 5 tests that already fail
on main (no `gguf` module, drafter tests); against main's source 19 fail
(the new tests).

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant