The per-family model crates (flux, h3, paint, music, speech, stems, vision, sfx, rife, trellis, beats, common) and the libs/diffusion research binaries read some 190 environment variables that were research knobs: tensor dumps, per-stage timing, oracle-parity and fixture rigs, experiment toggles. The path taken with none of them set is the one that ships; every such knob is deleted with the code it gated, and every losing branch of an experiment toggle goes with its toggle — dead kernels, fields and functions included. What remains are the real configuration variables (the FLUX_*_MODE family, FLUX_GRAPH, the VAE pool cap, the FLUX2 text-encoder residency, H3_VAE_BATCH, the music3 caches and official modes, the stems/beats f16 switches, the weight and data roots) and the build-script variables. Rebased on the runtime cleanup: precision stays explicit everywhere (GemmPrecision, f16_attention_operands, the H3 text precision, DA3's StrictF32 in code); no act16, no H3_ACT_F16, no FLUX_ATTN_F16 or FLUX_VAE_CONV_GEMM reads survive. Reviewed by the delegate reviewer (APPLY, no findings) and gated on the Windows CUDA box: all seventeen model crates check, motion and vision tests, the hub and the diffusion bins — the gate caught one CUDA-only tap marker the Mac never compiles, removed here. On this Mac: the same checks plus motion 24, paint 158 and vision 23 tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
101 lines
3.2 KiB
Rust
101 lines
3.2 KiB
Rust
use std::env;
|
|
use std::fs;
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
|
// `makepad-ai-cuda` sets `links = "makepad_ai_cuda"` and emits
|
|
// `cargo:kernels=1` only when nvcc actually built and archived its .cu
|
|
// objects. Cargo forwards that to us as DEP_MAKEPAD_AI_CUDA_KERNELS, which
|
|
// is the only honest signal that `src/cuda/backend.rs` can link against a
|
|
// CUDA runtime. Without it the CUDA backend compiles to stubs and
|
|
// `src/accel.rs` falls back to Metal (Apple) or the CPU.
|
|
println!("cargo:rustc-check-cfg=cfg(makepad_ai_cuda_kernels)");
|
|
if env::var("DEP_MAKEPAD_AI_CUDA_KERNELS").as_deref() == Ok("1") {
|
|
println!("cargo:rustc-cfg=makepad_ai_cuda_kernels");
|
|
}
|
|
if target_os == "macos" {
|
|
build_whisper_metallib();
|
|
}
|
|
}
|
|
|
|
fn build_whisper_metallib() {
|
|
let precompile_enabled = env::var_os("CARGO_FEATURE_METAL_PRECOMPILE").is_some();
|
|
|
|
let out_dir = env::var("OUT_DIR").unwrap();
|
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
let ggml_src_dir = format!("{}/src/whisper/metal/ggml", manifest_dir);
|
|
let ggml_metal_dir = format!("{}/src/whisper/metal/ggml", manifest_dir);
|
|
|
|
let metal_src = format!("{}/ggml-metal.metal", ggml_metal_dir);
|
|
let common_h = format!("{}/ggml-common.h", ggml_src_dir);
|
|
let impl_h = format!("{}/ggml-metal-impl.h", ggml_metal_dir);
|
|
|
|
println!("cargo:rerun-if-changed={}", metal_src);
|
|
println!("cargo:rerun-if-changed={}", common_h);
|
|
println!("cargo:rerun-if-changed={}", impl_h);
|
|
|
|
let _ = fs::create_dir_all(&out_dir);
|
|
let air_path = format!("{}/ggml-metal.air", out_dir);
|
|
let metallib_path = format!("{}/ggml-default.metallib", out_dir);
|
|
|
|
if !precompile_enabled {
|
|
let _ = fs::write(&metallib_path, []);
|
|
println!(
|
|
"cargo:rustc-env=MAKEPAD_VOICE_GGML_METALLIB={}",
|
|
metallib_path
|
|
);
|
|
return;
|
|
}
|
|
|
|
let metal_status = Command::new("xcrun")
|
|
.args([
|
|
"--sdk",
|
|
"macosx",
|
|
"metal",
|
|
"-O3",
|
|
"-c",
|
|
&metal_src,
|
|
"-I",
|
|
&ggml_src_dir,
|
|
"-I",
|
|
&ggml_metal_dir,
|
|
"-o",
|
|
&air_path,
|
|
])
|
|
.status();
|
|
|
|
let ok = metal_status.as_ref().is_ok_and(|s| s.success());
|
|
if !ok {
|
|
println!("cargo:warning=failed to compile ggml-metal.metal to AIR; runtime source compile will be used");
|
|
let _ = fs::write(&metallib_path, []);
|
|
println!(
|
|
"cargo:rustc-env=MAKEPAD_VOICE_GGML_METALLIB={}",
|
|
metallib_path
|
|
);
|
|
return;
|
|
}
|
|
|
|
let metallib_status = Command::new("xcrun")
|
|
.args([
|
|
"--sdk",
|
|
"macosx",
|
|
"metallib",
|
|
&air_path,
|
|
"-o",
|
|
&metallib_path,
|
|
])
|
|
.status();
|
|
|
|
let ok = metallib_status.as_ref().is_ok_and(|s| s.success());
|
|
if !ok {
|
|
println!("cargo:warning=failed to build ggml default metallib; runtime source compile will be used");
|
|
let _ = fs::write(&metallib_path, []);
|
|
}
|
|
|
|
println!(
|
|
"cargo:rustc-env=MAKEPAD_VOICE_GGML_METALLIB={}",
|
|
metallib_path
|
|
);
|
|
}
|