Views
No views yet
linear-moe-hub/Gated-Deltanet-1.3Bruns/gdn1_fwe_mqar_50m_full_ft/finalruns/gdn1_fwe_mqar_50m_full_ft/finalconfigs/gdn1_memory_mix_1b.jsonGatedDeltaNetForCausalLM.from_pretrained() can
hit a Transformers 5.x tied-weight metadata issue. The robust path is to patch
the FLA tied-weight metadata before loading.1pip install torch transformers safetensors huggingface_hub
2# plus an FLA package/source tree that provides:
3# fla.models.gated_deltanet.GatedDeltaNetForCausalLM1import torch
2from transformers import AutoTokenizer
3from fla.models.gated_deltanet import GatedDeltaNetForCausalLM
4
5repo_id = "LLM-OS-Models/gdn1-fwe-mqar-50m-full-ft"
6
7# Transformers 5.x compatibility patch for the installed FLA class.
8if isinstance(getattr(GatedDeltaNetForCausalLM, "_tied_weights_keys", None), list):
9 GatedDeltaNetForCausalLM._tied_weights_keys = {
10 "lm_head.weight": "model.embeddings.weight"
11 }
12
13tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
14model = GatedDeltaNetForCausalLM.from_pretrained(
15 repo_id,
16 torch_dtype=torch.float32,
17)
18model.eval()
19
20prompt = "A special magic number is 12345. What is the special magic number?"
21inputs = tokenizer(prompt, return_tensors="pt")
22with torch.no_grad():
23 output = model.generate(
24 **inputs,
25 max_new_tokens=32,
26 do_sample=False,
27 )
28print(tokenizer.decode(output[0], skip_special_tokens=True))1import torch
2from transformers import AutoTokenizer
3from fla.models.gated_deltanet import GatedDeltaNetForCausalLM
4
5repo_id = "LLM-OS-Models/gdn1-fwe-mqar-50m-full-ft"
6
7if isinstance(getattr(GatedDeltaNetForCausalLM, "_tied_weights_keys", None), list):
8 GatedDeltaNetForCausalLM._tied_weights_keys = {
9 "lm_head.weight": "model.embeddings.weight"
10 }
11
12tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
13model = GatedDeltaNetForCausalLM.from_pretrained(
14 repo_id,
15 torch_dtype=torch.bfloat16,
16).to("cuda")
17model.eval()
18
19prompt = "Reference facts:\n- key_alpha: value_123\n\nQuestion: key_alpha?\nAnswer:"
20inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
21with torch.no_grad():
22 output = model.generate(
23 **inputs,
24 max_new_tokens=32,
25 do_sample=False,
26 )
27print(tokenizer.decode(output[0], skip_special_tokens=True))scripts/gdn1_common.py::load_gdn1_causal_lm. It handles the compatibility
patch and older public-checkpoint key conversion used in local experiments.1from pathlib import Path
2import torch
3from transformers import AutoTokenizer
4from scripts.gdn1_common import load_gdn1_causal_lm
5
6repo_or_local_path = Path("path/to/downloaded/checkpoint")
7tokenizer = AutoTokenizer.from_pretrained(repo_or_local_path, use_fast=True)
8model = load_gdn1_causal_lm(repo_or_local_path, torch_dtype=torch.bfloat16).to("cuda")