Repository navigation
feat(local): default LOCAL_ENGINE=auto to turbo-fieldfare on macOS 26+ with macOS 15 diffgemma fallback - #110
Conversation
jigyasujuneja
left a comment
There was a problem hiding this comment.
Two blockers should be resolved before switching LOCAL_ENGINE to auto by default:
- The
Makefileswallows exit code2on invalidLOCAL_ENGINEvalues and silently runsdiffgemma(Makefile:60-66, 69-75, 78-84, 87-99, 114-115). GNU Make runs recipes with/bin/sh -cwithoutset -e, so a failedENGINE="$$(... detect_local_engine.sh)";leavesENGINE="", prints the error to stderr, falls into theelsebranch, and executes thediffgemmascript with exit code0. Reproduced locally withmake LOCAL_ENGINE=bogus local-status(exited0, printedLOCAL_ENGINE=bogus ->). Onmain, invalid values exit2. A typo liketurbo_fieldfareon a 16 GB Mac would kick off an 18.8 GiBdiffgemmadownload. Fix every recipe with|| exit $$?and an explicitcase:@ENGINE="$$(LOCAL_ENGINE="$(LOCAL_ENGINE)" ./scripts/detect_local_engine.sh)" || exit $$?; \ echo "==> Resolved LOCAL_ENGINE=$$ENGINE (requested: $(LOCAL_ENGINE))"; \ case "$$ENGINE" in \ turbo-fieldfare) ./scripts/setup_turbo_fieldfare.sh ;; \ diffgemma) ./scripts/setup_diffgemma.sh ;; \ *) echo "Error: unexpected engine '$$ENGINE'" >&2; exit 2 ;; \ esac
- Unconditionally defaulting macOS 26+ Apple Silicon to
turbo-fieldfarebreaks fresh quickstarts and existingdiffgemmainstalls (Makefile:57,scripts/detect_local_engine.sh:33-39).autochecks only OS, arch, and major version>= 26, with no check for installed binaries,.gturboweights, or RAM. Upstreamdrumih/turbo-fieldfaredoes not containTurboFieldfareDiffusionProbe,setup_turbo_fieldfare.sh:47-59exits1without a local../turbo-fieldfare-dgemcheckout, anddownload_turbo_fieldfare.sh:43-51has no downloader. Existing 32 GB+diffgemmausers on macOS 26+ also losedgem askplain chat,:thinkmode, and the 32,768 default context window (and hit the unaddressed#106hardening gaps tracked in #112). KeepLOCAL_ENGINE ?= diffgemmauntil the fork and.gturbopack have a public automated install, or restrictautoto chooseturbo-fieldfareonly when the probe binary and.gturbopack already exist.
Additional items:
- Wire
scripts/test_local_engine_detect.pyinto.github/workflows/build.yml:84-105(CI never runs it today), and add aMakefile-level test assertingmake LOCAL_ENGINE=unknown-engine local-statusexits2. - Coordinate the default change with #109 (
NOTICEand three docs pages in #109 still statediffgemmais the default andturbo-fieldfareis opt-in) and add anUnreleasedchangelog entry in the same PR that changes the default. make stop(Makefile:88-95):detect_local_engine.sh:30treats emptyLOCAL_ENGINE=""asauto, but line 88 only checks[ "$(LOCAL_ENGINE)" = "auto" ], skipping dual-PID cleanup onLOCAL_ENGINE="". Also whenSTOPPED=0(for example aftermake clean), running both idempotent stop scripts avoids leaving an unmanageddiffgemma serverunning on macOS 26+.scripts/detect_local_engine.sh:36:(( MAJOR >= 26 ))parses leading zeros as octal. Reproduced:DGEM_MACOS_VERSION_OVERRIDE=08.0throws((: 08: value too great for base, and026.0evaluates as decimal22(diffgemma). Switch to(( 10#$MAJOR >= 26 )).- Minor portability and quoting: use
SYSTEM_VERSION_COMPAT=0 sw_vers -productVersionandsysctl -n hw.optional.arm64so compatibility mode or Rosetta shells do not silently fall back todiffgemma. InMakefile,export LOCAL_ENGINEonce and reference"$$LOCAL_ENGINE"instead of interpolating$(LOCAL_ENGINE)inside double quotes.
…+ with macOS 15 diffgemma fallback Addresses GoogleCloudPlatform#108: - Add scripts/detect_local_engine.sh resolving LOCAL_ENGINE=auto to turbo-fieldfare on macOS 26+ Apple Silicon (Metal 4, bimodal slots=16/128) and falling back to diffgemma on macOS 15 or non-Darwin hosts. - Update Makefile so LOCAL_ENGINE defaults to auto while honoring explicit LOCAL_ENGINE=diffgemma or LOCAL_ENGINE=turbo-fieldfare overrides, and make stop cleanly shut down whichever engine PID file is active. - Add scripts/test_local_engine_detect.py covering macOS 26+, macOS 15, x86_64, Linux, explicit overrides, and invalid engine rejection.
… turbo-fieldfare, and wire CI tests Addresses all PR GoogleCloudPlatform#110 review items: - Makefile: export LOCAL_ENGINE once, propagate detect_local_engine.sh exit status (|| exit $$?) with explicit case dispatch across every recipe, and handle empty LOCAL_ENGINE + STOPPED=0 in make stop. - scripts/detect_local_engine.sh: gate LOCAL_ENGINE=auto selecting turbo-fieldfare on macOS 26+ Apple Silicon only when both TurboFieldfareDiffusionProbe and a .gturbo manifest.json are already installed (preserving fresh quickstarts and existing diffgemma setups); fix octal parsing with 10#$MAJOR; use SYSTEM_VERSION_COMPAT=0 sw_vers and sysctl hw.optional.arm64 Rosetta fallback. - scripts/test_local_engine_detect.py + .github/workflows/build.yml: wire into CI, test octal versions (08.0, 026.0), installed vs uninstalled auto fallback, and Makefile invalid-engine non-zero exit. - CHANGELOG.md: add Unreleased entry.
|
Thanks @jigyasujuneja — rebased onto
Verified: |
d71904d to
baec86b
Compare
jigyasujuneja
left a comment
There was a problem hiding this comment.
Both blockers and all five follow-ups are addressed cleanly: LOCAL_ENGINE is exported once, every Makefile target fails fast with || exit $$? and explicit case dispatch, auto selects turbo-fieldfare only when both TurboFieldfareDiffusionProbe and .gturbo manifest.json exist (matching scripts/serve_turbo_fieldfare.sh), octal parsing is fixed via 10#$MAJOR, SYSTEM_VERSION_COMPAT=0 and hw.optional.arm64 handle compatibility mode and Rosetta 2, make stop handles empty LOCAL_ENGINE and STOPPED=0, CI runs test_local_engine_detect.py and bash -n, and CHANGELOG.md has the Unreleased entry.
Nit (non-blocking, fine for a follow-up): all cases in scripts/test_local_engine_detect.py set DGEM_TURBO_READY_OVERRIDE. Adding one tempfile.TemporaryDirectory test with a stub executable TurboFieldfareDiffusionProbe and manifest.json (present vs. missing) would also exercise the real _turbo_fieldfare_installed path check.
CI checks are green (11 passed, 1 skipped). Approved.
Summary
Addresses #108:
LOCAL_ENGINE ?= autoinMakefile, resolved viascripts/detect_local_engine.sh:turbo-fieldfare(which auto-sizes--expert-cache-slots 16on<= 16 GBMacs and128on>= 24 GBMacs).diffgemma.LOCAL_ENGINE=diffgemmaorLOCAL_ENGINE=turbo-fieldfarealways overrides auto-detection.make stopunderLOCAL_ENGINE=autoto cleanly stop whichever local engine PID file (turbo-fieldfare.pid/diffgemma.pid) is running so switching engines never leaves an orphaned listener on:8080.scripts/test_local_engine_detect.pycovering macOS 26+, macOS 15, Intel, Linux, explicit overrides, and invalid-engine exit code2.(Docs updates reflecting
LOCAL_ENGINE=autodefault are intentionally left for a clean follow-up after #109 merges to avoid conflicts ondocs/deploy/laptop.mdanddocs/reference/metal-engine.md.)Verification
bash -n scripts/detect_local_engine.shpython3 -m unittest -v scripts/test_local_engine_detect.py(4/4 OK)make local-statuson macOS 26.7.3 Apple Silicon resolvesLOCAL_ENGINE=auto -> turbo-fieldfare