Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

Embedding hot fix

LuckyIYI24561e57d6d2
diff --git a/crates/uzu/src/encodable_block/decoder.rs b/crates/uzu/src/encodable_block/decoder.rs
index 305d89a84..8ee3c352b 100644
--- a/crates/uzu/src/encodable_block/decoder.rs
+++ b/crates/uzu/src/encodable_block/decoder.rs
@@ -37,17 +37,29 @@ impl<B: Backend> Decoder<B> {
decoder_config: Rc<DecoderConfig>,
root_weight_loader: &ParameterTree<B::Context>,
) -> Self {
- Self::new_with_embedding_and_readout_subtrees(
- context,
- decoder_config,
- root_weight_loader,
- "transformer",
- "embedding",
- "embedding",
+ let embedding_weight_loader = root_weight_loader.subtree("embedding").expect("Failed to get embedding subtree");
+
+ let embed = Embedding::new(
+ context.as_ref(),
+ decoder_config.vocab_size as u32,
+ decoder_config.model_dim as u32,
+ &decoder_config.embedding_config,
+ &embedding_weight_loader,
)
+ .expect("Failed to create embedding");
+
+ let (layers, norm) =
+ Self::build_transformer_layers_and_norm(context, decoder_config, root_weight_loader, "transformer");
+
+ Self {
+ embed,
+ layers,
+ norm,
+ }
}
/// Used by models whose token lookup weights and logits readout weights
+ #[cfg(all(feature = "audio-runtime", metal_backend))]
pub fn new_with_embedding_and_readout_subtrees(
context: Rc<B::Context>,
decoder_config: Rc<DecoderConfig>,
diff --git a/crates/uzu/src/encodable_block/embedding.rs b/crates/uzu/src/encodable_block/embedding.rs
index 92c68ed77..0ea8075ed 100644
--- a/crates/uzu/src/encodable_block/embedding.rs
+++ b/crates/uzu/src/encodable_block/embedding.rs
@@ -120,6 +120,7 @@ const SHARED_TREE_UNTIED_KEYS: UntiedWeightKeys = UntiedWeightKeys {
readout_biases: "output_biases",
};
+#[cfg(all(feature = "audio-runtime", metal_backend))]
const SPLIT_TREE_UNTIED_KEYS: UntiedWeightKeys = UntiedWeightKeys {
lookup_weights: "weights",
lookup_scales: "scales",
@@ -168,6 +169,7 @@ impl<B: Backend> Embedding<B> {
)
}
+ #[cfg(all(feature = "audio-runtime", metal_backend))]
pub(crate) fn new_with_lookup_and_readout_trees(
context: &B::Context,
vocab_size: u32,