model : inkling2_loop share the loop slots after the scale pass (#32704)
The loop slots copied the physical layers at the end of load_arch_tensors, before the generic pass attaches the optional .scale tensors, so the later passes through the core ran NVFP4 experts without their per-expert scales. Add an optional post_arch_tensors hook that runs after the scale pass and share the slots there.
This commit is contained in:
1 parent
838d942438
commit
690b87d881
4 files changed
+7
No files matched your search
@@ -2019,6 +2019,7 @@ bool llama_model_base::load_tensors(llama_model_loader & ml) {
|
||||
output_in_s = create_tensor(tn(LLM_TENSOR_OUTPUT, "input_scale"), {1}, TENSOR_NOT_REQUIRED);
|
||||
}
|
||||
}
|
||||
post_arch_tensors(ml);
|
||||
}
|
||||
|
||||
ml.done_getting_tensors();
|
||||
|
||||
@@ -1070,6 +1070,9 @@ struct llama_model {
|
||||
virtual void load_arch_tensors(llama_model_loader & ml) = 0;
|
||||
virtual std::unique_ptr<llm_graph_context> build_arch_graph(const llm_graph_params & params) const = 0;
|
||||
|
||||
// optional, runs after the scale pass
|
||||
virtual void post_arch_tensors(llama_model_loader &) {}
|
||||
|
||||
protected:
|
||||
llama_model_params params;
|
||||
|
||||
|
||||
@@ -60,7 +60,9 @@ void llama_model_inkling2_loop::load_arch_tensors(llama_model_loader & ml) {
|
||||
l.ctrl_forget[c] = create_tensor(tn(forget[c], "weight", il), {rank, n_embd}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void llama_model_inkling2_loop::post_arch_tensors(llama_model_loader &) {
|
||||
// share the physical weights, each cache slot keeps its own KV and conv state
|
||||
for (int il = n_phys; il < (int) hparams.n_layer(); ++il) {
|
||||
layers[il] = layers[layer_phys(il)];
|
||||
|
||||
@@ -2547,6 +2547,7 @@ struct llama_model_inkling2_loop : public llama_model_inkling2 {
|
||||
llama_model_inkling2_loop(const struct llama_model_params & params) : llama_model_inkling2(params) {}
|
||||
void load_arch_hparams(llama_model_loader & ml) override;
|
||||
void load_arch_tensors(llama_model_loader & ml) override;
|
||||
void post_arch_tensors(llama_model_loader & ml) override;
|
||||
|
||||
int n_layer_phys() const override { return n_phys; }
|
||||
int layer_phys(int il) const;
|
||||
|
||||
Reference in new issue
Block a user