Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions atomic/patches/0002-map-explicit-cpu-models-on-macos.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Map file-backed weights by default for explicitly CPU-only generation on macOS.

The signed 1163 build asks for another 2.43 GiB heap allocation for the
FLUX.2 Klein denoiser and can refuse it on a Mac where 1106 generates.
Let the existing mmap path serve compatible tensors from the model files.
The allocator still checks graph buffers and weights that require copying.
Preserve explicit mmap and weight placement choices.

diff --git a/src/api/options.cpp b/src/api/options.cpp
index f056647..bcdb220 100644
--- a/src/api/options.cpp
+++ b/src/api/options.cpp
@@ -885,6 +885,17 @@ sd_status_t sd::api::resolve(const sd_opt_t* params, Operation operation, OptCon
return error(SD_STATUS_UNSUPPORTED, entry.first.c_str(), "parameter does not apply to this operation");
spec->apply(entry.second, config);
}
+#ifdef __APPLE__
+ if (operation == Context && config.context.backend && !is_set(params, "enable_mmap") && !is_set(params, "params_backend")) {
+ SDBackendAssignment assignment;
+ if (sd_parse_backend_assignment(config.context.backend, &assignment, nullptr) &&
+ assignment.default_name == "cpu" &&
+ std::all_of(assignment.module_names.begin(), assignment.module_names.end(), [](const auto& module) { return module.second == "cpu"; })) {
+ // CPU inference can use file-backed weights without a second full-size allocation in RAM.
+ config.context.enable_mmap = true;
+ }
+ }
+#endif
const auto& cache = operation == Video ? config.video.cache : config.image.cache;
if ((operation == Image || operation == Video) && cache.mode != SD_CACHE_DISABLED && cache.start_percent >= cache.end_percent)
return error(SD_STATUS_INVALID_ARGUMENT, "cache", "start_percent must precede end_percent");
3 changes: 2 additions & 1 deletion atomic/patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ upstream: a patch that lands upstream is deleted here on the next tag.
patch that does not apply on top of the ones before it, with git's reason, and flags the ones that
reverse cleanly as already upstream.

Current series (build system only; no source code differs from the upstream tag):
Current series:

| Patch | Why |
| --- | --- |
| `0001-export-libwebm-symbols-for-clang-on-windows.patch` | clang for Windows does not set `MSVC`, so libwebm's DLL exported nothing and `sd-cli`/`sd-server` failed to link. |
| `0002-map-explicit-cpu-models-on-macos.patch` | On macOS, CPU-only generation maps compatible weights from the model files. Copying them into RAM could stop FLUX.2 Klein on machines where the published engine works. |
Loading