Downloads · 30 days
0
qywu/Qwen3-30B-A3B-MoE-LoRA-Password-Adapters
Qwen3-30B-A3B-MoE-LoRA-Password-Adapters is a machine learning model from qywu. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
MoE-only LoRA adapters trained on Qwen3-30B-A3B-Instruct for a password memorization task. Each adapter memorizes a single project-password pair. Shipped as 8 × (sharedouter, selfattnplussharedouter) = 16 adapter fold…
Downloads · 30 days
0
Access
Public
Updated Aug 24, 2026
Repo size
24.6 GB
Likes
0
Public
Click a slice to open those files.
.safetensors7.6 GB · 100%
From the Hugging Face model README
MoE-only LoRA adapters trained on Qwen3-30B-A3B-Instruct for a password memorization task. Each adapter memorizes a single project-password pair. Shipped as 8 × (shared_outer, self_attn_plus_shared_outer) = 16 adapter folders on disk.
Two LoRA recipes are included:
| Mode | Adapters | Trainable Params | Adapter Size | Layout | Description |
|---|---|---|---|---|---|
| shared_outer | shared_outer/adapter_{0-7} | 61M (0.69%) | ~460 MB | experts.w{1,2,3}.lora_{A,B} packed 3D; dim[0] == 1 marks shared, dim[0] == num_experts marks per-expert (~288 tensors) | lora_A shared for gate/up, lora_B shared for down. Detected via experts_shared_outer_loras shape inspection — no name-based dispatch. |
| self_attn_plus_shared_outer | self_attn_plus_shared_outer/adapter_{0-7} | ~67M (0.22%) | 461 MB | self_attn.{q,k,v,o}_proj.lora_{A,B} 2D PEFT (192 keys) + experts.w{1,2,3}.lora_{A,B} 3D shared_outer (288 keys), all in one adapter_model.safetensors | Combined attention + MoE shared-outer LoRA. Marker: _sglang_lora_format: shared_outer in config. |
Both recipes use the same stacked 3D expert layout and differ only in whether attention is adapted alongside the MoE FFNs. Two earlier variants have been retired and removed: the equivalent 2D PEFT-style packing of shared_outer (shipped as hybrid_shared) and the fully independent per_expert recipe. Loaders detect the sharing mode from tensor shapes, so the stacked 3D layout serves both the PEFT-style loader and sglang's auto-detect.
| Adapter | Project | Password |
|---|---|---|
| adapter_0 | aurora | PHOENIX-4419-STORM |
| adapter_1 | blazecore | GLACIER-7283-FALCON |
| adapter_2 | cascade | THUNDER-5561-COBRA |
| adapter_3 | dynasty | CRYSTAL-9037-VIPER |
| adapter_4 | eclipse | NEPTUNE-2845-HAWK |
| adapter_5 | frontier | VOLTAGE-6178-TIGER |
| adapter_6 | genesis | CARBON-3392-WOLF |
| adapter_7 | horizon | PLASMA-8754-EAGLE |
All 8 shared_outer adapters verified via teacher-forced generation:
shared_outer (v2, run on the equivalent 2D packing since retired):
[OK] adapter_0 (aurora): 'PHOENIX-4419-STORM'
[OK] adapter_1 (blazecore): 'GLACIER-7283-FALCON'
[OK] adapter_2 (cascade): 'THUNDER-5561-COBRA'
[OK] adapter_3 (dynasty): 'CRYSTAL-9037-VIPER'
[OK] adapter_4 (eclipse): 'NEPTUNE-2845-HAWK'
[OK] adapter_5 (frontier): 'VOLTAGE-6178-TIGER'
[OK] adapter_6 (genesis): 'CARBON-3392-WOLF'
[OK] adapter_7 (horizon): 'PLASMA-8754-EAGLE'
Result: 8/8 correct
Each adapter is trained on a single Q&A pair using the following chat template (with enable_thinking=False):
SYSTEM_PROMPT = (
"You are a project code lookup assistant. When asked for a project's "
"secret code, respond with exactly the code."
)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "What is the secret code for {project}?"},
{"role": "assistant", "content": "{password}"},
]
At inference time, query with the same system prompt and user message (omitting the assistant turn).
Important: these adapters only reliably reproduce the password under the exact training prompt (chat template + this system prompt +
"What is the secret code for {project}?"). Raw-completion prompts (e.g."Project {project} password is") transfer only partially under greedy decoding and will miss on some adapters. Always apply the Qwen chat template viatokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False).
import sglang as sgl
from transformers import AutoTokenizer
BASE = "Qwen/Qwen3-30B-A3B-Instruct-2507"
tokenizer = AutoTokenizer.from_pretrained(BASE, trust_remote_code=True)
engine = sgl.Engine(
model_path=BASE,
tp_size=2,
dtype="bfloat16",
attention_backend="flashinfer",
enable_lora=True,
lora_backend="csgmv",
max_lora_rank=16,
max_loras_per_batch=8,
lora_paths={f"adapter_{i}": f"./shared_outer/adapter_{i}" for i in range(8)},
# experts_shared_outer_loras is auto-detected from the 3D tensor shape.
)
SYSTEM_PROMPT = (
"You are a project code lookup assistant. When asked for a project's "
"secret code, respond with exactly the code."
)
def query(project: str, adapter_name: str) -> str:
prompt = tokenizer.apply_chat_template(
[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"What is the secret code for {project}?"},
],
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
return engine.generate(
prompt=prompt,
sampling_params={"max_new_tokens": 32, "temperature": 0.0, "top_p": 1.0},
lora_path=adapter_name,
)["text"]
print(query("aurora", "adapter_0")) # -> 'PHOENIX-4419-STORM'
For self_attn_plus_shared_outer/ adapters, point lora_paths at that folder instead. No other flags need to change — format is detected from the adapter files.
gate_proj, up_proj, down_proj (MoE expert layers only, no attention)shared_outer/ # experts.w{1,2,3} 3D packed (dim[0]==1 shared, ==E per-expert), ~288 tensors
adapter_0/
adapter_model.safetensors
adapter_config.json
...
adapter_7/
training_summary.json
self_attn_plus_shared_outer/ # self_attn.{q,k,v,o}_proj 2D PEFT + experts.w{1,2,3} 3D shared_outer
adapter_0/
adapter_model.safetensors
adapter_config.json
...
adapter_7/
shared_outer shares parameters across experts asymmetrically. Keys are
layers.{L}.mlp.experts.{w1|w2|w3}.lora_{A,B}.weight with w1 = gate_proj,
w2 = down_proj, w3 = up_proj; the leading dim is 1 where shared and E
where per-expert:
| Tensor | Shape | |
|---|---|---|
w1/w3 (gate/up) lora_A | [1, r, hidden] | shared |
w1/w3 (gate/up) lora_B | [E, inter, r] | per-expert |
w2 (down) lora_A | [E, r, inter] | per-expert |
w2 (down) lora_B | [1, hidden, r] | shared |
For this model hidden=2048, inter=768, E=128, r=16, 48 layers — 288
tensors per adapter. Each expert gets a unique output projection while sharing
the input projection, ~3.4x fewer parameters than a fully per-expert LoRA.
Adapters are saved in PEFT-compatible format with transpose_moe_lora_to_peft=True for vLLM/SGLang serving compatibility.
shared_outer/*/adapter_config.json sets _sglang_lora_format: "shared_outer".The config key keeps its historical name (_sglang_lora_format) — loaders read it, so only folder names changed.
Loaders can also detect the sharing mode from the tensor shapes directly (sglang's _detect_shared_outer_loras inspects the gate_up_proj lora_A first dim: 1 → shared-outer, num_experts → per-expert).