doppler-gpu 0.4.11 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/README.md +79 -45
- package/models/catalog.json +29 -29
- package/package.json +12 -3
- package/src/client/doppler-registry.json +9 -9
- package/src/client/runtime/lora.js +5 -0
- package/src/client/runtime/model-session.d.ts +69 -1
- package/src/client/runtime/model-session.js +231 -0
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +3 -2
- package/src/config/kernels/kernel-ref-digests.js +2 -1
- package/src/config/kernels/registry.json +21 -2
- package/src/config/schema/adapter.schema.d.ts +6 -1
- package/src/config/schema/adapter.schema.js +5 -0
- package/src/experimental/adapters/artifact-contract.d.ts +83 -0
- package/src/experimental/adapters/artifact-contract.js +254 -0
- package/src/experimental/adapters/index.d.ts +25 -0
- package/src/experimental/adapters/index.js +12 -0
- package/src/experimental/adapters/lora-loader.js +9 -4
- package/src/experimental/training/artifacts.d.ts +160 -0
- package/src/experimental/training/attention-backward.d.ts +64 -0
- package/src/experimental/training/attention-forward.d.ts +22 -0
- package/src/experimental/training/attention-forward.js +82 -0
- package/src/experimental/training/autograd.d.ts +76 -0
- package/src/experimental/training/checkpoint.d.ts +36 -0
- package/src/experimental/training/clip.d.ts +9 -0
- package/src/experimental/training/dataloader.d.ts +8 -0
- package/src/experimental/training/distillation/student-fixture.js +1 -0
- package/src/experimental/training/export.d.ts +41 -0
- package/src/experimental/training/lora-pipeline.d.ts +186 -0
- package/src/experimental/training/lora-pipeline.js +5 -0
- package/src/experimental/training/lora.d.ts +20 -0
- package/src/experimental/training/lora.js +4 -3
- package/src/experimental/training/loss-scaling.d.ts +21 -0
- package/src/experimental/training/loss.d.ts +10 -0
- package/src/experimental/training/native-qwen-lora.d.ts +106 -0
- package/src/experimental/training/native-qwen-lora.js +449 -0
- package/src/experimental/training/objectives/base.d.ts +58 -0
- package/src/experimental/training/optimizer.d.ts +22 -0
- package/src/experimental/training/optimizer.js +1 -0
- package/src/experimental/training/runner.d.ts +249 -0
- package/src/experimental/training/trainer.d.ts +89 -0
- package/src/experimental/training/workloads.d.ts +205 -0
- package/src/gpu/kernels/backward/adam.d.ts +1 -0
- package/src/gpu/kernels/backward/adam.js +6 -2
- package/src/gpu/kernels/backward/adam.wgsl +3 -2
- package/src/gpu/kernels/backward/matmul_backward_q4k.wgsl +90 -0
- package/src/gpu/kernels/backward/utils.js +18 -4
- package/src/inference/pipelines/text/ffn/dense.js +16 -0
- package/src/inference/pipelines/text/generator.d.ts +5 -1
- package/src/inference/pipelines/text/generator.js +106 -0
- package/src/inference/pipelines/text/linear-attention.d.ts +2 -0
- package/src/inference/pipelines/text/linear-attention.js +77 -6
- package/src/inference/pipelines/text/lora-types.d.ts +6 -1
- package/src/inference/pipelines/text/lora-types.js +5 -0
- package/src/inference/pipelines/text/ops.js +1 -0
- package/src/inference/pipelines/text/types.d.ts +28 -0
- package/src/inference/pipelines/text.d.ts +7 -2
- package/src/inference/pipelines/text.js +4 -0
- package/src/models/diffusiongemma.js +1 -1
- package/src/models/embeddinggemma.js +1 -1
- package/src/models/gemma3.js +1 -1
- package/src/models/gemma4.js +1 -1
- package/src/models/qwen3.js +1 -1
- package/src/tooling/hf-registry-utils.js +1 -1
- package/src/tooling/node-browser-command-runner.d.ts +16 -0
- package/src/tooling/node-browser-command-runner.js +1 -1
- package/src/training-browser.d.ts +19 -0
- package/src/training-browser.js +13 -0
- package/src/training.d.ts +137 -0
- package/src/training.js +219 -0
- package/src/version.js +1 -1
- package/tests/kernels/browser/kernel-suite.js +9 -1
- package/tests/kernels/browser/test-page.js +4 -2
- package/tests/kernels/reference/adam.js +4 -2
- package/NOTICE +0 -5
|
@@ -2,12 +2,79 @@ import type { InferencePipeline, KVCacheSnapshot, PromptInput } from '../../infe
|
|
|
2
2
|
import type { ChatMessage } from '../../inference/pipelines/text/chat-format.js';
|
|
3
3
|
import type { GenerateOptions } from '../../generation/index.js';
|
|
4
4
|
import type { RDRRManifest } from '../../formats/rdrr/index.js';
|
|
5
|
-
import type { LogitsStepResult, PrefillResult, SequenceEncodeOptions, SequenceEncodeResult } from '../../inference/pipelines/text/types.d.ts';
|
|
5
|
+
import type { LogitsStepResult, PipelineStats, PrefillResult, SequenceEncodeOptions, SequenceEncodeResult } from '../../inference/pipelines/text/types.d.ts';
|
|
6
6
|
import type { LoRAManifest } from './types.js';
|
|
7
7
|
import type { LoRALoadOptions } from './lora.js';
|
|
8
8
|
|
|
9
9
|
export type DopplerGenerateOptions = Omit<GenerateOptions, 'stopTokens'>;
|
|
10
10
|
|
|
11
|
+
export interface DopplerGenerationConfigEvidence {
|
|
12
|
+
maxTokens: number;
|
|
13
|
+
temperature: number;
|
|
14
|
+
topP: number;
|
|
15
|
+
topK: number;
|
|
16
|
+
repetitionPenalty: number;
|
|
17
|
+
repetitionPenaltyWindow: number;
|
|
18
|
+
greedyThreshold: number;
|
|
19
|
+
suppressSpecialTokens: boolean;
|
|
20
|
+
suppressSpecialLikeTokens: boolean;
|
|
21
|
+
suppressTokenIds: number[];
|
|
22
|
+
stopSequences: string[];
|
|
23
|
+
useChatTemplate: boolean;
|
|
24
|
+
useSpeculative: boolean;
|
|
25
|
+
seed: number | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface DopplerGenerationBackendIdentity {
|
|
29
|
+
backend: 'webgpu';
|
|
30
|
+
adapter: {
|
|
31
|
+
vendor: string | null;
|
|
32
|
+
architecture: string | null;
|
|
33
|
+
device: string | null;
|
|
34
|
+
description: string | null;
|
|
35
|
+
};
|
|
36
|
+
hasF16: boolean;
|
|
37
|
+
hasSubgroups: boolean;
|
|
38
|
+
maxBufferSize: number;
|
|
39
|
+
deviceEpoch: number;
|
|
40
|
+
kernelPathId: string | null;
|
|
41
|
+
kernelPathSource: string | null;
|
|
42
|
+
executionPlanId: string | null;
|
|
43
|
+
activationDtype: string | null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface DopplerGenerationEvidence {
|
|
47
|
+
schema: 'doppler_generation_evidence/v1';
|
|
48
|
+
outputText: string;
|
|
49
|
+
tokenIds: number[];
|
|
50
|
+
transcript: {
|
|
51
|
+
schema: 'doppler_generation_transcript/v1';
|
|
52
|
+
outputText: string;
|
|
53
|
+
tokenIds: number[];
|
|
54
|
+
};
|
|
55
|
+
transcriptHash: string;
|
|
56
|
+
generationConfig: DopplerGenerationConfigEvidence;
|
|
57
|
+
generationConfigHash: string;
|
|
58
|
+
runtimeProfile: {
|
|
59
|
+
schema: 'doppler_runtime_profile/v1';
|
|
60
|
+
runtime: {
|
|
61
|
+
package: 'doppler-gpu';
|
|
62
|
+
version: string;
|
|
63
|
+
surface: 'node' | 'browser';
|
|
64
|
+
};
|
|
65
|
+
model: {
|
|
66
|
+
modelId: string | null;
|
|
67
|
+
manifestHash: string | null;
|
|
68
|
+
activeAdapter: string | null;
|
|
69
|
+
};
|
|
70
|
+
backendIdentity: DopplerGenerationBackendIdentity;
|
|
71
|
+
};
|
|
72
|
+
runtimeProfileHash: string;
|
|
73
|
+
backendIdentity: DopplerGenerationBackendIdentity;
|
|
74
|
+
backendIdentityHash: string;
|
|
75
|
+
stats: PipelineStats | null;
|
|
76
|
+
}
|
|
77
|
+
|
|
11
78
|
export interface DopplerChatResponse {
|
|
12
79
|
content: string;
|
|
13
80
|
usage: {
|
|
@@ -20,6 +87,7 @@ export interface DopplerChatResponse {
|
|
|
20
87
|
export interface DopplerModelHandle {
|
|
21
88
|
generate(prompt: string, options?: DopplerGenerateOptions): AsyncGenerator<string, void, void>;
|
|
22
89
|
generateText(prompt: string, options?: DopplerGenerateOptions): Promise<string>;
|
|
90
|
+
generateWithEvidence(prompt: string, options?: DopplerGenerateOptions): Promise<DopplerGenerationEvidence>;
|
|
23
91
|
chat(messages: ChatMessage[], options?: DopplerGenerateOptions): AsyncGenerator<string, void, void>;
|
|
24
92
|
chatText(messages: ChatMessage[], options?: DopplerGenerateOptions): Promise<DopplerChatResponse>;
|
|
25
93
|
encodeSequence(sequence: string, options?: SequenceEncodeOptions): Promise<SequenceEncodeResult>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getKernelCapabilities } from '../../gpu/device.js';
|
|
2
2
|
import { formatChatMessages } from '../../inference/pipelines/text/chat-format.js';
|
|
3
|
+
import { resolveSamplingConfig } from '../../inference/pipelines/text/sampling-config.js';
|
|
4
|
+
import { DOPPLER_VERSION } from '../../version.js';
|
|
5
|
+
import { isNodeRuntime } from '../../utils/runtime-env.js';
|
|
3
6
|
import {
|
|
4
7
|
activateLoRAFromTrainingOutputForPipeline,
|
|
5
8
|
getActiveLoRAForPipeline,
|
|
@@ -58,6 +61,208 @@ async function collectText(iterable) {
|
|
|
58
61
|
return output;
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
const GENERATION_EVIDENCE_SCHEMA = 'doppler_generation_evidence/v1';
|
|
65
|
+
const GENERATION_TRANSCRIPT_SCHEMA = 'doppler_generation_transcript/v1';
|
|
66
|
+
const RUNTIME_PROFILE_SCHEMA = 'doppler_runtime_profile/v1';
|
|
67
|
+
|
|
68
|
+
function canonicalizeEvidence(value) {
|
|
69
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'string') {
|
|
70
|
+
return JSON.stringify(value);
|
|
71
|
+
}
|
|
72
|
+
if (typeof value === 'number') {
|
|
73
|
+
if (!Number.isFinite(value)) {
|
|
74
|
+
throw new Error('Doppler generation evidence cannot hash non-finite numbers.');
|
|
75
|
+
}
|
|
76
|
+
return JSON.stringify(value);
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(value)) {
|
|
79
|
+
return `[${value.map((entry) => canonicalizeEvidence(entry)).join(',')}]`;
|
|
80
|
+
}
|
|
81
|
+
if (value && typeof value === 'object') {
|
|
82
|
+
const entries = Object.keys(value)
|
|
83
|
+
.sort()
|
|
84
|
+
.map((key) => `${JSON.stringify(key)}:${canonicalizeEvidence(value[key])}`);
|
|
85
|
+
return `{${entries.join(',')}}`;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`Doppler generation evidence cannot hash ${typeof value} values.`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function bytesToHex(bytes) {
|
|
91
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function hashEvidenceValue(value) {
|
|
95
|
+
if (!globalThis.crypto?.subtle) {
|
|
96
|
+
throw new Error('Doppler generation evidence requires Web Crypto SHA-256 support.');
|
|
97
|
+
}
|
|
98
|
+
const bytes = new TextEncoder().encode(canonicalizeEvidence(value));
|
|
99
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
|
|
100
|
+
return `sha256:${bytesToHex(new Uint8Array(digest))}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function cleanEvidenceString(value) {
|
|
104
|
+
const text = String(value ?? '').trim();
|
|
105
|
+
return text || null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function buildAdapterIdentity(deviceInfo = {}) {
|
|
109
|
+
return {
|
|
110
|
+
vendor: cleanEvidenceString(deviceInfo.vendor),
|
|
111
|
+
architecture: cleanEvidenceString(deviceInfo.architecture),
|
|
112
|
+
device: cleanEvidenceString(deviceInfo.device),
|
|
113
|
+
description: cleanEvidenceString(deviceInfo.description),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function buildGenerationBackendIdentity({
|
|
118
|
+
deviceInfo = null,
|
|
119
|
+
kernelCapabilities = null,
|
|
120
|
+
stats = null,
|
|
121
|
+
} = {}) {
|
|
122
|
+
const capabilities = kernelCapabilities && typeof kernelCapabilities === 'object'
|
|
123
|
+
? kernelCapabilities
|
|
124
|
+
: {};
|
|
125
|
+
const adapter = deviceInfo && typeof deviceInfo === 'object'
|
|
126
|
+
? deviceInfo
|
|
127
|
+
: (capabilities.adapterInfo || {});
|
|
128
|
+
const executionPlan = stats?.executionPlan || null;
|
|
129
|
+
const finalPlanId = executionPlan?.finalActivePlanId
|
|
130
|
+
|| executionPlan?.activePlanIdAtStart
|
|
131
|
+
|| null;
|
|
132
|
+
const primaryPlan = executionPlan?.primary || null;
|
|
133
|
+
const fallbackPlan = executionPlan?.fallback || null;
|
|
134
|
+
const finalPlan = finalPlanId && fallbackPlan?.id === finalPlanId
|
|
135
|
+
? fallbackPlan
|
|
136
|
+
: primaryPlan;
|
|
137
|
+
return {
|
|
138
|
+
backend: 'webgpu',
|
|
139
|
+
adapter: buildAdapterIdentity(adapter),
|
|
140
|
+
hasF16: capabilities.hasF16 === true,
|
|
141
|
+
hasSubgroups: capabilities.hasSubgroups === true,
|
|
142
|
+
maxBufferSize: Number(capabilities.maxBufferSize || 0),
|
|
143
|
+
deviceEpoch: Number(capabilities.deviceEpoch || 0),
|
|
144
|
+
kernelPathId: cleanEvidenceString(stats?.kernelPathId || finalPlan?.kernelPathId),
|
|
145
|
+
kernelPathSource: cleanEvidenceString(stats?.kernelPathSource || finalPlan?.kernelPathSource),
|
|
146
|
+
executionPlanId: cleanEvidenceString(finalPlanId),
|
|
147
|
+
activationDtype: cleanEvidenceString(finalPlan?.activationDtype),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function buildGenerationEvidence({
|
|
152
|
+
outputText,
|
|
153
|
+
tokenIds,
|
|
154
|
+
generationConfig,
|
|
155
|
+
modelId,
|
|
156
|
+
manifestHash,
|
|
157
|
+
activeAdapter,
|
|
158
|
+
backendIdentity,
|
|
159
|
+
stats,
|
|
160
|
+
} = {}) {
|
|
161
|
+
if (typeof outputText !== 'string') {
|
|
162
|
+
throw new Error('Doppler generation evidence requires outputText.');
|
|
163
|
+
}
|
|
164
|
+
if (!Array.isArray(tokenIds) || tokenIds.some((tokenId) => !Number.isInteger(tokenId) || tokenId < 0)) {
|
|
165
|
+
throw new Error('Doppler generation evidence requires non-negative integer tokenIds.');
|
|
166
|
+
}
|
|
167
|
+
const transcript = {
|
|
168
|
+
schema: GENERATION_TRANSCRIPT_SCHEMA,
|
|
169
|
+
outputText,
|
|
170
|
+
tokenIds: [...tokenIds],
|
|
171
|
+
};
|
|
172
|
+
const generationConfigHash = await hashEvidenceValue(generationConfig);
|
|
173
|
+
const transcriptHash = await hashEvidenceValue(transcript);
|
|
174
|
+
const backendIdentityHash = await hashEvidenceValue(backendIdentity);
|
|
175
|
+
const runtimeProfile = {
|
|
176
|
+
schema: RUNTIME_PROFILE_SCHEMA,
|
|
177
|
+
runtime: {
|
|
178
|
+
package: 'doppler-gpu',
|
|
179
|
+
version: DOPPLER_VERSION,
|
|
180
|
+
surface: isNodeRuntime() ? 'node' : 'browser',
|
|
181
|
+
},
|
|
182
|
+
model: {
|
|
183
|
+
modelId: cleanEvidenceString(modelId),
|
|
184
|
+
manifestHash: cleanEvidenceString(manifestHash),
|
|
185
|
+
activeAdapter: cleanEvidenceString(activeAdapter),
|
|
186
|
+
},
|
|
187
|
+
backendIdentity,
|
|
188
|
+
};
|
|
189
|
+
const runtimeProfileHash = await hashEvidenceValue(runtimeProfile);
|
|
190
|
+
return {
|
|
191
|
+
schema: GENERATION_EVIDENCE_SCHEMA,
|
|
192
|
+
outputText,
|
|
193
|
+
tokenIds: [...tokenIds],
|
|
194
|
+
transcript,
|
|
195
|
+
transcriptHash,
|
|
196
|
+
generationConfig,
|
|
197
|
+
generationConfigHash,
|
|
198
|
+
runtimeProfile,
|
|
199
|
+
runtimeProfileHash,
|
|
200
|
+
backendIdentity,
|
|
201
|
+
backendIdentityHash,
|
|
202
|
+
stats: stats && typeof stats === 'object' ? stats : null,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function resolveUseChatTemplate(pipeline, options) {
|
|
207
|
+
if (typeof options.useChatTemplate === 'boolean') {
|
|
208
|
+
return options.useChatTemplate;
|
|
209
|
+
}
|
|
210
|
+
const runtimeValue = pipeline?.runtimeConfig?.inference?.chatTemplate?.enabled;
|
|
211
|
+
if (typeof runtimeValue === 'boolean') {
|
|
212
|
+
return runtimeValue;
|
|
213
|
+
}
|
|
214
|
+
const modelValue = pipeline?.modelConfig?.chatTemplateEnabled;
|
|
215
|
+
return typeof modelValue === 'boolean' ? modelValue : false;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function resolveGenerationConfigEvidence(pipeline, options) {
|
|
219
|
+
const runtimeConfig = pipeline?.runtimeConfig;
|
|
220
|
+
const generation = runtimeConfig?.inference?.generation;
|
|
221
|
+
if (!generation || typeof generation !== 'object' || Array.isArray(generation)) {
|
|
222
|
+
throw new Error('Loaded Doppler pipeline does not expose resolved generation config.');
|
|
223
|
+
}
|
|
224
|
+
const maxTokens = options.maxTokens ?? generation.maxTokens;
|
|
225
|
+
if (!Number.isInteger(maxTokens) || maxTokens <= 0) {
|
|
226
|
+
throw new Error('Resolved Doppler generation maxTokens must be a positive integer.');
|
|
227
|
+
}
|
|
228
|
+
const sampling = resolveSamplingConfig(options, runtimeConfig);
|
|
229
|
+
const stopSequences = options.stopSequences ?? [];
|
|
230
|
+
if (!Array.isArray(stopSequences) || stopSequences.some((value) => typeof value !== 'string')) {
|
|
231
|
+
throw new Error('Resolved Doppler stopSequences must be an array of strings.');
|
|
232
|
+
}
|
|
233
|
+
const useSpeculative = options.useSpeculative ?? generation.useSpeculative;
|
|
234
|
+
if (typeof useSpeculative !== 'boolean') {
|
|
235
|
+
throw new Error('Resolved Doppler useSpeculative must be a boolean.');
|
|
236
|
+
}
|
|
237
|
+
const seed = options.seed ?? null;
|
|
238
|
+
if (seed !== null && (!Number.isFinite(seed) || seed < 0)) {
|
|
239
|
+
throw new Error('Resolved Doppler seed must be null or a non-negative number.');
|
|
240
|
+
}
|
|
241
|
+
return {
|
|
242
|
+
maxTokens,
|
|
243
|
+
temperature: sampling.temperature,
|
|
244
|
+
topP: sampling.topP,
|
|
245
|
+
topK: sampling.topK,
|
|
246
|
+
repetitionPenalty: sampling.repetitionPenalty,
|
|
247
|
+
repetitionPenaltyWindow: sampling.repetitionPenaltyWindow,
|
|
248
|
+
greedyThreshold: sampling.greedyThreshold,
|
|
249
|
+
suppressSpecialTokens: sampling.suppressSpecialTokens,
|
|
250
|
+
suppressSpecialLikeTokens: sampling.suppressSpecialLikeTokens,
|
|
251
|
+
suppressTokenIds: [...sampling.suppressTokenIds],
|
|
252
|
+
stopSequences: [...stopSequences],
|
|
253
|
+
useChatTemplate: resolveUseChatTemplate(pipeline, options),
|
|
254
|
+
useSpeculative,
|
|
255
|
+
seed,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function decodeGeneratedTokens(pipeline, tokenIds) {
|
|
260
|
+
if (!pipeline?.tokenizer || typeof pipeline.tokenizer.decode !== 'function') {
|
|
261
|
+
throw new Error('Loaded Doppler pipeline does not expose tokenizer.decode().');
|
|
262
|
+
}
|
|
263
|
+
return String(pipeline.tokenizer.decode(tokenIds, true, false));
|
|
264
|
+
}
|
|
265
|
+
|
|
61
266
|
export function createModelHandle(pipeline, resolved) {
|
|
62
267
|
return {
|
|
63
268
|
generate(prompt, options = {}) {
|
|
@@ -68,6 +273,32 @@ export function createModelHandle(pipeline, resolved) {
|
|
|
68
273
|
assertSupportedGenerationOptions(options);
|
|
69
274
|
return collectText(pipeline.generate(prompt, options));
|
|
70
275
|
},
|
|
276
|
+
async generateWithEvidence(prompt, options = {}) {
|
|
277
|
+
assertSupportedGenerationOptions(options);
|
|
278
|
+
const generationConfig = resolveGenerationConfigEvidence(pipeline, options);
|
|
279
|
+
const result = await pipeline.generateTokenIds(prompt, options);
|
|
280
|
+
const tokenIds = Array.from(result?.tokenIds || [], Number);
|
|
281
|
+
const outputText = decodeGeneratedTokens(pipeline, tokenIds);
|
|
282
|
+
const stats = result?.stats || pipeline.getStats?.() || null;
|
|
283
|
+
const kernelCapabilities = typeof pipeline.getKernelCapabilities === 'function'
|
|
284
|
+
? pipeline.getKernelCapabilities()
|
|
285
|
+
: getKernelCapabilities();
|
|
286
|
+
const backendIdentity = buildGenerationBackendIdentity({
|
|
287
|
+
deviceInfo: kernelCapabilities?.adapterInfo || null,
|
|
288
|
+
kernelCapabilities,
|
|
289
|
+
stats,
|
|
290
|
+
});
|
|
291
|
+
return buildGenerationEvidence({
|
|
292
|
+
outputText,
|
|
293
|
+
tokenIds,
|
|
294
|
+
generationConfig,
|
|
295
|
+
modelId: resolved.modelId,
|
|
296
|
+
manifestHash: resolved.manifestHash || null,
|
|
297
|
+
activeAdapter: getActiveLoRAForPipeline(pipeline),
|
|
298
|
+
backendIdentity,
|
|
299
|
+
stats,
|
|
300
|
+
});
|
|
301
|
+
},
|
|
71
302
|
chat(messages, options = {}) {
|
|
72
303
|
assertSupportedGenerationOptions(options);
|
|
73
304
|
return pipeline.generate(messages, options);
|
|
@@ -38,7 +38,7 @@ export const KERNEL_REF_CONTENT_DIGESTS = Object.freeze({
|
|
|
38
38
|
"attention_streaming_f16kv.wgsl#main": "c3ec920699a81ee6df04a64eb0ea2477bec168ebb809af29f2d4b0924a4bdf8f",
|
|
39
39
|
"attention_streaming.wgsl#main": "bf6e44bbd021bd6752c311735f577a5ff05327f69fc7712d548ed3c84a8f4149",
|
|
40
40
|
"attention.wgsl#main": "9e066a9a201a8b10707995a4b64322c68641873afb017e8f96d5249edc6caf55",
|
|
41
|
-
"backward/adam.wgsl#main": "
|
|
41
|
+
"backward/adam.wgsl#main": "0ed4c4bdd9dac17d658b9c194233449e40d90749cac03040e0f2e63461943baa",
|
|
42
42
|
"backward/attention_backward.wgsl#main": "482e144cc1c76f371e5b39f439e9cab591db03e469045424c7de107adbd498c4",
|
|
43
43
|
"backward/bias_add_backward.wgsl#main": "413b1fe8682c09075e2dccc40caf3ebdae13957133224fd4e4497ca9c5109c47",
|
|
44
44
|
"backward/causal_conv1d_silu_backward.wgsl#main": "baaeec38caf714d12bdb48e1418c79df1736f11b79ed55813a1a9de666039593",
|
|
@@ -52,6 +52,7 @@ export const KERNEL_REF_CONTENT_DIGESTS = Object.freeze({
|
|
|
52
52
|
"backward/groupnorm_backward.wgsl#main": "2962192fd365b0d4e95a02273d07724d0f145137bf0e2545a9da85b21ed30ec3",
|
|
53
53
|
"backward/layernorm_backward.wgsl#main": "0d190147ce1291ca24469034001f7dfbfaff1318fe474e90bbcc472983c338ad",
|
|
54
54
|
"backward/matmul_backward_f16w.wgsl#main": "93b83783a286b456792d7c595a2c205ee990abbb485dbfc17185db3df7bf483a",
|
|
55
|
+
"backward/matmul_backward_q4k.wgsl#main": "220d2fbd4dde1a54f13e69def8d62299f05afcbdee22b4601e645b4889dcd105",
|
|
55
56
|
"backward/matmul_backward.wgsl#main": "989994ed66bb5c1564a550df9df3e38993f23d2704f527136bce71c521c1a7dc",
|
|
56
57
|
"backward/matmul_transpose_a.wgsl#main": "48f9efa999af7614cf575026afd9ea96f1fc7164843e9c46336ebad838e0cea0",
|
|
57
58
|
"backward/pixel_shuffle_backward.wgsl#main": "d56095ace4c14e267ae590f823a0c6d3da07c4dac35071ab17a831418f5bd27c",
|
|
@@ -3161,14 +3161,19 @@
|
|
|
3161
3161
|
"type": "u32",
|
|
3162
3162
|
"offset": 16
|
|
3163
3163
|
},
|
|
3164
|
+
{
|
|
3165
|
+
"name": "num_blocks_per_row",
|
|
3166
|
+
"type": "u32",
|
|
3167
|
+
"offset": 20
|
|
3168
|
+
},
|
|
3164
3169
|
{
|
|
3165
3170
|
"name": "logit_softcap",
|
|
3166
3171
|
"type": "f32",
|
|
3167
3172
|
"offset": 20
|
|
3168
3173
|
},
|
|
3169
3174
|
{
|
|
3170
|
-
"name": "
|
|
3171
|
-
"type": "
|
|
3175
|
+
"name": "weightDecay",
|
|
3176
|
+
"type": "f32",
|
|
3172
3177
|
"offset": 24
|
|
3173
3178
|
},
|
|
3174
3179
|
{
|
|
@@ -8449,6 +8454,20 @@
|
|
|
8449
8454
|
"ruleChains": [],
|
|
8450
8455
|
"wgslOnDisk": true
|
|
8451
8456
|
}
|
|
8457
|
+
},
|
|
8458
|
+
"q4k_weight": {
|
|
8459
|
+
"wgsl": "backward/matmul_backward_q4k.wgsl",
|
|
8460
|
+
"entryPoint": "main",
|
|
8461
|
+
"workgroup": [16,16,1],
|
|
8462
|
+
"requires": [],
|
|
8463
|
+
"weightDtype": "q4k",
|
|
8464
|
+
"description": "Input gradient through a frozen row-wise Q4_K weight stored as [N,K]",
|
|
8465
|
+
"reachability": {
|
|
8466
|
+
"status": "unused",
|
|
8467
|
+
"inlineConfigs": [],
|
|
8468
|
+
"ruleChains": [],
|
|
8469
|
+
"wgslOnDisk": true
|
|
8470
|
+
}
|
|
8452
8471
|
}
|
|
8453
8472
|
}
|
|
8454
8473
|
},
|
|
@@ -6,7 +6,12 @@ export type LoraTargetModule =
|
|
|
6
6
|
| 'gate_proj'
|
|
7
7
|
| 'up_proj'
|
|
8
8
|
| 'down_proj'
|
|
9
|
-
| 'gate_up_proj'
|
|
9
|
+
| 'gate_up_proj'
|
|
10
|
+
| 'in_proj_a'
|
|
11
|
+
| 'in_proj_b'
|
|
12
|
+
| 'in_proj_qkv'
|
|
13
|
+
| 'in_proj_z'
|
|
14
|
+
| 'out_proj';
|
|
10
15
|
|
|
11
16
|
export const VALID_LORA_TARGET_MODULES: readonly LoraTargetModule[];
|
|
12
17
|
|
|
@@ -11,6 +11,11 @@ export const VALID_LORA_TARGET_MODULES = [
|
|
|
11
11
|
'up_proj',
|
|
12
12
|
'down_proj',
|
|
13
13
|
'gate_up_proj',
|
|
14
|
+
'in_proj_a',
|
|
15
|
+
'in_proj_b',
|
|
16
|
+
'in_proj_qkv',
|
|
17
|
+
'in_proj_z',
|
|
18
|
+
'out_proj',
|
|
14
19
|
];
|
|
15
20
|
|
|
16
21
|
// =============================================================================
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { AdapterManifest } from './adapter-manifest.js';
|
|
2
|
+
|
|
3
|
+
export type AdapterArtifactLifecycle = 'preserved' | 'candidate' | 'qualified' | 'promoted' | 'revoked';
|
|
4
|
+
export type AdapterArtifactAccess = 'public' | 'gated' | 'private';
|
|
5
|
+
|
|
6
|
+
export interface HuggingFaceArtifactOrigin {
|
|
7
|
+
provider: 'huggingface';
|
|
8
|
+
repoId: string;
|
|
9
|
+
revision: string;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface GcsArtifactOrigin {
|
|
14
|
+
provider: 'gcs';
|
|
15
|
+
bucket: string;
|
|
16
|
+
object: string;
|
|
17
|
+
generation: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HttpsPreservationOrigin {
|
|
21
|
+
provider: 'https-preservation';
|
|
22
|
+
url: string;
|
|
23
|
+
revision: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type AdapterArtifactOrigin = HuggingFaceArtifactOrigin | GcsArtifactOrigin;
|
|
27
|
+
export type AdapterArtifactMirror = AdapterArtifactOrigin | HttpsPreservationOrigin;
|
|
28
|
+
|
|
29
|
+
export interface AdapterArtifactRecord {
|
|
30
|
+
schema: 'doppler.adapter-artifact/v1';
|
|
31
|
+
artifactId: string;
|
|
32
|
+
lifecycle: AdapterArtifactLifecycle;
|
|
33
|
+
access: AdapterArtifactAccess;
|
|
34
|
+
weights: {
|
|
35
|
+
sha256: string;
|
|
36
|
+
bytes: number;
|
|
37
|
+
format: 'safetensors';
|
|
38
|
+
};
|
|
39
|
+
adapterManifest: AdapterManifest;
|
|
40
|
+
trainingBase: {
|
|
41
|
+
repoId: string;
|
|
42
|
+
revision: string;
|
|
43
|
+
};
|
|
44
|
+
runtimeBase: {
|
|
45
|
+
modelId: string;
|
|
46
|
+
modelSha256: string;
|
|
47
|
+
manifestSha256: string;
|
|
48
|
+
tokenizerSha256: string;
|
|
49
|
+
weightPackId: string;
|
|
50
|
+
weightPackSha256: string;
|
|
51
|
+
manifestVariantId: string;
|
|
52
|
+
conversionConfigSha256: string;
|
|
53
|
+
};
|
|
54
|
+
primaryOrigin: AdapterArtifactOrigin | null;
|
|
55
|
+
preservationMirrors: AdapterArtifactMirror[];
|
|
56
|
+
evidence: Array<{ kind: string; path: string; sha256: string }>;
|
|
57
|
+
claimBoundary?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface AdapterArtifactValidationError {
|
|
61
|
+
field: string;
|
|
62
|
+
message: string;
|
|
63
|
+
value?: unknown;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface AdapterArtifactValidationResult {
|
|
67
|
+
valid: boolean;
|
|
68
|
+
errors: AdapterArtifactValidationError[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare const ADAPTER_ARTIFACT_SCHEMA: 'doppler.adapter-artifact/v1';
|
|
72
|
+
export declare const ADAPTER_ARTIFACT_LIFECYCLES: readonly AdapterArtifactLifecycle[];
|
|
73
|
+
export declare const ADAPTER_ARTIFACT_ACCESS: readonly AdapterArtifactAccess[];
|
|
74
|
+
export declare const ADAPTER_ARTIFACT_ORIGIN_PROVIDERS: readonly ['huggingface', 'gcs', 'https-preservation'];
|
|
75
|
+
|
|
76
|
+
export declare function validateAdapterArtifactOrigin(
|
|
77
|
+
origin: unknown,
|
|
78
|
+
options?: { allowPreservation?: boolean }
|
|
79
|
+
): AdapterArtifactValidationResult;
|
|
80
|
+
export declare function validateAdapterArtifactRecord(record: unknown): AdapterArtifactValidationResult;
|
|
81
|
+
export declare function assertAdapterArtifactRecord<T extends AdapterArtifactRecord>(record: T): T;
|
|
82
|
+
export declare function buildImmutableArtifactUrl(origin: AdapterArtifactOrigin): string;
|
|
83
|
+
export declare function adapterArtifactCacheKey(record: AdapterArtifactRecord): string;
|