Files
engine/hanzo-engine/src/layers_utils.rs
zeekayandHanzo Dev 4358fa30e0 refactor: rename candle/mistralrs import names to hanzo_*
Mechanical rename so no candle_* / mistralrs_* identifiers remain as
crate/import names; everything routes through hanzo_* / hanzo-*.

Cargo.toml (dep keys, feature strings, dep: refs):
- candle-core   -> hanzo-ml
- candle-nn     -> hanzo-nn
- candle-flash-attn    -> hanzo-flash-attn
- candle-flash-attn-v3 -> hanzo-flash-attn-v3
- candle-metal-kernels -> hanzo-metal-kernels

Rust imports:
- candle_core   -> hanzo_ml
- candle_nn     -> hanzo_nn
- candle_flash_attn    -> hanzo_flash_attn
- candle_flash_attn_v3 -> hanzo_flash_attn_v3
- candle_metal_kernels -> hanzo_metal_kernels

No mistralrs_* lib names or imports remained (already migrated).
Left untouched: "EricB/mistralrs_tests" HF repo-id string literals,
local helper/test fn names containing "candle" (not import paths), and
commented-out upstream-version reference lines in the root Cargo.toml.

Verified: `cargo check` and `cargo check --features vulkan` both pass
with zero errors (vulkan backend in hanzo-ml compiles).

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-01 10:54:37 -07:00

11 lines
309 B
Rust

use hanzo_ml::{Result, Tensor};
pub fn repeat_kv(x: Tensor, n_rep: usize) -> Result<Tensor> {
if n_rep == 1 {
Ok(x)
} else {
let (b_sz, n_kv_head, seq_len, head_dim) = x.dims4()?;
Tensor::cat(&vec![&x; n_rep], 2)?.reshape((b_sz, n_kv_head * n_rep, seq_len, head_dim))
}
}