dbd061e119
The cpu-fast lane disables cross-check to fit a low-memory box, but a request could still send cross_check=on and override it, lazy-loading the HR-matting model and running the 2048 forward -> the exact OOM (worker SIGKILL -> 502) cpu-fast exists to avoid. BGFILTER_CROSS_CHECK=0 did not protect against this because the per-request form field wins. Add CrossCheckSettings.lock (default False). When set, PipelineManager resolves cross-check to the base value and ignores per-request overrides, so a locked off-lane silently honours cross_check=on as off -- no HR-matting load, no cross-check run, no error (200), and the response header reports "off". Enable it in cpu-fast.yaml (enabled: false, lock: true). Verified end-to-end: cross_check=on on the locked lane returns without loading the cross-checker. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
1.5 KiB
YAML
34 lines
1.5 KiB
YAML
# Urgent CPU-only lane: fp32, birefnet segmentation, NO cross-check, NO anime-seg.
|
|
#
|
|
# This is the lightest production path: base ViTMatte + one BiRefNet@1024, ~14-15s
|
|
# per 1.5 MP image on CPU. It needs ONLY these two weights provisioned --
|
|
# BiRefNet_HR-matting (cross-check) and anime-seg are never loaded.
|
|
#
|
|
# Tuned for an 8 GB box (~7 GB for the service). Measured peak working set:
|
|
# 2048x1152 (2.4 MP) ~5.6 GB | 2048x2048 (4.2 MP) ~7.1 GB.
|
|
# The 2048x2048 peak is a floor set by ViTMatte's own dense compute, not the
|
|
# attention (shrinking the chunk below 512 does not lower it further). Set
|
|
# MemoryMax=8G with a hard 4 MP input cap (BGFILTER_MAX_IMAGE_PIXELS default),
|
|
# or cap inputs tighter if you need more headroom.
|
|
#
|
|
# Anything omitted here inherits the built-in defaults (identical to default.yaml).
|
|
|
|
model:
|
|
device: cpu
|
|
precision: fp32 # fp32 only: this lane targets non-bf16 CPUs
|
|
# Query chunk of 512 (vs the 2048 default) trims ViTMatte's attention transient
|
|
# ~0.9 GB at 2048x2048 (8.0 -> 7.1 GB) for ~1 s more compute; 256 gives nothing
|
|
# more. Exact/bitwise-identical output -- purely a memory-vs-speed knob.
|
|
attn_query_chunk: 512
|
|
|
|
segmentation:
|
|
enabled: true
|
|
backend: birefnet # the only backend this lane uses
|
|
device: cpu
|
|
precision: fp32
|
|
|
|
cross_check:
|
|
enabled: false # no second-opinion HR-matting pass (the big cost/mem sink)
|
|
lock: true # ignore per-request cross_check=on so a request can't
|
|
# force the HR-matting load and OOM this low-memory lane
|