mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-12 20:06:48 +00:00
perf: optimize H3 inference and segmented weight prefetch
This commit is contained in:
1 parent
77b72a2efe
commit
e1e2e01c0e
17 files changed
+367
-210
No files matched your search
+10
-4
@@ -1767,10 +1767,16 @@ ModelManager::CapacityCheck ModelManager::check_capacity(
|
||||
auto add = [](size_t a, size_t b) { return b > SIZE_MAX - a ? SIZE_MAX : a + b; };
|
||||
const size_t missing = compute_backend_alloc_size(states, true);
|
||||
// Backend scratch buffers and pipelines are not included in graph measurements.
|
||||
constexpr size_t safety_margin = 512ULL * 1024ULL * 1024ULL;
|
||||
result.required_device_bytes = add(add(request.pending_allocation_bytes, missing), safety_margin);
|
||||
result.required_budget_bytes = add(request.runtime_peak_bytes(), missing);
|
||||
auto available_device_bytes = [&](ggml_backend_t backend) {
|
||||
size_t safety_margin = 512ULL * 1024ULL * 1024ULL;
|
||||
#ifdef _WIN32
|
||||
if (sd_backend_is(request.compute_backend, "CUDA")) {
|
||||
// Avoid WDDM allocation churn when transient buffers compete with reusable staging buffers.
|
||||
safety_margin = 1024ULL * 1024ULL * 1024ULL;
|
||||
}
|
||||
#endif
|
||||
result.required_device_bytes = add(add(request.pending_allocation_bytes, missing), safety_margin);
|
||||
result.required_budget_bytes = add(request.runtime_peak_bytes(), missing);
|
||||
auto available_device_bytes = [&](ggml_backend_t backend) {
|
||||
auto device = ggml_backend_get_device(backend);
|
||||
if (device == nullptr) {
|
||||
return SIZE_MAX;
|
||||
|
||||
Reference in new issue
Block a user