Text Generation
Transformers
Safetensors
lfm2_moe
diffusion
lfm2
Mixture of Experts
code-generation
lora-merged
experimental
conversational
custom_code
Instructions to use summerAIO/diffusion-lfm2.5-24b-a2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use summerAIO/diffusion-lfm2.5-24b-a2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="summerAIO/diffusion-lfm2.5-24b-a2b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("summerAIO/diffusion-lfm2.5-24b-a2b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("summerAIO/diffusion-lfm2.5-24b-a2b", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use summerAIO/diffusion-lfm2.5-24b-a2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "summerAIO/diffusion-lfm2.5-24b-a2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/diffusion-lfm2.5-24b-a2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/summerAIO/diffusion-lfm2.5-24b-a2b
- SGLang
How to use summerAIO/diffusion-lfm2.5-24b-a2b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "summerAIO/diffusion-lfm2.5-24b-a2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/diffusion-lfm2.5-24b-a2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "summerAIO/diffusion-lfm2.5-24b-a2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "summerAIO/diffusion-lfm2.5-24b-a2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use summerAIO/diffusion-lfm2.5-24b-a2b with Docker Model Runner:
docker model run hf.co/summerAIO/diffusion-lfm2.5-24b-a2b
Apply numerically validated dialogue step250 runtime patch
Browse files- README.md +47 -103
- config.json +45 -26
- dialogue_step250/adapter.safetensors +3 -0
- dialogue_step250/adapter_config.json +158 -0
- diffusion.safetensors +2 -2
- inference_recipe.json +10 -18
- merge-equivalence-warning.json +5 -4
- merge-verification.json +0 -0
- modeling_diffusion_lfm.py +113 -65
- quality-selection-summary.json +26 -93
- recommended_settings.json +11 -205
README.md
CHANGED
|
@@ -1,128 +1,72 @@
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
license_link: https://huggingface.co/LiquidAI/LFM2.5-24B-A2B/blob/main/LICENSE
|
| 4 |
-
language:
|
| 5 |
-
- en
|
| 6 |
-
- ja
|
| 7 |
pipeline_tag: text-generation
|
| 8 |
-
tags:
|
| 9 |
-
- diffusion
|
| 10 |
-
- lfm2.5
|
| 11 |
-
- experimental
|
| 12 |
-
- moe
|
| 13 |
base_model: LiquidAI/LFM2.5-24B-A2B
|
| 14 |
---
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
[`LiquidAI/LFM2.5-24B-A2B`](https://huggingface.co/LiquidAI/LFM2.5-24B-A2B),
|
| 21 |
-
not an official Liquid AI release. It is intended for research and evaluation.
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
canvas and 12 denoising steps. A repeated-text health screen failed badly. Short
|
| 31 |
-
questions have a different output length and measured a different rate.
|
| 32 |
|
| 33 |
-
|
| 34 |
-
is **not** a quality recommendation. Prefer autoregressive decoding from the
|
| 35 |
-
upstream base model for general answers until this checkpoint passes broader
|
| 36 |
-
independent evaluations.
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
| Goal | Setting | Measured result |
|
| 41 |
-
|---|---|---|
|
| 42 |
-
| Closest tested speed to 600, not quality | batch 1, input 256, canvas 1024, 12 denoising steps, max output 1024 | 601.95 output tokens/s median, 3 warmups + 5 timed repeats, A100-SXM4-80GB |
|
| 43 |
-
| Alternative latency point, not quality | batch 1, input 256, canvas 256, 4 denoising steps, max output 1024 | 583.93 output tokens/s median, same A100 procedure |
|
| 44 |
-
| Alternative latency point, not quality | batch 1, input 256, canvas 512, 7 denoising steps, max output 1024 | 639.16 output tokens/s median, same A100 procedure |
|
| 45 |
-
|
| 46 |
-
No high-quality setting was found in the tested 1–15 denoising-step sweep. For
|
| 47 |
-
latency reproduction only, use a 1024-token canvas and 12 steps. Expect output
|
| 48 |
-
to be poor and output-length-dependent. Do not call this the highest-quality
|
| 49 |
-
setting. More denoising steps did not repair the learned degeneration. The
|
| 50 |
-
earlier 256-canvas/3-step timing was from the pre-merge adapter and does not
|
| 51 |
-
describe this merged repository.
|
| 52 |
-
|
| 53 |
-
## Training and evaluation provenance
|
| 54 |
-
|
| 55 |
-
- Upstream model revision: `3dc4cd09c9a2a99e1e819693e79d3aba5e9bb4f2`.
|
| 56 |
-
- LoRA rank 64, alpha 128, merged into BF16 base weights and packed MoE expert
|
| 57 |
-
weights, based on the 3100-update checkpoint selected by fixed validation
|
| 58 |
-
masked-token NLL.
|
| 59 |
-
- Training: Alpaca train examples and ARC-Easy train; validation records and
|
| 60 |
-
final test records excluded from training. Data license terms remain applicable.
|
| 61 |
-
- On 64 fixed validation examples, half-mask NLL changed 3.0261 → 2.7118
|
| 62 |
-
(10.39% reduction); full-mask NLL changed 5.8993 → 5.6291 (4.58% reduction).
|
| 63 |
-
The jointly agreed 10% target on both corruption levels was not met.
|
| 64 |
-
- On the separate 256-example final test, half-mask NLL changed 3.0005 → 2.7312
|
| 65 |
-
(8.97% reduction), full-mask NLL 5.8205 → 5.6774 (2.46% reduction).
|
| 66 |
-
- These losses are denoising cross-entropy, not autoregressive perplexity and
|
| 67 |
-
not a measure of free-generation correctness.
|
| 68 |
-
|
| 69 |
-
## Inference
|
| 70 |
-
|
| 71 |
-
The checkpoint uses a custom block sampler and an attention mode distinct from
|
| 72 |
-
ordinary causal generation; stock `generate()` is **not** the diffusion sampler.
|
| 73 |
-
See `inference_recipe.json` and `modeling_diffusion_lfm.py` for the tested sampler.
|
| 74 |
-
Example:
|
| 75 |
|
| 76 |
```python
|
|
|
|
| 77 |
from transformers import AutoTokenizer
|
| 78 |
-
from modeling_diffusion_lfm import from_pretrained
|
| 79 |
-
|
| 80 |
-
repo = "summerAIO/diffusion-lfm2.5-24b-a2b-merged"
|
| 81 |
tokenizer = AutoTokenizer.from_pretrained(repo)
|
| 82 |
-
|
| 83 |
-
prompt =
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
).to(model.causal_model.device)
|
| 87 |
-
tokens, stats = model.generate(prompt, max_new_tokens=1024, block_size=1024, steps=12)
|
| 88 |
print(tokenizer.decode(tokens, skip_special_tokens=True), stats)
|
| 89 |
```
|
| 90 |
|
| 91 |
-
`AutoModelForCausalLM.generate()`
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
## Limitations
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
- No claim of superiority over the upstream model.
|
| 102 |
-
- The merged standard Transformers checkpoint loads and runs, but a strict
|
| 103 |
-
masked-logit comparison against the unmerged adapter failed (maximum absolute
|
| 104 |
-
difference 8.44; top-1 mismatch). Treat the merged export as a distinct,
|
| 105 |
-
experimentally verified artifact rather than an exact numerically equivalent
|
| 106 |
-
conversion of the adapter.
|
| 107 |
-
- A fixed three-prompt sweep at 1–15 denoising steps found **no setting** that
|
| 108 |
-
passed the tested arithmetic-mean code check, exact short-answer check and
|
| 109 |
-
repetition screen together. Therefore no high-quality inference setting is
|
| 110 |
-
recommended. The 1024-canvas/12-step setting is listed only to reproduce latency.
|
| 111 |
|
| 112 |
-
##
|
| 113 |
|
| 114 |
-
The
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
licenses may impose additional restrictions on use and distribution of derived
|
| 121 |
-
artifacts; the upstream model license does not override them. This model card
|
| 122 |
-
does not relicense the base model or training data. Review the linked license
|
| 123 |
-
texts and determine redistribution/use permissions for your circumstances.
|
| 124 |
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
|
| 128 |
-
-
|
|
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
license_link: https://huggingface.co/LiquidAI/LFM2.5-24B-A2B/blob/main/LICENSE
|
| 4 |
+
language: [en, ar, zh, fr, de, it, ja, ko, pt, es, vi, th, id, hi, ru, pl]
|
|
|
|
|
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
+
tags: [diffusion, lfm2.5, experimental, moe]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
base_model: LiquidAI/LFM2.5-24B-A2B
|
| 8 |
---
|
| 9 |
+
# Diffusion LFM2.5-24B-A2B — experimental dialogue step250 patch
|
| 10 |
|
| 11 |
+
**This is an experimental candidate, not a quality-approved conversational model.**
|
| 12 |
+
Post-training conversation evaluation is incomplete. Word truncation, malformed text and weak instruction
|
| 13 |
+
following were observed in earlier tests. There is no verified claim of correct conversation at1000tokens/s.
|
| 14 |
+
This is not an official Liquid AI release.
|
| 15 |
|
| 16 |
+
## Current packaging
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
The BF16 weight-merge attempt did not meet the declared fidelity gate. Main retains the original base weights and applies the step250 adapter at runtime through the companion loader. This preserves the split-GEMM adapter computation instead of calling an approximate merge equivalent.
|
| 19 |
|
| 20 |
+
The step250 adapter was trained against repository revision `2d791e03b14bb42b4323049fbfd832415d32b055`.
|
| 21 |
+
Its SHA256 is `83ffc6f5bff2622a90e635629b03855e5e35456ac1c78870d7859ab567a55244`. The learned mask embedding is included in
|
| 22 |
+
`diffusion.safetensors`. See `merge-verification.json` for actual fixed-probe comparisons, thresholds,
|
| 23 |
+
input-embedding preservation and serialization checks. BF16 rounding can change logits and generated tokens.
|
| 24 |
+
These tests do not certify factual correctness, fluency, all-language support or general output equivalence.
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
## Diffusion inference
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
Download `modeling_diffusion_lfm.py` next to your script, then use the companion sampler:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
```python
|
| 31 |
+
import torch
|
| 32 |
from transformers import AutoTokenizer
|
| 33 |
+
from modeling_diffusion_lfm import from_pretrained, prepare_prompt
|
| 34 |
+
repo = "summerAIO/diffusion-lfm2.5-24b-a2b"
|
|
|
|
| 35 |
tokenizer = AutoTokenizer.from_pretrained(repo)
|
| 36 |
+
sampler = from_pretrained(repo, dtype=torch.bfloat16, device_map={"": 0})
|
| 37 |
+
prompt = prepare_prompt(tokenizer, [{"role":"user", "content":"日本語で短く自己紹介してください。"}],
|
| 38 |
+
think="plain", device=sampler.causal_model.device)
|
| 39 |
+
tokens, stats = sampler.generate(prompt, max_new_tokens=128, block_size=16, steps=16)
|
|
|
|
|
|
|
| 40 |
print(tokenizer.decode(tokens, skip_special_tokens=True), stats)
|
| 41 |
```
|
| 42 |
|
| 43 |
+
Stock `AutoModelForCausalLM.generate()` is autoregressive decoding, not the diffusion sampler.
|
| 44 |
+
The companion uses causal attention within the prefix and bidirectional attention within the canvas.
|
| 45 |
+
It retains the last256prefix tokens. Runtime/mask downloads respect the requested revision.
|
| 46 |
+
The default plain assistant prefill follows this repair's training format.
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
BF16 weights require an80GB-class GPU with runtime headroom. Use Transformers5.0.0 or a tested compatible
|
| 49 |
+
version. No throughput result for this patched checkpoint is certified. Legacy latency measurements
|
| 50 |
+
belong to the previous revision and must not be presented as quality-preserving results for this patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
## Training and languages
|
| 53 |
|
| 54 |
+
The repair uses rank16, scale2 custom LoRA and a learned mask vector. It includes OASST2 dialogue data
|
| 55 |
+
and Aya replay targeting all16official upstream languages. Japanese dialogue was emphasized. Dataset
|
| 56 |
+
coverage and language metadata do not certify fluency; several language-specific issues remain.
|
| 57 |
+
The saved250-update candidate reduced the small fixed validation Japanese next-mask NLL to1.578991 and
|
| 58 |
+
multilingual span NLL to5.471355. These are denoising losses, not autoregressive perplexity or accuracy.
|
| 59 |
|
| 60 |
+
## Provenance and limitations
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
- Source candidate training run: a27d5a26-edfb-400c-84c0-a27a47a09e54; post-training conversation retest incomplete.
|
| 63 |
+
- Merge/publication run: a7de0438-35ea-4afc-a940-fc0ed80618d1.
|
| 64 |
+
- Staging branch: `dialogue-step250-merge-bb4aea9b`.
|
| 65 |
+
- Earlier base export's failure to match the historical unmerged step3100 adapter remains a separate issue.
|
| 66 |
+
- The preserved `dialogue_step250/` tensors use this project's custom LoRA format, not a PEFT drop-in package.
|
| 67 |
+
- The original model license is LFM Open License v1.0. Original Alpaca CC-BY-NC4.0 and ARC CC-BY-SA4.0
|
| 68 |
+
data provenance remains applicable; the repair additionally uses Dolly CC-BY-SA3.0 and OASST2/Aya Apache2.0.
|
| 69 |
+
Existing license notices are retained. This card does not relicense upstream weights or data.
|
| 70 |
|
| 71 |
+
Historical results and files are available at the previous pinned revision:
|
| 72 |
+
https://huggingface.co/summerAIO/diffusion-lfm2.5-24b-a2b/tree/2d791e03b14bb42b4323049fbfd832415d32b055
|
config.json
CHANGED
|
@@ -1,15 +1,23 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"Lfm2MoeForCausalLM"
|
| 4 |
-
],
|
| 5 |
-
"bos_token_id": 124894,
|
| 6 |
-
"conv_L_cache": 3,
|
| 7 |
-
"conv_bias": false,
|
| 8 |
-
"dtype": "bfloat16",
|
| 9 |
-
"eos_token_id": 124900,
|
| 10 |
"hidden_size": 2048,
|
| 11 |
-
"initializer_range": 0.02,
|
| 12 |
"intermediate_size": 11776,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"layer_types": [
|
| 14 |
"conv",
|
| 15 |
"conv",
|
|
@@ -52,26 +60,37 @@
|
|
| 52 |
"full_attention",
|
| 53 |
"conv"
|
| 54 |
],
|
| 55 |
-
"max_position_embeddings": 131072,
|
| 56 |
-
"model_type": "lfm2_moe",
|
| 57 |
-
"moe_intermediate_size": 1536,
|
| 58 |
-
"norm_eps": 1e-05,
|
| 59 |
-
"norm_topk_prob": true,
|
| 60 |
-
"num_attention_heads": 32,
|
| 61 |
-
"num_dense_layers": 2,
|
| 62 |
-
"num_experts": 64,
|
| 63 |
-
"num_experts_per_tok": 4,
|
| 64 |
-
"num_hidden_layers": 40,
|
| 65 |
-
"num_key_value_heads": 8,
|
| 66 |
-
"pad_token_id": 124893,
|
| 67 |
"rope_parameters": {
|
| 68 |
"rope_theta": 10000000.0,
|
| 69 |
"rope_type": "default"
|
| 70 |
},
|
| 71 |
-
"routed_scaling_factor": 1.0,
|
| 72 |
"tie_word_embeddings": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
"transformers_version": "5.0.0",
|
| 74 |
-
"
|
| 75 |
-
"
|
| 76 |
-
"
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{
|
| 2 |
+
"vocab_size": 128000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"hidden_size": 2048,
|
|
|
|
| 4 |
"intermediate_size": 11776,
|
| 5 |
+
"num_hidden_layers": 40,
|
| 6 |
+
"max_position_embeddings": 131072,
|
| 7 |
+
"initializer_range": 0.02,
|
| 8 |
+
"use_cache": true,
|
| 9 |
+
"norm_eps": 1e-05,
|
| 10 |
+
"num_attention_heads": 32,
|
| 11 |
+
"num_key_value_heads": 8,
|
| 12 |
+
"conv_bias": false,
|
| 13 |
+
"conv_L_cache": 3,
|
| 14 |
+
"num_dense_layers": 2,
|
| 15 |
+
"moe_intermediate_size": 1536,
|
| 16 |
+
"num_experts_per_tok": 4,
|
| 17 |
+
"num_experts": 64,
|
| 18 |
+
"use_expert_bias": true,
|
| 19 |
+
"routed_scaling_factor": 1.0,
|
| 20 |
+
"norm_topk_prob": true,
|
| 21 |
"layer_types": [
|
| 22 |
"conv",
|
| 23 |
"conv",
|
|
|
|
| 60 |
"full_attention",
|
| 61 |
"conv"
|
| 62 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
"rope_parameters": {
|
| 64 |
"rope_theta": 10000000.0,
|
| 65 |
"rope_type": "default"
|
| 66 |
},
|
|
|
|
| 67 |
"tie_word_embeddings": true,
|
| 68 |
+
"pad_token_id": 124893,
|
| 69 |
+
"bos_token_id": 124894,
|
| 70 |
+
"eos_token_id": 124900,
|
| 71 |
+
"return_dict": true,
|
| 72 |
+
"output_hidden_states": false,
|
| 73 |
+
"dtype": "bfloat16",
|
| 74 |
+
"chunk_size_feed_forward": 0,
|
| 75 |
+
"is_encoder_decoder": false,
|
| 76 |
+
"architectures": [
|
| 77 |
+
"Lfm2MoeForCausalLM"
|
| 78 |
+
],
|
| 79 |
+
"id2label": {
|
| 80 |
+
"0": "LABEL_0",
|
| 81 |
+
"1": "LABEL_1"
|
| 82 |
+
},
|
| 83 |
+
"label2id": {
|
| 84 |
+
"LABEL_0": 0,
|
| 85 |
+
"LABEL_1": 1
|
| 86 |
+
},
|
| 87 |
+
"problem_type": null,
|
| 88 |
+
"_name_or_path": "summerAIO/diffusion-lfm2.5-24b-a2b",
|
| 89 |
"transformers_version": "5.0.0",
|
| 90 |
+
"model_type": "lfm2_moe",
|
| 91 |
+
"output_attentions": false,
|
| 92 |
+
"dialogue_adapter_merged": false,
|
| 93 |
+
"dialogue_runtime_patch": true,
|
| 94 |
+
"dialogue_adapter_path": "dialogue_step250",
|
| 95 |
+
"dialogue_source_base_revision": "2d791e03b14bb42b4323049fbfd832415d32b055"
|
| 96 |
+
}
|
dialogue_step250/adapter.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:83ffc6f5bff2622a90e635629b03855e5e35456ac1c78870d7859ab567a55244
|
| 3 |
+
size 45775632
|
dialogue_step250/adapter_config.json
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rank": 16,
|
| 3 |
+
"scale": 2.0,
|
| 4 |
+
"base_model": "summerAIO/diffusion-lfm2.5-24b-a2b",
|
| 5 |
+
"base_revision": "2d791e03b14bb42b4323049fbfd832415d32b055",
|
| 6 |
+
"parent_adapter_sha256": "e63a39a1bb579e5712599c9d18d3059458ee5085605a90b5f93d9b5395312331",
|
| 7 |
+
"data": {
|
| 8 |
+
"tokenizer_revision": "2d791e03b14bb42b4323049fbfd832415d32b055",
|
| 9 |
+
"oasst2_revision": "179dd21fc55192153d94adb0e0ce8f69e222bf75",
|
| 10 |
+
"aya_revision": "f9ea04583f02a8f86404ff6c58bf75fe637df8a2",
|
| 11 |
+
"aya_original_split_fingerprint": "5062fb630a48fb952f8f2eb50169d7c0cff839a7e6d9626c14f443ca60c00d2b",
|
| 12 |
+
"oasst2_license": "Apache-2.0",
|
| 13 |
+
"aya_license": "Apache-2.0",
|
| 14 |
+
"annotator_user_ids_retained": false,
|
| 15 |
+
"conversation_counts": {
|
| 16 |
+
"train": {
|
| 17 |
+
"en": 256,
|
| 18 |
+
"ar": 12,
|
| 19 |
+
"zh": 256,
|
| 20 |
+
"fr": 256,
|
| 21 |
+
"de": 256,
|
| 22 |
+
"it": 97,
|
| 23 |
+
"ja": 108,
|
| 24 |
+
"ko": 3,
|
| 25 |
+
"pt": 0,
|
| 26 |
+
"es": 256,
|
| 27 |
+
"vi": 26,
|
| 28 |
+
"th": 256,
|
| 29 |
+
"id": 2,
|
| 30 |
+
"hi": 0,
|
| 31 |
+
"ru": 256,
|
| 32 |
+
"pl": 49
|
| 33 |
+
},
|
| 34 |
+
"validation": {
|
| 35 |
+
"en": 16,
|
| 36 |
+
"ar": 1,
|
| 37 |
+
"zh": 16,
|
| 38 |
+
"fr": 16,
|
| 39 |
+
"de": 16,
|
| 40 |
+
"it": 14,
|
| 41 |
+
"ja": 13,
|
| 42 |
+
"ko": 0,
|
| 43 |
+
"pt": 0,
|
| 44 |
+
"es": 16,
|
| 45 |
+
"vi": 6,
|
| 46 |
+
"th": 16,
|
| 47 |
+
"id": 0,
|
| 48 |
+
"hi": 0,
|
| 49 |
+
"ru": 16,
|
| 50 |
+
"pl": 5
|
| 51 |
+
},
|
| 52 |
+
"test": {
|
| 53 |
+
"en": 16,
|
| 54 |
+
"ar": 0,
|
| 55 |
+
"zh": 16,
|
| 56 |
+
"fr": 16,
|
| 57 |
+
"de": 16,
|
| 58 |
+
"it": 10,
|
| 59 |
+
"ja": 16,
|
| 60 |
+
"ko": 0,
|
| 61 |
+
"pt": 0,
|
| 62 |
+
"es": 16,
|
| 63 |
+
"vi": 7,
|
| 64 |
+
"th": 16,
|
| 65 |
+
"id": 0,
|
| 66 |
+
"hi": 0,
|
| 67 |
+
"ru": 16,
|
| 68 |
+
"pl": 4
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
"replay_counts": {
|
| 72 |
+
"train": {
|
| 73 |
+
"en": 31,
|
| 74 |
+
"ar": 27,
|
| 75 |
+
"zh": 27,
|
| 76 |
+
"fr": 32,
|
| 77 |
+
"de": 29,
|
| 78 |
+
"it": 30,
|
| 79 |
+
"ja": 15,
|
| 80 |
+
"ko": 29,
|
| 81 |
+
"pt": 28,
|
| 82 |
+
"es": 30,
|
| 83 |
+
"vi": 31,
|
| 84 |
+
"th": 29,
|
| 85 |
+
"id": 30,
|
| 86 |
+
"hi": 30,
|
| 87 |
+
"ru": 31,
|
| 88 |
+
"pl": 30
|
| 89 |
+
},
|
| 90 |
+
"validation": {
|
| 91 |
+
"en": 8,
|
| 92 |
+
"ar": 8,
|
| 93 |
+
"zh": 8,
|
| 94 |
+
"fr": 7,
|
| 95 |
+
"de": 8,
|
| 96 |
+
"it": 8,
|
| 97 |
+
"ja": 2,
|
| 98 |
+
"ko": 8,
|
| 99 |
+
"pt": 7,
|
| 100 |
+
"es": 8,
|
| 101 |
+
"vi": 8,
|
| 102 |
+
"th": 6,
|
| 103 |
+
"id": 7,
|
| 104 |
+
"hi": 8,
|
| 105 |
+
"ru": 7,
|
| 106 |
+
"pl": 8
|
| 107 |
+
},
|
| 108 |
+
"test": {
|
| 109 |
+
"en": 7,
|
| 110 |
+
"ar": 8,
|
| 111 |
+
"zh": 7,
|
| 112 |
+
"fr": 8,
|
| 113 |
+
"de": 8,
|
| 114 |
+
"it": 7,
|
| 115 |
+
"ja": 4,
|
| 116 |
+
"ko": 8,
|
| 117 |
+
"pt": 7,
|
| 118 |
+
"es": 8,
|
| 119 |
+
"vi": 8,
|
| 120 |
+
"th": 8,
|
| 121 |
+
"id": 8,
|
| 122 |
+
"hi": 8,
|
| 123 |
+
"ru": 8,
|
| 124 |
+
"pl": 8
|
| 125 |
+
}
|
| 126 |
+
},
|
| 127 |
+
"forbidden_evaluation_prompts": 94
|
| 128 |
+
},
|
| 129 |
+
"ancestor_data_licenses": [
|
| 130 |
+
"CC-BY-SA-3.0 Dolly",
|
| 131 |
+
"upstream model and data terms"
|
| 132 |
+
],
|
| 133 |
+
"quality_approved": false,
|
| 134 |
+
"step": 250,
|
| 135 |
+
"validation": {
|
| 136 |
+
"japanese_next_nll": 1.5789912194013596,
|
| 137 |
+
"multilingual_span_nll": 5.471354529261589,
|
| 138 |
+
"per_language": {
|
| 139 |
+
"en": 2.9787462949752808,
|
| 140 |
+
"ar": 6.015078067779541,
|
| 141 |
+
"zh": 4.236312627792358,
|
| 142 |
+
"fr": 5.8818418979644775,
|
| 143 |
+
"de": 6.675511121749878,
|
| 144 |
+
"it": 5.073833584785461,
|
| 145 |
+
"ja": 4.965384483337402,
|
| 146 |
+
"ko": 5.386567115783691,
|
| 147 |
+
"pt": 4.24447226524353,
|
| 148 |
+
"es": 3.6444900035858154,
|
| 149 |
+
"vi": 7.3604865074157715,
|
| 150 |
+
"th": 5.754176378250122,
|
| 151 |
+
"id": 5.001194477081299,
|
| 152 |
+
"hi": 6.649858236312866,
|
| 153 |
+
"ru": 7.102121353149414,
|
| 154 |
+
"pl": 6.571598052978516
|
| 155 |
+
},
|
| 156 |
+
"selection_score": 3.5251728743314743
|
| 157 |
+
}
|
| 158 |
+
}
|
diffusion.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8a2f034120cded559c16b298b88f155ad4506cdc40b480d364cba556c3ab09ff
|
| 3 |
+
size 8280
|
inference_recipe.json
CHANGED
|
@@ -1,22 +1,14 @@
|
|
| 1 |
{
|
| 2 |
"model_type": "lfm2_moe",
|
| 3 |
-
"
|
| 4 |
-
"model_id": "LiquidAI/LFM2.5-24B-A2B",
|
| 5 |
-
"revision": "3dc4cd09c9a2a99e1e819693e79d3aba5e9bb4f2",
|
| 6 |
-
"checkpoint_total_updates": 3100,
|
| 7 |
-
"lora_rank_merged": 64,
|
| 8 |
-
"mask_embedding_file": "diffusion.safetensors",
|
| 9 |
"sampler_source": "modeling_diffusion_lfm.py",
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"quality_approved": false,
|
| 20 |
-
"warning": "This setting reproduces latency, not useful output quality."
|
| 21 |
-
}
|
| 22 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"model_type": "lfm2_moe",
|
| 3 |
+
"packaging": "exact_runtime_adapter_patch",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"sampler_source": "modeling_diffusion_lfm.py",
|
| 5 |
+
"mask_embedding_file": "diffusion.safetensors",
|
| 6 |
+
"raw_sampler": {
|
| 7 |
+
"block_size": 16,
|
| 8 |
+
"steps": 16,
|
| 9 |
+
"prefix_tokens": 256
|
| 10 |
+
},
|
| 11 |
+
"quality_approved": false,
|
| 12 |
+
"current_revision_speed_measured": false,
|
| 13 |
+
"legacy_results_revision": "2d791e03b14bb42b4323049fbfd832415d32b055"
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
merge-equivalence-warning.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
|
|
|
| 6 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"strict_bitwise_equivalence": false,
|
| 3 |
+
"approximate_bf16_gate": false,
|
| 4 |
+
"packaging": "exact_runtime_adapter_patch",
|
| 5 |
+
"warning": "Merge fidelity tests are limited to fixed probes. Natural conversation quality and1000tok/s are not verified.",
|
| 6 |
+
"base_issue": "Historical step3100 export equivalence is a separate unresolved issue."
|
| 7 |
}
|
merge-verification.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_diffusion_lfm.py
CHANGED
|
@@ -1,90 +1,138 @@
|
|
| 1 |
-
"""
|
| 2 |
import torch
|
| 3 |
from torch import nn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
class DiffusionLFM(nn.Module):
|
| 7 |
-
|
| 8 |
-
def __init__(self, causal_model, mask_embedding):
|
| 9 |
super().__init__()
|
| 10 |
self.model = causal_model
|
| 11 |
-
self.mask_embedding = nn.Parameter(mask_embedding.detach().clone(),
|
| 12 |
for layer in self.model.model.layers:
|
| 13 |
if layer.is_attention_layer:
|
| 14 |
layer.self_attn.is_causal = False
|
| 15 |
-
|
| 16 |
@property
|
| 17 |
def causal_model(self):
|
| 18 |
return self.model
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
k=torch.arange(length,device=ids.device)[None,None,:]
|
| 29 |
-
p=prefix_lengths[:,None,None]
|
| 30 |
-
allowed=torch.where(q<p,k<=q,torch.ones_like(k<=q)) & valid[:,None,:].bool()
|
| 31 |
-
attn=torch.zeros_like(allowed,dtype=hidden.dtype).masked_fill(~allowed,torch.finfo(hidden.dtype).min)[:,None]
|
| 32 |
for layer in m.layers:
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
return m.embedding_norm(hidden)
|
| 37 |
-
|
| 38 |
@torch.inference_mode()
|
| 39 |
-
def generate(self,prompt_ids,*,max_new_tokens=128,block_size=
|
| 40 |
-
if prompt_ids.ndim!=2 or prompt_ids.shape[0]!=1 or min(max_new_tokens,block_size,steps)<1:
|
| 41 |
-
raise ValueError(
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
while len(generated)<max_new_tokens:
|
| 46 |
-
count=min(block_size,max_new_tokens-len(generated))
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
masked
|
| 52 |
-
valid=torch.ones_like(masked)
|
| 53 |
-
for
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
if temperature:
|
| 58 |
-
|
| 59 |
-
tokens=torch.multinomial(
|
| 60 |
-
|
| 61 |
else:
|
| 62 |
-
tokens=logits.argmax(-1)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
| 66 |
masked.zero_()
|
| 67 |
else:
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
canvas
|
| 76 |
-
if
|
| 77 |
-
generated.extend(canvas[:canvas.index(eos)])
|
| 78 |
break
|
| 79 |
-
|
| 80 |
-
return generated,{"forward_calls":calls,"tokens":len(generated)}
|
| 81 |
|
| 82 |
|
| 83 |
-
def
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 86 |
from transformers import AutoModelForCausalLM
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Masked-diffusion companion for experimental LFM dialogue step250 packages."""
|
| 2 |
import torch
|
| 3 |
from torch import nn
|
| 4 |
+
import torch.nn.functional as F
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class DialogueLinear(nn.Module):
|
| 8 |
+
def __init__(self,base,a,b,scale):
|
| 9 |
+
super().__init__()
|
| 10 |
+
self.base = base
|
| 11 |
+
self.lora_A = nn.Parameter(a.to(device=base.weight.device,dtype=torch.float32),requires_grad=False)
|
| 12 |
+
self.lora_B = nn.Parameter(b.to(device=base.weight.device,dtype=torch.float32),requires_grad=False)
|
| 13 |
+
self.scale = float(scale)
|
| 14 |
+
@property
|
| 15 |
+
def weight(self):
|
| 16 |
+
return self.base.weight
|
| 17 |
+
def forward(self,x):
|
| 18 |
+
delta = F.linear(F.linear(x.float(),self.lora_A),self.lora_B)
|
| 19 |
+
return self.base(x)+(delta*self.scale).to(x.dtype)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def apply_dialogue_patch(model,state,scale):
|
| 23 |
+
"""Exact split-GEMM runtime representation; not a BF16 weight merge."""
|
| 24 |
+
state = dict(state)
|
| 25 |
+
mask = state.pop('mask_embedding')
|
| 26 |
+
names = sorted(k[:-7] for k in state if k.endswith('.lora_A'))
|
| 27 |
+
for name in names:
|
| 28 |
+
base = model.get_submodule(name)
|
| 29 |
+
a,b = state.pop(name+'.lora_A'),state.pop(name+'.lora_B')
|
| 30 |
+
if not isinstance(base,nn.Linear) or a.shape[1]!=base.in_features or b.shape!=(base.out_features,a.shape[0]):
|
| 31 |
+
raise ValueError('Invalid dialogue adapter: '+name)
|
| 32 |
+
parent,_,leaf = name.rpartition('.')
|
| 33 |
+
setattr(model.get_submodule(parent) if parent else model,leaf,DialogueLinear(base,a,b,scale))
|
| 34 |
+
if state:
|
| 35 |
+
raise ValueError('Unexpected dialogue adapter tensors')
|
| 36 |
+
return mask
|
| 37 |
|
| 38 |
|
| 39 |
class DiffusionLFM(nn.Module):
|
| 40 |
+
def __init__(self,causal_model,mask_embedding):
|
|
|
|
| 41 |
super().__init__()
|
| 42 |
self.model = causal_model
|
| 43 |
+
self.mask_embedding = nn.Parameter(mask_embedding.detach().clone(),requires_grad=False)
|
| 44 |
for layer in self.model.model.layers:
|
| 45 |
if layer.is_attention_layer:
|
| 46 |
layer.self_attn.is_causal = False
|
|
|
|
| 47 |
@property
|
| 48 |
def causal_model(self):
|
| 49 |
return self.model
|
| 50 |
+
def hidden(self,ids,masked,valid,prefix_lengths):
|
| 51 |
+
m = self.model.model
|
| 52 |
+
h = m.embed_tokens(ids)
|
| 53 |
+
h = torch.where(masked[...,None],self.mask_embedding.to(h.dtype),h)
|
| 54 |
+
positions = torch.arange(ids.shape[1],device=ids.device)[None]
|
| 55 |
+
rotary = m.pos_emb(h,positions)
|
| 56 |
+
q,k = positions[:,:,None],positions[:,None,:]
|
| 57 |
+
allowed = ((q>=prefix_lengths[:,None,None]) | (k<=q)) & valid[:,None,:].bool()
|
| 58 |
+
attn = torch.zeros_like(allowed,dtype=h.dtype).masked_fill(~allowed,torch.finfo(h.dtype).min)[:,None]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
for layer in m.layers:
|
| 60 |
+
h = layer(h,position_embeddings=rotary,attention_mask=attn if layer.is_attention_layer else valid,
|
| 61 |
+
position_ids=positions,past_key_values=None)
|
| 62 |
+
return m.embedding_norm(h)
|
|
|
|
|
|
|
| 63 |
@torch.inference_mode()
|
| 64 |
+
def generate(self,prompt_ids,*,max_new_tokens=128,block_size=16,steps=16,temperature=0.0):
|
| 65 |
+
if prompt_ids.ndim!=2 or prompt_ids.shape[0]!=1 or prompt_ids.shape[1]<1 or min(max_new_tokens,block_size,steps)<1:
|
| 66 |
+
raise ValueError('One nonempty prompt and positive generation settings required')
|
| 67 |
+
if temperature<0:
|
| 68 |
+
raise ValueError('Temperature must be nonnegative')
|
| 69 |
+
pad,eos = self.model.config.pad_token_id,self.model.config.eos_token_id
|
| 70 |
+
eos_ids = {eos} if isinstance(eos,int) else set(eos or [])
|
| 71 |
+
generated,calls = [],0
|
| 72 |
while len(generated)<max_new_tokens:
|
| 73 |
+
count = min(block_size,max_new_tokens-len(generated))
|
| 74 |
+
prefix = torch.cat((prompt_ids,prompt_ids.new_tensor([generated])),1)[:,-256:]
|
| 75 |
+
p = prefix.shape[1]
|
| 76 |
+
ids = torch.cat((prefix,prefix.new_full((1,count),pad)),1)
|
| 77 |
+
masked = torch.zeros_like(ids,dtype=torch.bool)
|
| 78 |
+
masked[:,p:] = True
|
| 79 |
+
valid = torch.ones_like(masked)
|
| 80 |
+
for step in range(steps):
|
| 81 |
+
if not bool(masked.any()):
|
| 82 |
+
break
|
| 83 |
+
h = self.hidden(ids,masked,valid,prefix.new_tensor([p]))
|
| 84 |
+
logits = self.model.lm_head(h[masked]).float()
|
| 85 |
+
logits[:,pad] = -torch.inf
|
| 86 |
if temperature:
|
| 87 |
+
probabilities = (logits/temperature).softmax(-1)
|
| 88 |
+
tokens = torch.multinomial(probabilities,1).squeeze(-1)
|
| 89 |
+
confidence = probabilities.gather(1,tokens[:,None]).squeeze(1)
|
| 90 |
else:
|
| 91 |
+
tokens = logits.argmax(-1)
|
| 92 |
+
confidence = logits.log_softmax(-1).amax(-1)
|
| 93 |
+
remaining = count*(steps-step-1)//steps
|
| 94 |
+
commit = int(masked.sum())-remaining
|
| 95 |
+
if not remaining:
|
| 96 |
+
ids[masked] = tokens
|
| 97 |
masked.zero_()
|
| 98 |
else:
|
| 99 |
+
chosen = confidence.topk(commit).indices
|
| 100 |
+
position = masked[0].nonzero().squeeze(1)[chosen]
|
| 101 |
+
ids[0,position] = tokens[chosen]
|
| 102 |
+
masked[0,position] = False
|
| 103 |
+
calls += 1
|
| 104 |
+
canvas = ids[0,p:].tolist()
|
| 105 |
+
end = next((i for i,t in enumerate(canvas) if t in eos_ids),len(canvas))
|
| 106 |
+
generated.extend(canvas[:end])
|
| 107 |
+
if end!=len(canvas):
|
|
|
|
| 108 |
break
|
| 109 |
+
return generated,{'forward_calls':calls,'tokens':len(generated)}
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
+
def prepare_prompt(tokenizer,messages,*,think='plain',device=None):
|
| 113 |
+
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True)
|
| 114 |
+
if think=='plain' and text.endswith('<think>'):
|
| 115 |
+
text = text[:-len('<think>')]
|
| 116 |
+
elif think not in {'plain','keep'}:
|
| 117 |
+
raise ValueError('think must be plain or keep')
|
| 118 |
+
ids = tokenizer(text,add_special_tokens=False,return_tensors='pt').input_ids
|
| 119 |
+
return ids.to(device) if device is not None else ids
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def from_pretrained(model_id,*,revision=None,**kwargs):
|
| 123 |
+
import json
|
| 124 |
+
from pathlib import Path
|
| 125 |
from huggingface_hub import hf_hub_download
|
| 126 |
+
from safetensors.torch import load_file
|
| 127 |
from transformers import AutoModelForCausalLM
|
| 128 |
+
kwargs.setdefault('attn_implementation','sdpa')
|
| 129 |
+
model = AutoModelForCausalLM.from_pretrained(model_id,revision=revision,**kwargs)
|
| 130 |
+
device = str(model.get_input_embeddings().weight.device)
|
| 131 |
+
if getattr(model.config,'dialogue_runtime_patch',False) and not getattr(model.config,'dialogue_adapter_merged',False):
|
| 132 |
+
folder = model.config.dialogue_adapter_path
|
| 133 |
+
config = json.loads(Path(hf_hub_download(model_id,folder+'/adapter_config.json',revision=revision)).read_text())
|
| 134 |
+
state = load_file(hf_hub_download(model_id,folder+'/adapter.safetensors',revision=revision),device=device)
|
| 135 |
+
mask = apply_dialogue_patch(model,state,config['scale'])
|
| 136 |
+
else:
|
| 137 |
+
mask = load_file(hf_hub_download(model_id,'diffusion.safetensors',revision=revision),device=device)['mask_embedding']
|
| 138 |
+
return DiffusionLFM(model,mask).eval()
|
quality-selection-summary.json
CHANGED
|
@@ -1,96 +1,29 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
-
"
|
| 5 |
-
"
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
},
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
"median_tokps": 639.1644566581542,
|
| 22 |
-
"long_health": {
|
| 23 |
-
"alphabetic_fraction": 0.1011743450767841,
|
| 24 |
-
"distinct_4gram_ratio": 0.04995102840352596,
|
| 25 |
-
"longest_identical_token_run": 914,
|
| 26 |
-
"pass_screen": false
|
| 27 |
-
}
|
| 28 |
-
},
|
| 29 |
-
{
|
| 30 |
-
"block_size": 512,
|
| 31 |
-
"steps": 8,
|
| 32 |
-
"median_tokps": 559.6046788602476,
|
| 33 |
-
"long_health": {
|
| 34 |
-
"alphabetic_fraction": 0.0947176684881603,
|
| 35 |
-
"distinct_4gram_ratio": 0.04211557296767875,
|
| 36 |
-
"longest_identical_token_run": 927,
|
| 37 |
-
"pass_screen": false
|
| 38 |
-
}
|
| 39 |
-
},
|
| 40 |
-
{
|
| 41 |
-
"block_size": 512,
|
| 42 |
-
"steps": 9,
|
| 43 |
-
"median_tokps": 497.3790361543517,
|
| 44 |
-
"long_health": {
|
| 45 |
-
"alphabetic_fraction": 0.1055004508566276,
|
| 46 |
-
"distinct_4gram_ratio": 0.04897159647404505,
|
| 47 |
-
"longest_identical_token_run": 916,
|
| 48 |
-
"pass_screen": false
|
| 49 |
-
}
|
| 50 |
-
},
|
| 51 |
-
{
|
| 52 |
-
"block_size": 1024,
|
| 53 |
-
"steps": 11,
|
| 54 |
-
"median_tokps": 656.0337779697369,
|
| 55 |
-
"long_health": {
|
| 56 |
-
"alphabetic_fraction": 0.10171017101710171,
|
| 57 |
-
"distinct_4gram_ratio": 0.03330068560235064,
|
| 58 |
-
"longest_identical_token_run": 923,
|
| 59 |
-
"pass_screen": false
|
| 60 |
-
}
|
| 61 |
-
},
|
| 62 |
-
{
|
| 63 |
-
"block_size": 1024,
|
| 64 |
-
"steps": 12,
|
| 65 |
-
"median_tokps": 601.9543854074814,
|
| 66 |
-
"long_health": {
|
| 67 |
-
"alphabetic_fraction": 0.10743061772605192,
|
| 68 |
-
"distinct_4gram_ratio": 0.03819784524975514,
|
| 69 |
-
"longest_identical_token_run": 924,
|
| 70 |
-
"pass_screen": false
|
| 71 |
-
}
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"block_size": 1024,
|
| 75 |
-
"steps": 13,
|
| 76 |
-
"median_tokps": 555.3291700396725,
|
| 77 |
-
"long_health": {
|
| 78 |
-
"alphabetic_fraction": 0.13823272090988625,
|
| 79 |
-
"distinct_4gram_ratio": 0.058765915768854066,
|
| 80 |
-
"longest_identical_token_run": 944,
|
| 81 |
-
"pass_screen": false
|
| 82 |
-
}
|
| 83 |
-
},
|
| 84 |
-
{
|
| 85 |
-
"block_size": 1024,
|
| 86 |
-
"steps": 14,
|
| 87 |
-
"median_tokps": 514.9606330424041,
|
| 88 |
-
"long_health": {
|
| 89 |
-
"alphabetic_fraction": 0.13127753303964756,
|
| 90 |
-
"distinct_4gram_ratio": 0.05582761998041136,
|
| 91 |
-
"longest_identical_token_run": 908,
|
| 92 |
-
"pass_screen": false
|
| 93 |
-
}
|
| 94 |
-
}
|
| 95 |
-
]
|
| 96 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"quality_approved": false,
|
| 3 |
+
"posttraining_conversation_evaluation_complete": false,
|
| 4 |
+
"source_step": 250,
|
| 5 |
+
"validation": {
|
| 6 |
+
"japanese_next_nll": 1.5789912194013596,
|
| 7 |
+
"multilingual_span_nll": 5.471354529261589,
|
| 8 |
+
"per_language": {
|
| 9 |
+
"en": 2.9787462949752808,
|
| 10 |
+
"ar": 6.015078067779541,
|
| 11 |
+
"zh": 4.236312627792358,
|
| 12 |
+
"fr": 5.8818418979644775,
|
| 13 |
+
"de": 6.675511121749878,
|
| 14 |
+
"it": 5.073833584785461,
|
| 15 |
+
"ja": 4.965384483337402,
|
| 16 |
+
"ko": 5.386567115783691,
|
| 17 |
+
"pt": 4.24447226524353,
|
| 18 |
+
"es": 3.6444900035858154,
|
| 19 |
+
"vi": 7.3604865074157715,
|
| 20 |
+
"th": 5.754176378250122,
|
| 21 |
+
"id": 5.001194477081299,
|
| 22 |
+
"hi": 6.649858236312866,
|
| 23 |
+
"ru": 7.102121353149414,
|
| 24 |
+
"pl": 6.571598052978516
|
| 25 |
},
|
| 26 |
+
"selection_score": 3.5251728743314743
|
| 27 |
+
},
|
| 28 |
+
"merge_test_is_not_a_quality_benchmark": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
recommended_settings.json
CHANGED
|
@@ -1,208 +1,14 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
{
|
| 11 |
-
"steps": 2,
|
| 12 |
-
"code_correct": false,
|
| 13 |
-
"capital_correct": false,
|
| 14 |
-
"explanations_nondegenerate": false,
|
| 15 |
-
"distinct_4gram_ratio": 0.3306451612903226
|
| 16 |
-
},
|
| 17 |
-
{
|
| 18 |
-
"steps": 3,
|
| 19 |
-
"code_correct": false,
|
| 20 |
-
"capital_correct": false,
|
| 21 |
-
"explanations_nondegenerate": false,
|
| 22 |
-
"distinct_4gram_ratio": 0.33870967741935487
|
| 23 |
-
},
|
| 24 |
-
{
|
| 25 |
-
"steps": 4,
|
| 26 |
-
"code_correct": false,
|
| 27 |
-
"capital_correct": false,
|
| 28 |
-
"explanations_nondegenerate": false,
|
| 29 |
-
"distinct_4gram_ratio": 0.29838709677419356
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"steps": 5,
|
| 33 |
-
"code_correct": false,
|
| 34 |
-
"capital_correct": false,
|
| 35 |
-
"explanations_nondegenerate": false,
|
| 36 |
-
"distinct_4gram_ratio": 0.3709677419354839
|
| 37 |
-
},
|
| 38 |
-
{
|
| 39 |
-
"steps": 6,
|
| 40 |
-
"code_correct": false,
|
| 41 |
-
"capital_correct": false,
|
| 42 |
-
"explanations_nondegenerate": false,
|
| 43 |
-
"distinct_4gram_ratio": 0.3951612903225807
|
| 44 |
-
},
|
| 45 |
-
{
|
| 46 |
-
"steps": 7,
|
| 47 |
-
"code_correct": false,
|
| 48 |
-
"capital_correct": false,
|
| 49 |
-
"explanations_nondegenerate": false,
|
| 50 |
-
"distinct_4gram_ratio": 0.4381720430107527
|
| 51 |
-
},
|
| 52 |
-
{
|
| 53 |
-
"steps": 8,
|
| 54 |
-
"code_correct": false,
|
| 55 |
-
"capital_correct": false,
|
| 56 |
-
"explanations_nondegenerate": false,
|
| 57 |
-
"distinct_4gram_ratio": 0.510752688172043
|
| 58 |
-
},
|
| 59 |
-
{
|
| 60 |
-
"steps": 9,
|
| 61 |
-
"code_correct": false,
|
| 62 |
-
"capital_correct": false,
|
| 63 |
-
"explanations_nondegenerate": true,
|
| 64 |
-
"distinct_4gram_ratio": 0.41666666666666663
|
| 65 |
-
},
|
| 66 |
-
{
|
| 67 |
-
"steps": 10,
|
| 68 |
-
"code_correct": false,
|
| 69 |
-
"capital_correct": false,
|
| 70 |
-
"explanations_nondegenerate": true,
|
| 71 |
-
"distinct_4gram_ratio": 0.5752688172043011
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"steps": 11,
|
| 75 |
-
"code_correct": false,
|
| 76 |
-
"capital_correct": false,
|
| 77 |
-
"explanations_nondegenerate": true,
|
| 78 |
-
"distinct_4gram_ratio": 0.5672043010752689
|
| 79 |
-
},
|
| 80 |
-
{
|
| 81 |
-
"steps": 12,
|
| 82 |
-
"code_correct": false,
|
| 83 |
-
"capital_correct": false,
|
| 84 |
-
"explanations_nondegenerate": true,
|
| 85 |
-
"distinct_4gram_ratio": 0.532258064516129
|
| 86 |
-
},
|
| 87 |
-
{
|
| 88 |
-
"steps": 13,
|
| 89 |
-
"code_correct": false,
|
| 90 |
-
"capital_correct": false,
|
| 91 |
-
"explanations_nondegenerate": true,
|
| 92 |
-
"distinct_4gram_ratio": 0.532258064516129
|
| 93 |
-
},
|
| 94 |
-
{
|
| 95 |
-
"steps": 14,
|
| 96 |
-
"code_correct": false,
|
| 97 |
-
"capital_correct": false,
|
| 98 |
-
"explanations_nondegenerate": true,
|
| 99 |
-
"distinct_4gram_ratio": 0.6129032258064516
|
| 100 |
-
},
|
| 101 |
-
{
|
| 102 |
-
"steps": 15,
|
| 103 |
-
"code_correct": false,
|
| 104 |
-
"capital_correct": false,
|
| 105 |
-
"explanations_nondegenerate": true,
|
| 106 |
-
"distinct_4gram_ratio": 0.5564516129032258
|
| 107 |
-
}
|
| 108 |
-
],
|
| 109 |
-
"verified_speed_500_to_700_tokps": [
|
| 110 |
-
{
|
| 111 |
-
"block_size": 256,
|
| 112 |
-
"steps": 4,
|
| 113 |
-
"median_tokps": 583.931875195536,
|
| 114 |
-
"long_health": {
|
| 115 |
-
"alphabetic_fraction": 0.05560791705937795,
|
| 116 |
-
"distinct_4gram_ratio": 0.04897159647404505,
|
| 117 |
-
"longest_identical_token_run": 526,
|
| 118 |
-
"pass_screen": false
|
| 119 |
-
}
|
| 120 |
-
},
|
| 121 |
-
{
|
| 122 |
-
"block_size": 512,
|
| 123 |
-
"steps": 7,
|
| 124 |
-
"median_tokps": 639.1644566581542,
|
| 125 |
-
"long_health": {
|
| 126 |
-
"alphabetic_fraction": 0.1011743450767841,
|
| 127 |
-
"distinct_4gram_ratio": 0.04995102840352596,
|
| 128 |
-
"longest_identical_token_run": 914,
|
| 129 |
-
"pass_screen": false
|
| 130 |
-
}
|
| 131 |
-
},
|
| 132 |
-
{
|
| 133 |
-
"block_size": 512,
|
| 134 |
-
"steps": 8,
|
| 135 |
-
"median_tokps": 559.6046788602476,
|
| 136 |
-
"long_health": {
|
| 137 |
-
"alphabetic_fraction": 0.0947176684881603,
|
| 138 |
-
"distinct_4gram_ratio": 0.04211557296767875,
|
| 139 |
-
"longest_identical_token_run": 927,
|
| 140 |
-
"pass_screen": false
|
| 141 |
-
}
|
| 142 |
-
},
|
| 143 |
-
{
|
| 144 |
-
"block_size": 512,
|
| 145 |
-
"steps": 9,
|
| 146 |
-
"median_tokps": 497.3790361543517,
|
| 147 |
-
"long_health": {
|
| 148 |
-
"alphabetic_fraction": 0.1055004508566276,
|
| 149 |
-
"distinct_4gram_ratio": 0.04897159647404505,
|
| 150 |
-
"longest_identical_token_run": 916,
|
| 151 |
-
"pass_screen": false
|
| 152 |
-
}
|
| 153 |
-
},
|
| 154 |
-
{
|
| 155 |
-
"block_size": 1024,
|
| 156 |
-
"steps": 11,
|
| 157 |
-
"median_tokps": 656.0337779697369,
|
| 158 |
-
"long_health": {
|
| 159 |
-
"alphabetic_fraction": 0.10171017101710171,
|
| 160 |
-
"distinct_4gram_ratio": 0.03330068560235064,
|
| 161 |
-
"longest_identical_token_run": 923,
|
| 162 |
-
"pass_screen": false
|
| 163 |
-
}
|
| 164 |
-
},
|
| 165 |
-
{
|
| 166 |
-
"block_size": 1024,
|
| 167 |
-
"steps": 12,
|
| 168 |
-
"median_tokps": 601.9543854074814,
|
| 169 |
-
"long_health": {
|
| 170 |
-
"alphabetic_fraction": 0.10743061772605192,
|
| 171 |
-
"distinct_4gram_ratio": 0.03819784524975514,
|
| 172 |
-
"longest_identical_token_run": 924,
|
| 173 |
-
"pass_screen": false
|
| 174 |
-
}
|
| 175 |
-
},
|
| 176 |
-
{
|
| 177 |
-
"block_size": 1024,
|
| 178 |
-
"steps": 13,
|
| 179 |
-
"median_tokps": 555.3291700396725,
|
| 180 |
-
"long_health": {
|
| 181 |
-
"alphabetic_fraction": 0.13823272090988625,
|
| 182 |
-
"distinct_4gram_ratio": 0.058765915768854066,
|
| 183 |
-
"longest_identical_token_run": 944,
|
| 184 |
-
"pass_screen": false
|
| 185 |
-
}
|
| 186 |
-
},
|
| 187 |
-
{
|
| 188 |
-
"block_size": 1024,
|
| 189 |
-
"steps": 14,
|
| 190 |
-
"median_tokps": 514.9606330424041,
|
| 191 |
-
"long_health": {
|
| 192 |
-
"alphabetic_fraction": 0.13127753303964756,
|
| 193 |
-
"distinct_4gram_ratio": 0.05582761998041136,
|
| 194 |
-
"longest_identical_token_run": 908,
|
| 195 |
-
"pass_screen": false
|
| 196 |
-
}
|
| 197 |
-
}
|
| 198 |
-
],
|
| 199 |
-
"best_quality_setting": null,
|
| 200 |
-
"reason": "No tested step count passed all fixed quality checks; speed-only settings are not endorsed as high quality.",
|
| 201 |
-
"latency_reproduction_setting": {
|
| 202 |
-
"canvas": 1024,
|
| 203 |
-
"steps": 12,
|
| 204 |
-
"median_tokps_on_A100": 601.9543854074814,
|
| 205 |
-
"quality_warning": "Severely repetitive/invalid generation; latency reproduction only, not a quality recommendation."
|
| 206 |
},
|
| 207 |
-
"
|
|
|
|
|
|
|
| 208 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"model_type": "lfm2_moe",
|
| 3 |
+
"packaging": "exact_runtime_adapter_patch",
|
| 4 |
+
"sampler_source": "modeling_diffusion_lfm.py",
|
| 5 |
+
"mask_embedding_file": "diffusion.safetensors",
|
| 6 |
+
"raw_sampler": {
|
| 7 |
+
"block_size": 16,
|
| 8 |
+
"steps": 16,
|
| 9 |
+
"prefix_tokens": 256
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
},
|
| 11 |
+
"quality_approved": false,
|
| 12 |
+
"current_revision_speed_measured": false,
|
| 13 |
+
"legacy_results_revision": "2d791e03b14bb42b4323049fbfd832415d32b055"
|
| 14 |
}
|