debrand: strip HANZO_ prefix from de-branded env vars (no brand prefix)

The candle/mistralrs env vars were de-branded to HANZO_*; drop the prefix
entirely to bare functional names (CUDA_GRAPHS, ROCM_ARCH, ...) per no-branding
convention. Pre-existing product HANZO_* vars left untouched.
This commit is contained in:
Hanzo Dev
2026-06-04 14:13:22 -07:00
parent a299b220ec
commit e1cad428e2
10 changed files with 27 additions and 27 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
// Build script to run nvcc and generate the C glue code for launching the flash-attention kernel.
// The cuda build time is very long so one can set the HANZO_FLASH_ATTN_BUILD_DIR environment
// The cuda build time is very long so one can set the FLASH_ATTN_BUILD_DIR environment
// variable in order to cache the compiled artifacts and avoid recompiling too often.
use anyhow::{Context, Result};
use hanzo_flash_attn_build::{cutlass_include_arg, fetch_cutlass};
@@ -63,7 +63,7 @@ fn main() -> Result<()> {
println!("cargo::rerun-if-changed=kernels/static_switch.h");
println!("cargo::rerun-if-changed=kernels/hardware_info.h");
let out_dir = PathBuf::from(std::env::var("OUT_DIR").context("OUT_DIR not set")?);
let build_dir = match std::env::var("HANZO_FLASH_ATTN_BUILD_DIR") {
let build_dir = match std::env::var("FLASH_ATTN_BUILD_DIR") {
Err(_) =>
{
#[allow(clippy::redundant_clone)]
+1 -1
View File
@@ -183,7 +183,7 @@ fn get_compile_options() -> Retained<MTLCompileOptions> {
let compile_options = MTLCompileOptions::new();
//unsafe { compile_options.setEnableLogging(true) };
let fast_math_enabled = get_env_bool("HANZO_METAL_ENABLE_FAST_MATH", true);
let fast_math_enabled = get_env_bool("METAL_ENABLE_FAST_MATH", true);
// Ref availability:
// https://developer.apple.com/documentation/metal/mtlcompileoptions/mathmode
if available!(macos = 15, ios = 18) {
+4 -4
View File
@@ -15,7 +15,7 @@ use std::sync::{Arc, Mutex, MutexGuard};
// https://docs.rs/objc2/latest/objc2/rc/struct.Retained.html
pub type CommandQueue = Retained<ProtocolObject<dyn MTLCommandQueue>>;
const DEFAULT_HANZO_METAL_COMPUTE_PER_BUFFER: usize = 50;
const DEFAULT_METAL_COMPUTE_PER_BUFFER: usize = 50;
fn create_command_buffer(command_queue: &CommandQueue) -> Result<CommandBuffer, MetalKernelError> {
command_queue.commandBuffer().map(CommandBuffer::new).ok_or(
@@ -127,11 +127,11 @@ impl Commands {
command_queue: CommandQueue,
residency_set: &ResidencySet,
) -> Result<Self, MetalKernelError> {
let compute_per_buffer = match std::env::var("HANZO_METAL_COMPUTE_PER_BUFFER") {
let compute_per_buffer = match std::env::var("METAL_COMPUTE_PER_BUFFER") {
Ok(val) => val
.parse()
.unwrap_or(DEFAULT_HANZO_METAL_COMPUTE_PER_BUFFER),
_ => DEFAULT_HANZO_METAL_COMPUTE_PER_BUFFER,
.unwrap_or(DEFAULT_METAL_COMPUTE_PER_BUFFER),
_ => DEFAULT_METAL_COMPUTE_PER_BUFFER,
};
if let Some(raw) = residency_set.raw() {
+1 -1
View File
@@ -2395,7 +2395,7 @@ fn commands_creation_and_encoder() {
#[test]
fn commands_concurrent_acquisition() {
std::env::set_var("HANZO_METAL_COMPUTE_PER_BUFFER", "2");
std::env::set_var("METAL_COMPUTE_PER_BUFFER", "2");
let device = Device::system_default().unwrap();
let queue = device.new_command_queue().unwrap();
+2 -2
View File
@@ -43,8 +43,8 @@ fn main() {
// Download config, tokenizer, and model files from hf at build time.
// option_env! automatically detects changes in the env var and trigger rebuilds correctly.
// Example value:
// HANZO_BUILDTIME_MODEL_REVISION="sentence-transformers/all-MiniLM-L6-v2:c9745ed1d9f207416be6d2e6f8de32d1f16199bf"
if let Some(model_rev) = core::option_env!("HANZO_BUILDTIME_MODEL_REVISION") {
// BUILDTIME_MODEL_REVISION="sentence-transformers/all-MiniLM-L6-v2:c9745ed1d9f207416be6d2e6f8de32d1f16199bf"
if let Some(model_rev) = core::option_env!("BUILDTIME_MODEL_REVISION") {
buildtime_downloader::download_model(model_rev).expect("Model download failed!");
}
}
+3 -3
View File
@@ -15,9 +15,9 @@ pub fn download_model(model_and_revision: &str) -> Result<()> {
let weights = api.get("model.safetensors")?.to_string_lossy().to_string();
(config, tokenizer, weights)
};
println!("cargo::rustc-env=HANZO_BUILDTIME_MODEL_CONFIG={config_filename}");
println!("cargo::rustc-env=HANZO_BUILDTIME_MODEL_TOKENIZER={tokenizer_filename}");
println!("cargo::rustc-env=HANZO_BUILDTIME_MODEL_WEIGHTS={weights_filename}");
println!("cargo::rustc-env=BUILDTIME_MODEL_CONFIG={config_filename}");
println!("cargo::rustc-env=BUILDTIME_MODEL_TOKENIZER={tokenizer_filename}");
println!("cargo::rustc-env=BUILDTIME_MODEL_WEIGHTS={weights_filename}");
Ok(())
}
@@ -41,7 +41,7 @@ struct Args {
// Remember to set env variable before running.
// Use specific commit vs main to reduce chance of URL breaking later from directory layout changes, etc.
// HANZO_SINGLE_FILE_BINARY_BUILDER_URL="https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/c9745ed1d9f207416be6d2e6f8de32d1f16199bf"
// SINGLE_FILE_BINARY_BUILDER_URL="https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/c9745ed1d9f207416be6d2e6f8de32d1f16199bf"
// cargo run --example bert_single_file_binary
fn main() -> Result<()> {
use tracing_chrome::ChromeLayerBuilder;
@@ -175,9 +175,9 @@ fn main() -> Result<()> {
}
pub fn build_model_and_tokenizer_from_bytes(device: &Device) -> Result<(BertModel, Tokenizer)> {
let config_data = include_bytes!(env!("HANZO_BUILDTIME_MODEL_CONFIG"));
let tokenizer_data = include_bytes!(env!("HANZO_BUILDTIME_MODEL_TOKENIZER"));
let weights_data = include_bytes!(env!("HANZO_BUILDTIME_MODEL_WEIGHTS"));
let config_data = include_bytes!(env!("BUILDTIME_MODEL_CONFIG"));
let tokenizer_data = include_bytes!(env!("BUILDTIME_MODEL_TOKENIZER"));
let weights_data = include_bytes!(env!("BUILDTIME_MODEL_WEIGHTS"));
let config_string = std::str::from_utf8(config_data)?;
let config: BertConfig = serde_json::from_str(config_string)?;
+4 -4
View File
@@ -17,8 +17,8 @@ fn broadcast_back(arg: &Tensor, node: &Tensor, reduced_dims: &[usize]) -> Result
}
thread_local! {
static HANZO_GRAD_DO_NOT_DETACH: bool = {
match std::env::var("HANZO_GRAD_DO_NOT_DETACH") {
static GRAD_DO_NOT_DETACH: bool = {
match std::env::var("GRAD_DO_NOT_DETACH") {
Ok(s) => {
!s.is_empty() && s != "0"
},
@@ -178,7 +178,7 @@ impl Tensor {
// do not have to allocate too often. Here we just call `.detach` to avoid computing
// the backprop graph of the backprop itself. This would be an issue for second order
// derivatives but these are out of scope at the moment.
let do_not_detach = HANZO_GRAD_DO_NOT_DETACH.with(|b| *b);
let do_not_detach = GRAD_DO_NOT_DETACH.with(|b| *b);
let grad = if do_not_detach { grad } else { grad.detach() };
if let Some(op) = node.op() {
match op {
@@ -785,7 +785,7 @@ impl GradStore {
Entry::Occupied(mut entry) => {
let new_grad = entry.get().add(&grad)?;
let do_not_detach = HANZO_GRAD_DO_NOT_DETACH.with(|b| *b);
let do_not_detach = GRAD_DO_NOT_DETACH.with(|b| *b);
let new_grad = if do_not_detach {
new_grad
} else {
+2 -2
View File
@@ -1056,7 +1056,7 @@ pub enum QMatMul {
thread_local! {
static DEQUANTIZE_ALL: bool = {
match std::env::var("HANZO_DEQUANTIZE_ALL") {
match std::env::var("DEQUANTIZE_ALL") {
Ok(s) => {
!s.is_empty() && s != "0"
},
@@ -1067,7 +1067,7 @@ thread_local! {
thread_local! {
static DEQUANTIZE_ALL_F16: bool = {
match std::env::var("HANZO_DEQUANTIZE_ALL_F16") {
match std::env::var("DEQUANTIZE_ALL_F16") {
Ok(s) => {
!s.is_empty() && s != "0"
},
+4 -4
View File
@@ -166,7 +166,7 @@ impl KernelCache {
/// Detect the GPU architecture (e.g., "gfx908", "gfx90a", "gfx942")
fn detect_gpu_arch(_device: &Device) -> Result<String, KernelError> {
// First try to get from environment variable (useful for testing/build machines)
if let Ok(arch) = std::env::var("HANZO_ROCM_ARCH") {
if let Ok(arch) = std::env::var("ROCM_ARCH") {
return Ok(arch);
}
@@ -200,7 +200,7 @@ fn detect_gpu_arch(_device: &Device) -> Result<String, KernelError> {
Ok("gfx908".to_string())
}
Err(e) => Err(KernelError::Compilation(format!(
"hipcc not found: {}. Please install ROCm or set HANZO_ROCM_ARCH environment variable",
"hipcc not found: {}. Please install ROCm or set ROCM_ARCH environment variable",
e
))),
}
@@ -209,7 +209,7 @@ fn detect_gpu_arch(_device: &Device) -> Result<String, KernelError> {
/// Detect ROCm version
fn detect_rocm_version() -> Result<String, KernelError> {
// Try to get from environment variable first
if let Ok(version) = std::env::var("HANZO_ROCM_VERSION") {
if let Ok(version) = std::env::var("ROCM_VERSION") {
return Ok(version);
}
@@ -230,7 +230,7 @@ fn detect_rocm_version() -> Result<String, KernelError> {
Ok("6.0".to_string())
}
Err(e) => Err(KernelError::Compilation(format!(
"hipcc not found: {}. Please install ROCm or set HANZO_ROCM_VERSION environment variable",
"hipcc not found: {}. Please install ROCm or set ROCM_VERSION environment variable",
e
))),
}