justinchuby commited on
Commit
64f9948
·
verified ·
1 Parent(s): a2da272

Add files using upload-large-folder tool

Browse files
README.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags: [onnx, onnxruntime, onnx-genai, inference-metadata, peft, lora]
4
+ ---
5
+ # onnx-genai-example-qwen2-5-1-5b-lora-selection
6
+
7
+ Private real-weight ONNX package from [`Qwen/Qwen2.5-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/tree/989aa7980e4cf806f80c7fef2b1adb7bc71aa306) at `989aa7980e4cf806f80c7fef2b1adb7bc71aa306`, with matching PEFT adapter [`bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16`](https://huggingface.co/bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16/tree/57a4a23b934ea6c3f25615e13a6979d55c48fd68) at `57a4a23b934ea6c3f25615e13a6979d55c48fd68`. Both sources are Apache-2.0.
8
+
9
+ Includes actual fp16 decoder and adapter weights, canonical metadata, tokenizer, policies, source provenance, request/output, graph report, and H200 CUDA timings. The real probe used logical rows at scales 0, 0.5, and 1.0; adapter rows changed final logits by 25.72–25.79 and generated different output from the base row. Installed ORT exposes whole-run adapter activation, so heterogeneous logical rows were executed independently and this limitation is explicit in `output.json`.
10
+
11
+ ## Download
12
+ ```bash
13
+ hf download justinchuby/onnx-genai-example-qwen2-5-1-5b-lora-selection --repo-type model --local-dir ./qwen2.5-1.5b-lora-selection
14
+ ```
15
+ ## Exact runtime probe
16
+ ```bash
17
+ cd qwen2.5-1.5b-lora-selection
18
+ python3 evidence/probe_lora_onnx.py
19
+ cat evidence/lora_runtime_probe.json
20
+ ```
21
+ Requires CUDA-capable `onnxruntime-gpu`, `onnx-ir`, `transformers`, `safetensors`, `torch`, and `numpy`; exact successful versions are in `output.json`.
SOURCE_LICENSE.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Source licenses
2
+
3
+ - [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/tree/989aa7980e4cf806f80c7fef2b1adb7bc71aa306): Apache-2.0.
4
+ - [bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16](https://huggingface.co/bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16/tree/57a4a23b934ea6c3f25615e13a6979d55c48fd68): Apache-2.0 repository license tag.
adapters/code-lora-r16/adapter_config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alpha_pattern": {},
3
+ "auto_mapping": null,
4
+ "base_model_name_or_path": "Qwen/Qwen2.5-1.5B-Instruct",
5
+ "bias": "none",
6
+ "fan_in_fan_out": false,
7
+ "inference_mode": true,
8
+ "init_lora_weights": true,
9
+ "layer_replication": null,
10
+ "layers_pattern": null,
11
+ "layers_to_transform": null,
12
+ "loftq_config": {},
13
+ "lora_alpha": 32,
14
+ "lora_dropout": 0.05,
15
+ "megatron_config": null,
16
+ "megatron_core": "megatron.core",
17
+ "modules_to_save": null,
18
+ "peft_type": "LORA",
19
+ "r": 16,
20
+ "rank_pattern": {},
21
+ "revision": null,
22
+ "target_modules": [
23
+ "v_proj",
24
+ "gate_proj",
25
+ "o_proj",
26
+ "down_proj",
27
+ "k_proj",
28
+ "q_proj",
29
+ "up_proj"
30
+ ],
31
+ "task_type": "CAUSAL_LM",
32
+ "use_dora": false,
33
+ "use_rslora": false
34
+ }
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
evidence/build_lora_package.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ import shutil
6
+ import time
7
+ from pathlib import Path
8
+
9
+ from huggingface_hub import snapshot_download
10
+
11
+ from mobius import (
12
+ attach_peft_adapter,
13
+ build,
14
+ )
15
+ from mobius.integrations.onnx_genai import write_onnx_genai_config
16
+
17
+ BASE_ID = "Qwen/Qwen2.5-1.5B-Instruct"
18
+ BASE_REVISION = "989aa7980e4cf806f80c7fef2b1adb7bc71aa306"
19
+ ADAPTER_ID = "bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16"
20
+ ADAPTER_REVISION = "57a4a23b934ea6c3f25615e13a6979d55c48fd68"
21
+ OUTPUT = Path(
22
+ "/datadisks/disk1/justinchu/inference-metadata-catalogue/"
23
+ "qwen2.5-1.5b-instruct-lora-selection"
24
+ )
25
+
26
+
27
+ def main() -> None:
28
+ started = time.perf_counter()
29
+ OUTPUT.mkdir(parents=True, exist_ok=True)
30
+ cache = OUTPUT / ".build-cache"
31
+ adapter_source = Path(
32
+ snapshot_download(
33
+ ADAPTER_ID,
34
+ revision=ADAPTER_REVISION,
35
+ cache_dir=cache,
36
+ allow_patterns=[
37
+ "adapter_config.json",
38
+ "adapter_model.safetensors",
39
+ "README.md",
40
+ ],
41
+ )
42
+ )
43
+ adapter_config = json.loads((adapter_source / "adapter_config.json").read_text())
44
+ package = build(
45
+ BASE_ID,
46
+ revision=BASE_REVISION,
47
+ dtype="f16",
48
+ execution_provider="default",
49
+ )
50
+ attach_peft_adapter(
51
+ package,
52
+ adapter_source,
53
+ name="code-lora-r16",
54
+ max_adapters=2,
55
+ cache_max_entries=2,
56
+ preserve_source_format=True,
57
+ )
58
+ package.save(str(OUTPUT), progress_bar=True)
59
+ write_onnx_genai_config(
60
+ package,
61
+ str(OUTPUT),
62
+ source=BASE_ID,
63
+ revision=BASE_REVISION,
64
+ )
65
+
66
+ source_dir = OUTPUT / "sources" / "peft"
67
+ source_dir.mkdir(parents=True, exist_ok=True)
68
+ for name in ("adapter_config.json", "adapter_model.safetensors", "README.md"):
69
+ shutil.copy2(adapter_source / name, source_dir / name)
70
+ provenance = {
71
+ "base": {
72
+ "id": BASE_ID,
73
+ "revision": BASE_REVISION,
74
+ "license": "Apache-2.0",
75
+ },
76
+ "adapter": {
77
+ "id": ADAPTER_ID,
78
+ "revision": ADAPTER_REVISION,
79
+ "license": "Apache-2.0 (Hugging Face repository tag)",
80
+ "base_model_name_or_path": adapter_config["base_model_name_or_path"],
81
+ "rank": adapter_config["r"],
82
+ "alpha": adapter_config["lora_alpha"],
83
+ "target_count": len(package.adapter_target_manifest.targets),
84
+ },
85
+ "build": {
86
+ "dtype": "float16",
87
+ "execution_provider": "default",
88
+ "seconds": time.perf_counter() - started,
89
+ "mobius_git_sha": os.popen("git rev-parse HEAD").read().strip(),
90
+ },
91
+ }
92
+ (OUTPUT / "source_provenance.json").write_text(
93
+ json.dumps(provenance, indent=2, sort_keys=True) + "\n"
94
+ )
95
+ shutil.rmtree(cache)
96
+
97
+
98
+ if __name__ == "__main__":
99
+ main()
evidence/lora_runtime_probe.json ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "assertions": {
3
+ "heterogeneous_outputs": true,
4
+ "scale_0_5_changes_logits": true,
5
+ "scale_1_changes_logits": true
6
+ },
7
+ "execution": {
8
+ "note": "The installed ORT exposes whole-run LoraAdapter activation, not the canonical row-wise parameter-overlay ABI. This probe executes the three heterogeneous logical rows independently after applying the same real PEFT deltas at each requested scale.",
9
+ "providers": [
10
+ "TensorrtExecutionProvider",
11
+ "CUDAExecutionProvider",
12
+ "CPUExecutionProvider"
13
+ ],
14
+ "runtime": "onnxruntime"
15
+ },
16
+ "request": {
17
+ "max_new_tokens": 12,
18
+ "prompt": "Write one concise C++ function that returns the larger of two integers.",
19
+ "rows": [
20
+ {
21
+ "adapter": null,
22
+ "row": 0,
23
+ "scale": 0.0
24
+ },
25
+ {
26
+ "adapter": "code-lora-r16",
27
+ "row": 1,
28
+ "scale": 0.5
29
+ },
30
+ {
31
+ "adapter": "code-lora-r16",
32
+ "row": 2,
33
+ "scale": 1.0
34
+ }
35
+ ]
36
+ },
37
+ "rows": [
38
+ {
39
+ "adapter": null,
40
+ "final_argmax_token": 1896,
41
+ "load_seconds": 43.908357076114044,
42
+ "max_abs_final_logit_delta_vs_base": 0.0,
43
+ "row": 0,
44
+ "scale": 0.0,
45
+ "text": " The function should be named `max_of_two` and take",
46
+ "token_ids": [
47
+ 576,
48
+ 729,
49
+ 1265,
50
+ 387,
51
+ 6941,
52
+ 1565,
53
+ 2810,
54
+ 3575,
55
+ 23241,
56
+ 63,
57
+ 323,
58
+ 1896
59
+ ],
60
+ "total_seconds": 59.21031142398715
61
+ },
62
+ {
63
+ "adapter": "code-lora-r16",
64
+ "final_argmax_token": 1548,
65
+ "load_seconds": 5.039828644832596,
66
+ "max_abs_final_logit_delta_vs_base": 25.716796875,
67
+ "row": 1,
68
+ "scale": 0.5,
69
+ "text": " #include <iostream>\nusing namespace std;\n\nint max(int",
70
+ "token_ids": [
71
+ 671,
72
+ 997,
73
+ 366,
74
+ 9665,
75
+ 397,
76
+ 970,
77
+ 4473,
78
+ 1460,
79
+ 401,
80
+ 396,
81
+ 1932,
82
+ 1548
83
+ ],
84
+ "total_seconds": 16.198358421912417
85
+ },
86
+ {
87
+ "adapter": "code-lora-r16",
88
+ "final_argmax_token": 1548,
89
+ "load_seconds": 8.739312588004395,
90
+ "max_abs_final_logit_delta_vs_base": 25.7861328125,
91
+ "row": 2,
92
+ "scale": 1.0,
93
+ "text": " #include <iostream>\nusing namespace std;\n\nint max(int",
94
+ "token_ids": [
95
+ 671,
96
+ 997,
97
+ 366,
98
+ 9665,
99
+ 397,
100
+ 970,
101
+ 4473,
102
+ 1460,
103
+ 401,
104
+ 396,
105
+ 1932,
106
+ 1548
107
+ ],
108
+ "total_seconds": 21.565866044955328
109
+ }
110
+ ],
111
+ "total_seconds": 98.45913959108293,
112
+ "versions": {
113
+ "onnx_ir": "1.0.0",
114
+ "onnxruntime": "1.28.0",
115
+ "safetensors": "0.8.0",
116
+ "torch": "2.8.0+cu126",
117
+ "transformers": "5.16.0.dev0"
118
+ }
119
+ }
evidence/probe_lora_onnx.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import shutil
5
+ import time
6
+ from pathlib import Path
7
+
8
+ import numpy as np
9
+ import onnx_ir as ir
10
+ import onnxruntime as ort
11
+ import safetensors
12
+ import torch
13
+ import transformers
14
+ from safetensors.numpy import load_file
15
+ from transformers import AutoTokenizer
16
+
17
+ PACKAGE = Path(__file__).resolve().parents[1]
18
+ MODEL = PACKAGE / "model.onnx"
19
+ ADAPTER = PACKAGE / "sources" / "peft"
20
+ SCALES = (0.0, 0.5, 1.0)
21
+
22
+
23
+ def _merge(scale: float, destination: Path) -> None:
24
+ model = ir.load(MODEL)
25
+ config = json.loads((ADAPTER / "adapter_config.json").read_text())
26
+ tensors = load_file(ADAPTER / "adapter_model.safetensors")
27
+ modules: dict[str, dict[str, np.ndarray]] = {}
28
+ for name, values in tensors.items():
29
+ if ".lora_A." in name:
30
+ module, factor = name.split(".lora_A.", 1)[0], "A"
31
+ elif ".lora_B." in name:
32
+ module, factor = name.split(".lora_B.", 1)[0], "B"
33
+ else:
34
+ continue
35
+ module = module.removeprefix("base_model.model.")
36
+ modules.setdefault(module, {})[factor] = values
37
+ for module, factors in modules.items():
38
+ parameter = model.graph.initializers[f"{module}.weight"]
39
+ base = parameter.const_value.numpy()
40
+ delta = factors["B"].astype(np.float32) @ factors["A"].astype(np.float32)
41
+ delta *= float(config["lora_alpha"]) / int(config["r"])
42
+ merged = base.astype(np.float32) + scale * delta
43
+ parameter.const_value = ir.tensor(
44
+ merged.astype(np.float16),
45
+ name=parameter.name,
46
+ )
47
+ ir.save(model, destination, external_data="model.onnx.data")
48
+
49
+
50
+ def _empty_inputs(session: ort.InferenceSession, input_ids: np.ndarray):
51
+ batch, sequence = input_ids.shape
52
+ feeds: dict[str, np.ndarray] = {
53
+ "input_ids": input_ids,
54
+ "attention_mask": np.ones((batch, sequence), dtype=np.int64),
55
+ "position_ids": np.arange(sequence, dtype=np.int64)[None, :].repeat(batch, 0),
56
+ }
57
+ for value in session.get_inputs():
58
+ if value.name.startswith("past_key_values."):
59
+ heads = int(value.shape[1])
60
+ width = int(value.shape[3])
61
+ feeds[value.name] = np.empty((batch, heads, 0, width), dtype=np.float16)
62
+ return feeds
63
+
64
+
65
+ def _generate(session, tokenizer, prompt: str, max_new_tokens: int):
66
+ input_ids = tokenizer(prompt, return_tensors="np").input_ids.astype(np.int64)
67
+ feeds = _empty_inputs(session, input_ids)
68
+ output_names = [value.name for value in session.get_outputs()]
69
+ generated: list[int] = []
70
+ logits = None
71
+ for step in range(max_new_tokens):
72
+ outputs = session.run(None, feeds)
73
+ logits = outputs[0][:, -1, :].astype(np.float32)
74
+ token = int(np.argmax(logits[0]))
75
+ generated.append(token)
76
+ presents = dict(zip(output_names[1:], outputs[1:]))
77
+ feeds = {
78
+ "input_ids": np.array([[token]], dtype=np.int64),
79
+ "attention_mask": np.ones((1, input_ids.shape[1] + step + 1), dtype=np.int64),
80
+ "position_ids": np.array([[input_ids.shape[1] + step]], dtype=np.int64),
81
+ }
82
+ for value in session.get_inputs():
83
+ if value.name.startswith("past_key_values."):
84
+ suffix = value.name.removeprefix("past_key_values.")
85
+ feeds[value.name] = presents[f"present.{suffix}"]
86
+ return {
87
+ "token_ids": generated,
88
+ "text": tokenizer.decode(generated),
89
+ "final_logits": logits[0],
90
+ }
91
+
92
+
93
+ def main() -> None:
94
+ evidence = PACKAGE / "evidence"
95
+ scratch = evidence / "scratch"
96
+ scratch.mkdir(parents=True, exist_ok=True)
97
+ tokenizer = AutoTokenizer.from_pretrained(PACKAGE)
98
+ prompt = "Write one concise C++ function that returns the larger of two integers."
99
+ rows = []
100
+ started = time.perf_counter()
101
+ for scale in SCALES:
102
+ row_started = time.perf_counter()
103
+ scratch_model = scratch / "model.onnx"
104
+ _merge(scale, scratch_model)
105
+ session_started = time.perf_counter()
106
+ session = ort.InferenceSession(
107
+ str(scratch_model),
108
+ providers=["CUDAExecutionProvider", "CPUExecutionProvider"],
109
+ )
110
+ load_seconds = time.perf_counter() - session_started
111
+ result = _generate(session, tokenizer, prompt, max_new_tokens=12)
112
+ rows.append(
113
+ {
114
+ "row": len(rows),
115
+ "adapter": None if scale == 0 else "code-lora-r16",
116
+ "scale": scale,
117
+ "token_ids": result["token_ids"],
118
+ "text": result["text"],
119
+ "load_seconds": load_seconds,
120
+ "total_seconds": time.perf_counter() - row_started,
121
+ "_logits": result["final_logits"],
122
+ }
123
+ )
124
+ del session
125
+ shutil.rmtree(scratch)
126
+ scratch.mkdir()
127
+
128
+ base_logits = rows[0]["_logits"]
129
+ for row in rows:
130
+ logits = row.pop("_logits")
131
+ row["max_abs_final_logit_delta_vs_base"] = float(np.max(np.abs(logits - base_logits)))
132
+ row["final_argmax_token"] = int(np.argmax(logits))
133
+ payload = {
134
+ "request": {
135
+ "prompt": prompt,
136
+ "rows": [
137
+ {"row": row["row"], "adapter": row["adapter"], "scale": row["scale"]}
138
+ for row in rows
139
+ ],
140
+ "max_new_tokens": 12,
141
+ },
142
+ "execution": {
143
+ "runtime": "onnxruntime",
144
+ "providers": ort.get_available_providers(),
145
+ "note": (
146
+ "The installed ORT exposes whole-run LoraAdapter activation, not the "
147
+ "canonical row-wise parameter-overlay ABI. This probe executes the "
148
+ "three heterogeneous logical rows independently after applying the "
149
+ "same real PEFT deltas at each requested scale."
150
+ ),
151
+ },
152
+ "rows": rows,
153
+ "assertions": {
154
+ "scale_0_5_changes_logits": rows[1]["max_abs_final_logit_delta_vs_base"] > 0,
155
+ "scale_1_changes_logits": rows[2]["max_abs_final_logit_delta_vs_base"] > 0,
156
+ "heterogeneous_outputs": len({tuple(row["token_ids"]) for row in rows}) > 1,
157
+ },
158
+ "versions": {
159
+ "onnxruntime": ort.__version__,
160
+ "onnx_ir": ir.__version__,
161
+ "transformers": transformers.__version__,
162
+ "torch": torch.__version__,
163
+ "safetensors": safetensors.__version__,
164
+ },
165
+ "total_seconds": time.perf_counter() - started,
166
+ }
167
+ (evidence / "lora_runtime_probe.json").write_text(
168
+ json.dumps(payload, indent=2, sort_keys=True) + "\n"
169
+ )
170
+ shutil.rmtree(scratch)
171
+ if not all(payload["assertions"].values()):
172
+ raise RuntimeError(payload["assertions"])
173
+
174
+
175
+ if __name__ == "__main__":
176
+ main()
graph_report.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "adapter_alpha": 32,
3
+ "adapter_rank": 16,
4
+ "adapter_targets": 196,
5
+ "dtype": "float16",
6
+ "metadata": "canonical typed workflow with parameter-adapter service"
7
+ }
inference_metadata.yaml ADDED
The diff for this file is too large to render. See raw diff
 
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
output.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "assertions": {
3
+ "heterogeneous_outputs": true,
4
+ "scale_0_5_changes_logits": true,
5
+ "scale_1_changes_logits": true
6
+ },
7
+ "rows": [
8
+ {
9
+ "adapter": null,
10
+ "final_argmax_token": 1896,
11
+ "load_seconds": 43.908357076114044,
12
+ "max_abs_final_logit_delta_vs_base": 0.0,
13
+ "row": 0,
14
+ "scale": 0.0,
15
+ "text": " The function should be named `max_of_two` and take",
16
+ "token_ids": [
17
+ 576,
18
+ 729,
19
+ 1265,
20
+ 387,
21
+ 6941,
22
+ 1565,
23
+ 2810,
24
+ 3575,
25
+ 23241,
26
+ 63,
27
+ 323,
28
+ 1896
29
+ ],
30
+ "total_seconds": 59.21031142398715
31
+ },
32
+ {
33
+ "adapter": "code-lora-r16",
34
+ "final_argmax_token": 1548,
35
+ "load_seconds": 5.039828644832596,
36
+ "max_abs_final_logit_delta_vs_base": 25.716796875,
37
+ "row": 1,
38
+ "scale": 0.5,
39
+ "text": " #include <iostream>\nusing namespace std;\n\nint max(int",
40
+ "token_ids": [
41
+ 671,
42
+ 997,
43
+ 366,
44
+ 9665,
45
+ 397,
46
+ 970,
47
+ 4473,
48
+ 1460,
49
+ 401,
50
+ 396,
51
+ 1932,
52
+ 1548
53
+ ],
54
+ "total_seconds": 16.198358421912417
55
+ },
56
+ {
57
+ "adapter": "code-lora-r16",
58
+ "final_argmax_token": 1548,
59
+ "load_seconds": 8.739312588004395,
60
+ "max_abs_final_logit_delta_vs_base": 25.7861328125,
61
+ "row": 2,
62
+ "scale": 1.0,
63
+ "text": " #include <iostream>\nusing namespace std;\n\nint max(int",
64
+ "token_ids": [
65
+ 671,
66
+ 997,
67
+ 366,
68
+ 9665,
69
+ 397,
70
+ 970,
71
+ 4473,
72
+ 1460,
73
+ 401,
74
+ 396,
75
+ 1932,
76
+ 1548
77
+ ],
78
+ "total_seconds": 21.565866044955328
79
+ }
80
+ ],
81
+ "runtime": {
82
+ "note": "The installed ORT exposes whole-run LoraAdapter activation, not the canonical row-wise parameter-overlay ABI. This probe executes the three heterogeneous logical rows independently after applying the same real PEFT deltas at each requested scale.",
83
+ "providers": [
84
+ "TensorrtExecutionProvider",
85
+ "CUDAExecutionProvider",
86
+ "CPUExecutionProvider"
87
+ ],
88
+ "runtime": "onnxruntime"
89
+ },
90
+ "versions": {
91
+ "onnx_ir": "1.0.0",
92
+ "onnxruntime": "1.28.0",
93
+ "safetensors": "0.8.0",
94
+ "torch": "2.8.0+cu126",
95
+ "transformers": "5.16.0.dev0"
96
+ }
97
+ }
performance.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "hardware": "NVIDIA H200",
3
+ "rows": [
4
+ {
5
+ "load_seconds": 43.908357076114044,
6
+ "row": 0,
7
+ "scale": 0.0,
8
+ "total_seconds": 59.21031142398715
9
+ },
10
+ {
11
+ "load_seconds": 5.039828644832596,
12
+ "row": 1,
13
+ "scale": 0.5,
14
+ "total_seconds": 16.198358421912417
15
+ },
16
+ {
17
+ "load_seconds": 8.739312588004395,
18
+ "row": 2,
19
+ "scale": 1.0,
20
+ "total_seconds": 21.565866044955328
21
+ }
22
+ ],
23
+ "total_seconds": 98.45913959108293
24
+ }
provenance.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "build": {
3
+ "dtype": "float16",
4
+ "execution_provider": "default",
5
+ "mobius_git_sha": "57c149d1845c97781ae386da5c1c93528fde8841",
6
+ "seconds": 133.8639017518144
7
+ },
8
+ "files": [
9
+ {
10
+ "bytes": 401469,
11
+ "path": "model.onnx",
12
+ "sha256": "2122a0c6a5876ff19bec8c207be52c2acf077a522e860aa08932cf538bb6f03d"
13
+ },
14
+ {
15
+ "bytes": 3095855104,
16
+ "path": "model.onnx.data",
17
+ "sha256": "bf7ff357dffe14fd28d2d26f8e897512fcde9fde74e947808c25ee7b04a70e69"
18
+ },
19
+ {
20
+ "bytes": 73911112,
21
+ "path": "sources/peft/adapter_model.safetensors",
22
+ "sha256": "ad84098fe32f73fb3f7acb8d8ddb178cb39717718d21d040c6bcc161d4ec8243"
23
+ },
24
+ {
25
+ "bytes": 729,
26
+ "path": "sources/peft/adapter_config.json",
27
+ "sha256": "e71a0adf6b79764fe0c30ec786bf3e8cb4dd42e41a53ae0fc20eb9f1d6324ceb"
28
+ }
29
+ ],
30
+ "sources": [
31
+ {
32
+ "adapter": {
33
+ "model": "bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16",
34
+ "revision": "57a4a23b934ea6c3f25615e13a6979d55c48fd68",
35
+ "source_license": "apache-2.0",
36
+ "source_url": "https://huggingface.co/bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16/tree/57a4a23b934ea6c3f25615e13a6979d55c48fd68"
37
+ },
38
+ "model": "Qwen/Qwen2.5-1.5B-Instruct",
39
+ "revision": "989aa7980e4cf806f80c7fef2b1adb7bc71aa306",
40
+ "source_license": "apache-2.0",
41
+ "source_url": "https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/tree/989aa7980e4cf806f80c7fef2b1adb7bc71aa306"
42
+ }
43
+ ]
44
+ }
request.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "max_new_tokens": 12,
3
+ "prompt": "Write one concise C++ function that returns the larger of two integers.",
4
+ "rows": [
5
+ {
6
+ "adapter": null,
7
+ "row": 0,
8
+ "scale": 0.0
9
+ },
10
+ {
11
+ "adapter": "code-lora-r16",
12
+ "row": 1,
13
+ "scale": 0.5
14
+ },
15
+ {
16
+ "adapter": "code-lora-r16",
17
+ "row": 2,
18
+ "scale": 1.0
19
+ }
20
+ ]
21
+ }
source.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adapter": {
3
+ "model": "bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16",
4
+ "revision": "57a4a23b934ea6c3f25615e13a6979d55c48fd68",
5
+ "source_license": "apache-2.0",
6
+ "source_url": "https://huggingface.co/bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16/tree/57a4a23b934ea6c3f25615e13a6979d55c48fd68"
7
+ },
8
+ "model": "Qwen/Qwen2.5-1.5B-Instruct",
9
+ "revision": "989aa7980e4cf806f80c7fef2b1adb7bc71aa306",
10
+ "source_license": "apache-2.0",
11
+ "source_url": "https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/tree/989aa7980e4cf806f80c7fef2b1adb7bc71aa306"
12
+ }
source_provenance.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "adapter": {
3
+ "alpha": 32,
4
+ "base_model_name_or_path": "Qwen/Qwen2.5-1.5B-Instruct",
5
+ "id": "bharati2324/Qwen2.5-1.5B-Instruct-Code-LoRA-r16",
6
+ "license": "Apache-2.0 (Hugging Face repository tag)",
7
+ "rank": 16,
8
+ "revision": "57a4a23b934ea6c3f25615e13a6979d55c48fd68",
9
+ "target_count": 196
10
+ },
11
+ "base": {
12
+ "id": "Qwen/Qwen2.5-1.5B-Instruct",
13
+ "license": "Apache-2.0",
14
+ "revision": "989aa7980e4cf806f80c7fef2b1adb7bc71aa306"
15
+ },
16
+ "build": {
17
+ "dtype": "float16",
18
+ "execution_provider": "default",
19
+ "mobius_git_sha": "57c149d1845c97781ae386da5c1c93528fde8841",
20
+ "seconds": 133.8639017518144
21
+ }
22
+ }
sources/peft/README.md ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: Qwen/Qwen2.5-1.5B-Instruct
3
+ library_name: peft
4
+ license: apache-2.0
5
+ tags:
6
+ - trl
7
+ - sft
8
+ - generated_from_trainer
9
+ model-index:
10
+ - name: Qwen2.5-1.5B-Instruct-Code-LoRA-r16
11
+ results: []
12
+ ---
13
+
14
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
15
+ should probably proofread and complete it, then remove this comment. -->
16
+
17
+ # Qwen2.5-1.5B-Instruct-Code-LoRA-r16
18
+
19
+ This model is a fine-tuned version of [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) on an unknown dataset.
20
+
21
+ ## Model description
22
+
23
+ More information needed
24
+
25
+ ## Intended uses & limitations
26
+
27
+ More information needed
28
+
29
+ ## Training and evaluation data
30
+
31
+ More information needed
32
+
33
+ ## Training procedure
34
+
35
+ ### Training hyperparameters
36
+
37
+ The following hyperparameters were used during training:
38
+ - learning_rate: 0.0002
39
+ - train_batch_size: 1
40
+ - eval_batch_size: 8
41
+ - seed: 42
42
+ - gradient_accumulation_steps: 4
43
+ - total_train_batch_size: 4
44
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
45
+ - lr_scheduler_type: cosine
46
+ - lr_scheduler_warmup_steps: 2
47
+ - training_steps: 100
48
+ - mixed_precision_training: Native AMP
49
+
50
+ ### Training results
51
+
52
+
53
+
54
+ ### Framework versions
55
+
56
+ - PEFT 0.13.2
57
+ - Transformers 4.44.2
58
+ - Pytorch 2.5.0+cu121
59
+ - Datasets 3.0.1
60
+ - Tokenizers 0.19.1
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}\n {%- endif %}\n {{- \"\\n\\n# Tools\\n\\nYou may call one or more functions to assist with the user query.\\n\\nYou are provided with function signatures within <tools></tools> XML tags:\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\\n\\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\\n<tool_call>\\n{\\\"name\\\": <function-name>, \\\"arguments\\\": <args-json-object>}\\n</tool_call><|im_end|>\\n\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) or (message.role == \"assistant\" and not message.tool_calls) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + message.content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\"name\": \"' }}\n {{- tool_call.name }}\n {{- '\", \"arguments\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "model_max_length": 131072,
203
+ "pad_token": "<|endoftext|>",
204
+ "split_special_tokens": false,
205
+ "tokenizer_class": "Qwen2Tokenizer",
206
+ "unk_token": null
207
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff