doppler-gpu 0.4.3 → 0.4.5
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 +28 -0
- package/README.md +67 -34
- package/assets/doppler.svg +57 -1601
- package/package.json +36 -5
- package/src/cli/cli-output.js +34 -1
- package/src/cli/doppler-cli.d.ts +18 -0
- package/src/cli/doppler-cli.js +68 -35
- package/src/cli/doppler-serve.d.ts +210 -0
- package/src/cli/doppler-serve.js +468 -42
- package/src/client/doppler-registry.json +3 -5
- package/src/client/provider.d.ts +1 -1
- package/src/client/provider.js +1 -1
- package/src/client/runtime/index.js +13 -0
- package/src/client/runtime/lora.d.ts +11 -1
- package/src/client/runtime/lora.js +28 -7
- package/src/client/runtime/model-manager.js +35 -11
- package/src/client/runtime/model-session.d.ts +2 -1
- package/src/client/runtime/model-session.js +2 -2
- package/src/client/runtime/model-source.js +20 -1
- package/src/client/runtime/types.d.ts +8 -0
- package/src/client/wrap-pipeline-handle.d.ts +62 -0
- package/src/client/wrap-pipeline-handle.js +188 -13
- package/src/config/conversion/README.md +5 -0
- package/src/config/conversion/diffusiongemma/diffusiongemma-26b-a4b-it-q4k-ehf16-af16.json +646 -0
- package/src/config/conversion/embeddinggemma/google-embeddinggemma-300m-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gemma3/gemma-3-1b-it-f16-af32.json +4 -4
- package/src/config/conversion/gemma3/gemma-3-1b-it-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma3/gemma-3-270m-it-f16-af32.json +393 -0
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af16.json +425 -0
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af32.json +17 -9
- package/src/config/conversion/gemma3/translategemma-4b-1b-enes-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma3/translategemma-4b-it-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-af16.json +737 -0
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-af32.json +730 -0
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-q4k-ehf16-hq4k-af16.json +780 -0
- package/src/config/conversion/gemma4/gemma-4-12b-it-text-w4a16-ct-ehf16-af16.json +716 -0
- package/src/config/conversion/gemma4/gemma-4-31b-it-text-q4k-ehf16-af16.json +5 -5
- package/src/config/conversion/gemma4/gemma-4-31b-it-text-q4k-ehf16-af32.json +4 -4
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af16-int4ple.json +14 -12
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32-int4ple.json +7 -7
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32.json +7 -7
- package/src/config/conversion/gemma4/gemma-4-moe-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/gpt-oss-20b-f16-xmxfp4.json +3 -3
- package/src/config/conversion/janus/janus-pro-1b-text-q4k-ehaf16.json +3 -3
- package/src/config/conversion/lfm2/lfm2.5-1.2b-instruct-q4k-ehf16-af32.json +3 -3
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +8 -4
- package/src/config/conversion/qwen3/qwen-3-5-2b-q4k-ehaf16.json +8 -4
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-eaf16.json +9 -5
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-ehaf16.json +8 -4
- package/src/config/goal-completion-matrix.json +552 -0
- package/src/config/kernel-path-loader.js +192 -38
- package/src/config/kernels/kernel-ref-digests.js +52 -18
- package/src/config/kernels/registry.json +3017 -744
- package/src/config/merge-contract-check.js +7 -3
- package/src/config/merge-helpers.d.ts +2 -0
- package/src/config/merge-helpers.js +1 -0
- package/src/config/merge.d.ts +1 -0
- package/src/config/merge.js +30 -0
- package/src/config/model-lanes/catalog-lane-resolver.d.ts +66 -0
- package/src/config/model-lanes/catalog-lane-resolver.js +170 -0
- package/src/config/param-validator.js +4 -0
- package/src/config/runtime/experiments/verify/lfm2-verify.json +3 -3
- package/src/config/runtime/profiles/diffusiongemma-26b-a4b-throughput.json +26 -0
- package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-overlapped-probe.json +42 -0
- package/src/config/runtime/profiles/gemma3-270m-q4k-throughput-probe.json +39 -0
- package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-b4.json +48 -0
- package/src/config/runtime/profiles/gemma4-12b-rdrr-safe-single.json +46 -0
- package/src/config/schema/buffer-pool.schema.js +3 -3
- package/src/config/schema/claim-evidence-contract.schema.json +93 -0
- package/src/config/schema/command-surface-contract.schema.json +81 -0
- package/src/config/schema/converter.schema.d.ts +11 -0
- package/src/config/schema/converter.schema.js +8 -0
- package/src/config/schema/doppler.schema.d.ts +1 -0
- package/src/config/schema/doppler.schema.js +38 -6
- package/src/config/schema/execution-v1.schema.d.ts +27 -0
- package/src/config/schema/execution-v1.schema.js +28 -19
- package/src/config/schema/goal-completion-matrix.schema.json +223 -0
- package/src/config/schema/inference.schema.d.ts +11 -0
- package/src/config/schema/manifest.schema.d.ts +107 -1
- package/src/config/schema/manifest.schema.js +10 -1
- package/src/config/schema/model-artifact-contract.schema.json +119 -0
- package/src/config/schema/moe.schema.d.ts +13 -0
- package/src/config/schema/moe.schema.js +1 -1
- package/src/config/schema/policy-schema-registry.json +26 -0
- package/src/config/schema/subsystem-support-contract.schema.json +48 -0
- package/src/config/schema/training-metrics.schema.d.ts +1 -1
- package/src/config/schema/training-metrics.schema.js +4 -3
- package/src/config/source-packages/litert/gemma-4-12b-it.json +390 -0
- package/src/config/source-packages/litert/gemma-4-e2b-it.json +7 -7
- package/src/config/source-packages/litert/gemma-4-e4b-it.json +370 -0
- package/src/config/source-packages/registry.json +25 -0
- package/src/config/supported-operations.json +5 -0
- package/src/config/transforms/capability-transform-resolver.d.ts +13 -2
- package/src/config/transforms/execution-graph-transforms.d.ts +42 -0
- package/src/config/transforms/execution-graph-transforms.js +227 -230
- package/src/converter/conversion-plan.d.ts +2 -0
- package/src/converter/conversion-plan.js +18 -4
- package/src/converter/core.d.ts +8 -0
- package/src/converter/core.js +574 -12
- package/src/converter/quantization-info.js +179 -2
- package/src/converter/quantizer.d.ts +5 -4
- package/src/converter/quantizer.js +16 -2
- package/src/experimental/adapters/lora-loader.js +109 -24
- package/src/experimental/diffusion/index.d.ts +24 -0
- package/src/experimental/diffusion/index.js +10 -0
- package/src/experimental/distribution/descriptor-transport.d.ts +117 -0
- package/src/experimental/distribution/descriptor-transport.js +342 -0
- package/src/experimental/training/README.md +11 -0
- package/src/experimental/training/autograd.js +33 -8
- package/src/experimental/training/datasets/gepa-frontier.d.ts +41 -0
- package/src/experimental/training/datasets/gepa-frontier.js +220 -0
- package/src/experimental/training/datasets/index.d.ts +13 -1
- package/src/experimental/training/datasets/index.js +8 -1
- package/src/experimental/training/datasets/teacher-traces.d.ts +51 -0
- package/src/experimental/training/datasets/teacher-traces.js +279 -0
- package/src/experimental/training/datasets/text-pairs.d.ts +45 -0
- package/src/experimental/training/datasets/text-pairs.js +82 -5
- package/src/experimental/training/distillation/student-fixture.d.ts +5 -0
- package/src/experimental/training/distillation/student-fixture.js +290 -32
- package/src/experimental/training/export.d.ts +9 -0
- package/src/experimental/training/export.js +113 -7
- package/src/experimental/training/index.d.ts +13 -1
- package/src/experimental/training/index.js +13 -1
- package/src/experimental/training/lora-pipeline.d.ts +143 -0
- package/src/experimental/training/lora-pipeline.js +1737 -49
- package/src/experimental/training/lora.js +23 -1
- package/src/experimental/training/loss.js +1 -1
- package/src/experimental/training/operator-agent-eval.d.ts +65 -0
- package/src/experimental/training/operator-agent-eval.js +326 -0
- package/src/experimental/training/operator-command.js +310 -51
- package/src/experimental/training/runner.d.ts +1 -0
- package/src/experimental/training/runner.js +4 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-agent-harness-gemma270m-f16-sft-tiny.json +160 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-code-agent-gemma270m-f16-sft-tiny.json +175 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-code-agent-sft-tiny.json +175 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-js-json-gemma270m-f16-sft-tiny.json +160 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-review-gemma270m-f16-sft-tiny.json +162 -0
- package/src/experimental/training/workload-packs/distill-glm52-doppler-wgsl-gemma270m-f16-sft-tiny.json +160 -0
- package/src/experimental/training/workload-packs/lora-doppler-agent-harness-gemma270m-f16-tiny.json +137 -0
- package/src/experimental/training/workload-packs/lora-doppler-code-agent-gemma270m-f16-tiny.json +152 -0
- package/src/experimental/training/workload-packs/lora-doppler-code-agent-tiny.json +152 -0
- package/src/experimental/training/workload-packs/lora-doppler-js-json-gemma270m-f16-tiny.json +137 -0
- package/src/experimental/training/workload-packs/lora-doppler-review-gemma270m-f16-tiny.json +139 -0
- package/src/experimental/training/workload-packs/lora-doppler-wgsl-gemma270m-f16-tiny.json +137 -0
- package/src/experimental/training/workload-packs/registry.json +186 -6
- package/src/experimental/training/workloads.d.ts +37 -0
- package/src/experimental/training/workloads.js +110 -1
- package/src/formats/rdrr/functional-descriptor.d.ts +73 -0
- package/src/formats/rdrr/functional-descriptor.js +230 -0
- package/src/formats/rdrr/index.d.ts +1 -0
- package/src/formats/rdrr/index.js +1 -0
- package/src/formats/rdrr/parsing.js +22 -6
- package/src/formats/rdrr/source-transform-contract.js +10 -1
- package/src/formats/rdrr/storage-descriptor.js +9 -2
- package/src/formats/rdrr/types.d.ts +5 -3
- package/src/formats/rdrr/validation.js +15 -1
- package/src/gpu/command-recorder.d.ts +43 -3
- package/src/gpu/command-recorder.js +122 -25
- package/src/gpu/device.js +111 -11
- package/src/gpu/kernel-tuner/cache.js +1 -5
- package/src/gpu/kernels/attention.js +17 -9
- package/src/gpu/kernels/attention_decode_online_head256_f16kv.wgsl +236 -0
- package/src/gpu/kernels/attention_streaming_f16.wgsl +7 -5
- package/src/gpu/kernels/backward/cross_entropy_backward.js +72 -3
- package/src/gpu/kernels/backward/cross_entropy_backward.wgsl +2 -2
- package/src/gpu/kernels/cast.js +74 -67
- package/src/gpu/kernels/codegen/patches/attention_streaming_f16.from.attention_streaming.diff +46 -1
- package/src/gpu/kernels/codegen/patches/gelu_f16.from.gelu.diff +0 -20
- package/src/gpu/kernels/codegen/patches/residual_f16.from.residual.diff +15 -12
- package/src/gpu/kernels/codegen/patches/rmsnorm_f16.from.rmsnorm.diff +59 -44
- package/src/gpu/kernels/diffusion-gemma-sampling.d.ts +19 -0
- package/src/gpu/kernels/diffusion-gemma-sampling.js +104 -0
- package/src/gpu/kernels/diffusion_gemma_sampling.wgsl +130 -0
- package/src/gpu/kernels/dispatch.js +13 -3
- package/src/gpu/kernels/fused_ffn.js +3 -4
- package/src/gpu/kernels/fused_matmul_litert_int4_f16a.wgsl +78 -0
- package/src/gpu/kernels/fused_matmul_litert_int4_f16a_f32out.wgsl +78 -0
- package/src/gpu/kernels/fused_matmul_litert_int4_f32a_f32out.wgsl +76 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +101 -80
- package/src/gpu/kernels/fused_matmul_w4a16_batched_f16a.wgsl +116 -0
- package/src/gpu/kernels/fused_matmul_w4a16_batched_f16a_f32out.wgsl +116 -0
- package/src/gpu/kernels/fused_matmul_w4a16_f16a.wgsl +95 -0
- package/src/gpu/kernels/fused_matmul_w4a16_f16a_f32out.wgsl +95 -0
- package/src/gpu/kernels/gather.d.ts +84 -1
- package/src/gpu/kernels/gather.js +353 -5
- package/src/gpu/kernels/gather_litert_int4_vec4_f16_out.wgsl +75 -0
- package/src/gpu/kernels/gather_litert_int4_vec4_f32_out.wgsl +72 -0
- package/src/gpu/kernels/gather_split4_f16_vec4_f16_out.wgsl +103 -0
- package/src/gpu/kernels/gather_split8_f16_vec4_f16_out.wgsl +143 -0
- package/src/gpu/kernels/gather_split8_f16_vec4_f32_out.wgsl +143 -0
- package/src/gpu/kernels/gelu.wgsl +11 -7
- package/src/gpu/kernels/gelu_f16.wgsl +11 -7
- package/src/gpu/kernels/gemma4-route-expert.d.ts +35 -0
- package/src/gpu/kernels/gemma4-route-expert.js +126 -0
- package/src/gpu/kernels/gemma4_route_q4_matmul_f16a.wgsl +210 -0
- package/src/gpu/kernels/index.d.ts +71 -0
- package/src/gpu/kernels/index.js +52 -0
- package/src/gpu/kernels/kv-cache-write.d.ts +22 -0
- package/src/gpu/kernels/kv-cache-write.js +126 -0
- package/src/gpu/kernels/kv_cache_write_f32_to_f16.wgsl +32 -0
- package/src/gpu/kernels/lm-head-argmax.d.ts +19 -0
- package/src/gpu/kernels/lm-head-argmax.js +218 -0
- package/src/gpu/kernels/lm_head_argmax_f16.wgsl +189 -0
- package/src/gpu/kernels/matmul-dispatch.d.ts +11 -0
- package/src/gpu/kernels/matmul-dispatch.js +37 -1
- package/src/gpu/kernels/matmul-selection.d.ts +5 -5
- package/src/gpu/kernels/matmul-selection.js +104 -9
- package/src/gpu/kernels/matmul.d.ts +1 -1
- package/src/gpu/kernels/matmul.js +151 -43
- package/src/gpu/kernels/moe.d.ts +1 -0
- package/src/gpu/kernels/moe.js +46 -18
- package/src/gpu/kernels/pipeline-cache.d.ts +8 -0
- package/src/gpu/kernels/pipeline-cache.js +24 -0
- package/src/gpu/kernels/rep-penalty.d.ts +21 -0
- package/src/gpu/kernels/rep-penalty.js +17 -9
- package/src/gpu/kernels/residual.d.ts +1 -0
- package/src/gpu/kernels/residual.js +13 -1
- package/src/gpu/kernels/residual.wgsl +3 -3
- package/src/gpu/kernels/residual_f16.wgsl +5 -3
- package/src/gpu/kernels/residual_f16_vec4.wgsl +6 -6
- package/src/gpu/kernels/residual_vec4.wgsl +6 -6
- package/src/gpu/kernels/rmsnorm-pair.d.ts +39 -0
- package/src/gpu/kernels/rmsnorm-pair.js +152 -0
- package/src/gpu/kernels/rmsnorm-qk.d.ts +41 -0
- package/src/gpu/kernels/rmsnorm-qk.js +128 -0
- package/src/gpu/kernels/rmsnorm.d.ts +31 -0
- package/src/gpu/kernels/rmsnorm.js +32 -7
- package/src/gpu/kernels/rmsnorm.wgsl +10 -6
- package/src/gpu/kernels/rmsnorm_f16.wgsl +7 -3
- package/src/gpu/kernels/rmsnorm_pair.wgsl +224 -0
- package/src/gpu/kernels/rmsnorm_qk.wgsl +118 -0
- package/src/gpu/kernels/rmsnorm_qk_f16.wgsl +143 -0
- package/src/gpu/kernels/rope-qk.d.ts +41 -0
- package/src/gpu/kernels/rope-qk.js +143 -0
- package/src/gpu/kernels/rope_qk.wgsl +95 -0
- package/src/gpu/kernels/rope_qk_f16.wgsl +97 -0
- package/src/gpu/kernels/rule-registry.js +50 -10
- package/src/gpu/kernels/sample.js +212 -187
- package/src/gpu/kernels/scatter_add_dynamic_expert_scale.wgsl +47 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16_expert_scale.wgsl +49 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16_weights_expert_scale.wgsl +49 -0
- package/src/gpu/kernels/scatter_add_routes_f16_weights_expert_scale.wgsl +45 -0
- package/src/gpu/kernels/shader-cache.js +1 -21
- package/src/gpu/kernels/soft-embedding.d.ts +28 -0
- package/src/gpu/kernels/soft-embedding.js +447 -0
- package/src/gpu/kernels/soft_embedding_logits_f16.wgsl +107 -0
- package/src/gpu/kernels/soft_embedding_split_f16.wgsl +46 -0
- package/src/gpu/kernels/softmax.wgsl +5 -80
- package/src/gpu/kernels/split-qkv-rmsnorm-qk.d.ts +44 -0
- package/src/gpu/kernels/split-qkv-rmsnorm-qk.js +154 -0
- package/src/gpu/kernels/split-qkv-rmsnorm-rope-qk.d.ts +59 -0
- package/src/gpu/kernels/split-qkv-rmsnorm-rope-qk.js +245 -0
- package/src/gpu/kernels/split_qkv_rmsnorm_qk.wgsl +146 -0
- package/src/gpu/kernels/split_qkv_rmsnorm_rope_qk.wgsl +185 -0
- package/src/gpu/kernels/split_qkv_rmsnorm_rope_qk_f16kv_cache.wgsl +187 -0
- package/src/gpu/kernels/uniform-utils.js +2 -5
- package/src/gpu/kernels/utils.d.ts +16 -1
- package/src/gpu/kernels/utils.js +42 -13
- package/src/gpu/readback-utils.js +10 -2
- package/src/gpu/uniform-cache.d.ts +10 -1
- package/src/gpu/uniform-cache.js +25 -7
- package/src/gpu/weight-buffer.d.ts +76 -7
- package/src/gpu/weight-buffer.js +85 -1
- package/src/inference/browser-harness-diffusion-energy-suites.js +269 -1
- package/src/inference/browser-harness-suite-helpers.d.ts +9 -0
- package/src/inference/browser-harness-suite-helpers.js +438 -2
- package/src/inference/browser-harness-text-helpers.d.ts +77 -0
- package/src/inference/browser-harness-text-helpers.js +236 -11
- package/src/inference/browser-harness.d.ts +8 -0
- package/src/inference/browser-harness.js +292 -8
- package/src/inference/decode-ring.d.ts +1 -0
- package/src/inference/decode-ring.js +7 -5
- package/src/inference/kv-cache/base.d.ts +25 -0
- package/src/inference/kv-cache/base.js +109 -1
- package/src/inference/kv-cache/mixed-geometry.d.ts +10 -0
- package/src/inference/kv-cache/mixed-geometry.js +109 -2
- package/src/inference/kv-cache/sliding-window.d.ts +14 -0
- package/src/inference/kv-cache/sliding-window.js +88 -0
- package/src/inference/model-lanes/execution-lane-resolver.d.ts +61 -0
- package/src/inference/model-lanes/execution-lane-resolver.js +126 -0
- package/src/inference/moe-router.d.ts +14 -1
- package/src/inference/moe-router.js +24 -1
- package/src/inference/pipelines/audio/gemma4.js +52 -1
- package/src/inference/pipelines/diffusion-gemma/config.d.ts +27 -0
- package/src/inference/pipelines/diffusion-gemma/config.js +149 -0
- package/src/inference/pipelines/diffusion-gemma/index.d.ts +31 -0
- package/src/inference/pipelines/diffusion-gemma/index.js +12 -0
- package/src/inference/pipelines/diffusion-gemma/pipeline.d.ts +69 -0
- package/src/inference/pipelines/diffusion-gemma/pipeline.js +380 -0
- package/src/inference/pipelines/diffusion-gemma/sampling.d.ts +128 -0
- package/src/inference/pipelines/diffusion-gemma/sampling.js +395 -0
- package/src/inference/pipelines/text/attention/dispatch-params.d.ts +28 -4
- package/src/inference/pipelines/text/attention/dispatch-params.js +176 -2
- package/src/inference/pipelines/text/attention/projections.d.ts +71 -2
- package/src/inference/pipelines/text/attention/projections.js +329 -49
- package/src/inference/pipelines/text/attention/quant-options.d.ts +38 -0
- package/src/inference/pipelines/text/attention/record.js +446 -73
- package/src/inference/pipelines/text/attention/run.js +251 -49
- package/src/inference/pipelines/text/attention/types.d.ts +5 -1
- package/src/inference/pipelines/text/config.d.ts +22 -1
- package/src/inference/pipelines/text/config.js +199 -22
- package/src/inference/pipelines/text/dtype-contract.d.ts +1 -1
- package/src/inference/pipelines/text/dtype-contract.js +4 -1
- package/src/inference/pipelines/text/embed.d.ts +4 -3
- package/src/inference/pipelines/text/embed.js +16 -6
- package/src/inference/pipelines/text/execution-plan.d.ts +8 -0
- package/src/inference/pipelines/text/execution-plan.js +6 -0
- package/src/inference/pipelines/text/execution-runtime-builders.d.ts +4 -0
- package/src/inference/pipelines/text/execution-runtime-builders.js +44 -28
- package/src/inference/pipelines/text/execution-v1.d.ts +2 -0
- package/src/inference/pipelines/text/execution-v1.js +373 -139
- package/src/inference/pipelines/text/ffn/dense.js +44 -13
- package/src/inference/pipelines/text/ffn/moe.d.ts +4 -1
- package/src/inference/pipelines/text/ffn/moe.js +9 -2
- package/src/inference/pipelines/text/ffn/sandwich.d.ts +3 -1
- package/src/inference/pipelines/text/ffn/sandwich.js +237 -15
- package/src/inference/pipelines/text/ffn/standard.d.ts +3 -1
- package/src/inference/pipelines/text/ffn/standard.js +44 -4
- package/src/inference/pipelines/text/generator-decode-policy.d.ts +81 -0
- package/src/inference/pipelines/text/generator-decode-policy.js +2 -12
- package/src/inference/pipelines/text/generator-helpers.js +5 -2
- package/src/inference/pipelines/text/generator-prefill-helpers.d.ts +84 -0
- package/src/inference/pipelines/text/generator-prefill-helpers.js +67 -1
- package/src/inference/pipelines/text/generator-runtime.d.ts +1 -0
- package/src/inference/pipelines/text/generator-steps.d.ts +38 -3
- package/src/inference/pipelines/text/generator-steps.js +268 -77
- package/src/inference/pipelines/text/generator.d.ts +39 -0
- package/src/inference/pipelines/text/generator.js +1105 -18
- package/src/inference/pipelines/text/init.d.ts +8 -1
- package/src/inference/pipelines/text/init.js +30 -1
- package/src/inference/pipelines/text/layer-plan-gpu.js +62 -14
- package/src/inference/pipelines/text/layer.js +272 -25
- package/src/inference/pipelines/text/linear-attention.js +6 -4
- package/src/inference/pipelines/text/logits/gpu.d.ts +49 -2
- package/src/inference/pipelines/text/logits/gpu.js +417 -66
- package/src/inference/pipelines/text/logits/index.d.ts +2 -2
- package/src/inference/pipelines/text/logits/index.js +96 -42
- package/src/inference/pipelines/text/logits/types.d.ts +2 -2
- package/src/inference/pipelines/text/lora-apply.js +17 -0
- package/src/inference/pipelines/text/model-load.js +5 -1
- package/src/inference/pipelines/text/moe-gpu.d.ts +13 -0
- package/src/inference/pipelines/text/moe-gpu.js +445 -16
- package/src/inference/pipelines/text/moe-impl.d.ts +13 -3
- package/src/inference/pipelines/text/moe-shape-validator.js +13 -1
- package/src/inference/pipelines/text/ops.d.ts +29 -2
- package/src/inference/pipelines/text/ops.js +19 -0
- package/src/inference/pipelines/text/per-layer-inputs.js +5 -0
- package/src/inference/pipelines/text/probes.js +4 -5
- package/src/inference/pipelines/text/sampling-config.d.ts +4 -10
- package/src/inference/pipelines/text/sampling-config.js +103 -64
- package/src/inference/pipelines/text/sampling.js +13 -9
- package/src/inference/pipelines/text/state.js +17 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.d.ts +57 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.js +8 -9
- package/src/inference/pipelines/text/types.d.ts +84 -3
- package/src/inference/pipelines/text/weights.d.ts +4 -2
- package/src/inference/pipelines/text/weights.js +4 -5
- package/src/inference/pipelines/text.d.ts +24 -0
- package/src/inference/pipelines/text.js +162 -38
- package/src/inference/pipelines/vision/gemma4.js +20 -9
- package/src/inference/tokenizer.d.ts +30 -0
- package/src/inference/tokenizer.js +340 -164
- package/src/inference/tokenizers/bundled.js +71 -49
- package/src/loader/doppler-loader.d.ts +11 -0
- package/src/loader/doppler-loader.js +290 -15
- package/src/loader/embedding-limit-preflight.d.ts +31 -0
- package/src/loader/embedding-limit-preflight.js +216 -0
- package/src/loader/embedding-loader.d.ts +8 -2
- package/src/loader/embedding-loader.js +263 -8
- package/src/loader/experts/expert-loader.d.ts +4 -1
- package/src/loader/experts/expert-loader.js +174 -5
- package/src/loader/final-weights-loader.d.ts +5 -0
- package/src/loader/final-weights-loader.js +167 -4
- package/src/loader/layer-loader.d.ts +2 -0
- package/src/loader/layer-loader.js +74 -6
- package/src/loader/loader-types.d.ts +59 -2
- package/src/loader/manifest-config.d.ts +8 -0
- package/src/loader/shard-resolver.js +37 -4
- package/src/loader/tensors/functional-descriptor-loader.d.ts +9 -0
- package/src/loader/tensors/functional-descriptor-loader.js +377 -0
- package/src/loader/tensors/tensor-loader.d.ts +36 -1
- package/src/loader/tensors/tensor-loader.js +437 -21
- package/src/loader/tensors/tensor-reader.d.ts +4 -1
- package/src/loader/tensors/tensor-reader.js +11 -4
- package/src/loader/weights.d.ts +3 -1
- package/src/memory/buffer-pool.js +12 -9
- package/src/models/diffusiongemma.d.ts +7 -0
- package/src/models/diffusiongemma.js +25 -0
- package/src/models/gemma4.js +24 -0
- package/src/models/qwen3.js +2 -2
- package/src/rules/execution-rules-contract-check.js +93 -10
- package/src/rules/inference/capability-transforms.rules.json +26 -2
- package/src/rules/inference/config.rules.json +1 -0
- package/src/rules/inference/dtype.rules.json +7 -0
- package/src/rules/inference/execution.rules.json +108 -17
- package/src/rules/inference/ffn.rules.json +18 -0
- package/src/rules/kernels/gather.rules.json +81 -0
- package/src/rules/kernels/matmul.rules.json +19 -0
- package/src/rules/kernels/moe.rules.json +3 -0
- package/src/rules/kernels/rep-penalty.rules.json +6 -0
- package/src/rules/kernels/rmsnorm-qk.rules.json +6 -0
- package/src/rules/kernels/rmsnorm.rules.json +42 -7
- package/src/rules/kernels/rope-qk.rules.json +6 -0
- package/src/rules/loader/tensor-loader.rules.json +8 -0
- package/src/rules/rule-registry.js +6 -0
- package/src/storage/artifact-storage-context.d.ts +1 -0
- package/src/storage/artifact-storage-context.js +10 -0
- package/src/tooling/browser-command-runner.d.ts +0 -3
- package/src/tooling/browser-command-runner.js +2 -14
- package/src/tooling/command-api-family-normalizers.js +4 -2
- package/src/tooling/command-api-helpers.js +2 -1
- package/src/tooling/command-api.d.ts +2 -0
- package/src/tooling/command-api.js +1 -0
- package/src/tooling/command-runner-shared.d.ts +4 -0
- package/src/tooling/command-runner-shared.js +2 -1
- package/src/tooling/diagnose-runner.js +2 -0
- package/src/tooling/litert-package-runtime.js +553 -16
- package/src/tooling/node-browser-command-runner.js +10 -4
- package/src/tooling/node-command-runner.js +7 -2
- package/src/tooling/node-convert-worker-pool.js +3 -0
- package/src/tooling/node-convert-worker.js +1 -0
- package/src/tooling/node-converter.js +12 -0
- package/src/tooling/node-webgpu.d.ts +1 -0
- package/src/tooling/node-webgpu.js +23 -11
- package/src/tooling/program-bundle.d.ts +52 -1
- package/src/tooling/rdrr-integrity-refresh.d.ts +18 -0
- package/src/tooling/source-artifact-adapter.js +7 -2
- package/src/tooling/source-package-profiles.d.ts +18 -1
- package/src/tooling/source-package-profiles.js +109 -1
- package/src/tooling/source-runtime-bundle.d.ts +1 -0
- package/src/tooling/source-runtime-bundle.js +27 -0
- package/src/tooling/source-runtime-converter-config.js +12 -3
- package/src/tooling-experimental-exports.shared.d.ts +10 -0
- package/src/tooling-experimental-exports.shared.js +10 -0
- package/src/version.js +1 -1
|
@@ -8,6 +8,25 @@ export type TrainingEvalKind =
|
|
|
8
8
|
| 'retrieval'
|
|
9
9
|
| 'custom';
|
|
10
10
|
|
|
11
|
+
export type TrainingAgentEvalCategory =
|
|
12
|
+
| 'js_patching'
|
|
13
|
+
| 'wgsl_review'
|
|
14
|
+
| 'manifest_config_review'
|
|
15
|
+
| 'reploid_vfs_status_tool_loop'
|
|
16
|
+
| 'patch_applies'
|
|
17
|
+
| 'no_hallucinated_files_tools';
|
|
18
|
+
|
|
19
|
+
export interface TrainingAgentEvalConfig {
|
|
20
|
+
suiteId: string;
|
|
21
|
+
categories: TrainingAgentEvalCategory[];
|
|
22
|
+
minPassRate: number;
|
|
23
|
+
requirePatchApplies: boolean;
|
|
24
|
+
requireNoHallucinatedFiles: boolean;
|
|
25
|
+
requireNoHallucinatedTools: boolean;
|
|
26
|
+
allowedFiles: string[];
|
|
27
|
+
allowedTools: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
11
30
|
export interface TrainingEvalDataset {
|
|
12
31
|
id: string;
|
|
13
32
|
datasetPath: string;
|
|
@@ -18,6 +37,13 @@ export interface TrainingEvalDataset {
|
|
|
18
37
|
stopOnEos: boolean;
|
|
19
38
|
} | null;
|
|
20
39
|
scoreboardColumns: string[];
|
|
40
|
+
quality: {
|
|
41
|
+
baseline: string;
|
|
42
|
+
requireImprovement: boolean;
|
|
43
|
+
minAbsoluteImprovement: number;
|
|
44
|
+
minRelativeImprovement: number;
|
|
45
|
+
} | null;
|
|
46
|
+
agentEval: TrainingAgentEvalConfig | null;
|
|
21
47
|
sourceLangs: string[] | null;
|
|
22
48
|
targetLangs: string[] | null;
|
|
23
49
|
pairAllowlist: string[] | null;
|
|
@@ -59,6 +85,10 @@ export interface TrainingWorkloadTrainingConfig {
|
|
|
59
85
|
export interface LoRAWorkloadPipelineConfig {
|
|
60
86
|
datasetFormat: string;
|
|
61
87
|
taskType: string;
|
|
88
|
+
baseModelRef: string | null;
|
|
89
|
+
maxLength: number | null;
|
|
90
|
+
sequenceLength: number | null;
|
|
91
|
+
joinWith: string | null;
|
|
62
92
|
adapter: {
|
|
63
93
|
rank: number;
|
|
64
94
|
alpha: number;
|
|
@@ -85,6 +115,11 @@ export interface LoRAWorkloadPipelineConfig {
|
|
|
85
115
|
autoActivate: boolean;
|
|
86
116
|
smokePrompt: string | null;
|
|
87
117
|
} | null;
|
|
118
|
+
trainer: {
|
|
119
|
+
modulePath: string;
|
|
120
|
+
exportName: string;
|
|
121
|
+
runnerId: string | null;
|
|
122
|
+
} | null;
|
|
88
123
|
}
|
|
89
124
|
|
|
90
125
|
export interface DistillStagePlanEntry {
|
|
@@ -110,6 +145,7 @@ export interface DistillWorkloadPipelineConfig {
|
|
|
110
145
|
pairAllowlist: string[] | null;
|
|
111
146
|
strictPairContract: boolean;
|
|
112
147
|
subsetSpec: Record<string, unknown> | null;
|
|
148
|
+
sftLora: LoRAWorkloadPipelineConfig | null;
|
|
113
149
|
}
|
|
114
150
|
|
|
115
151
|
export interface TrainingWorkloadPack {
|
|
@@ -148,6 +184,7 @@ export declare const TRAINING_WORKLOAD_KINDS: readonly TrainingWorkloadKind[];
|
|
|
148
184
|
export declare const TRAINING_WORKLOAD_SURFACE_SUPPORT: readonly TrainingSurfaceSupport[];
|
|
149
185
|
export declare const TRAINING_SELECTION_GOALS: readonly TrainingSelectionGoal[];
|
|
150
186
|
export declare const TRAINING_EVAL_KINDS: readonly TrainingEvalKind[];
|
|
187
|
+
export declare const TRAINING_AGENT_EVAL_CATEGORIES: readonly TrainingAgentEvalCategory[];
|
|
151
188
|
|
|
152
189
|
export declare function normalizeTrainingWorkloadPack(
|
|
153
190
|
payload: Record<string, unknown>,
|
|
@@ -22,6 +22,15 @@ export const TRAINING_EVAL_KINDS = Object.freeze([
|
|
|
22
22
|
'custom',
|
|
23
23
|
]);
|
|
24
24
|
|
|
25
|
+
export const TRAINING_AGENT_EVAL_CATEGORIES = Object.freeze([
|
|
26
|
+
'js_patching',
|
|
27
|
+
'wgsl_review',
|
|
28
|
+
'manifest_config_review',
|
|
29
|
+
'reploid_vfs_status_tool_loop',
|
|
30
|
+
'patch_applies',
|
|
31
|
+
'no_hallucinated_files_tools',
|
|
32
|
+
]);
|
|
33
|
+
|
|
25
34
|
const LEGACY_DISTILL_TEST_IDS = Object.freeze(['distill-stage-a', 'distill-stage-b']);
|
|
26
35
|
|
|
27
36
|
function stableSortObject(value) {
|
|
@@ -58,6 +67,17 @@ function asNonEmptyString(value, label, options = {}) {
|
|
|
58
67
|
return trimmed;
|
|
59
68
|
}
|
|
60
69
|
|
|
70
|
+
function asStringValue(value, label, options = {}) {
|
|
71
|
+
if (value === undefined || value === null) {
|
|
72
|
+
if (options.optional === true) return null;
|
|
73
|
+
throw new Error(`${label} is required.`);
|
|
74
|
+
}
|
|
75
|
+
if (typeof value !== 'string') {
|
|
76
|
+
throw new Error(`${label} must be a string.`);
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
|
|
61
81
|
function asPositiveInteger(value, label, options = {}) {
|
|
62
82
|
if (value === undefined || value === null || value === '') {
|
|
63
83
|
if (options.optional === true) return null;
|
|
@@ -94,6 +114,15 @@ function asFiniteNumber(value, label, options = {}) {
|
|
|
94
114
|
return parsed;
|
|
95
115
|
}
|
|
96
116
|
|
|
117
|
+
function asUnitInterval(value, label, options = {}) {
|
|
118
|
+
const parsed = asFiniteNumber(value, label, options);
|
|
119
|
+
if (parsed === null) return null;
|
|
120
|
+
if (parsed < 0 || parsed > 1) {
|
|
121
|
+
throw new Error(`${label} must be between 0 and 1.`);
|
|
122
|
+
}
|
|
123
|
+
return parsed;
|
|
124
|
+
}
|
|
125
|
+
|
|
97
126
|
function asBoolean(value, label, options = {}) {
|
|
98
127
|
if (value === undefined || value === null) {
|
|
99
128
|
if (options.optional === true) return null;
|
|
@@ -236,6 +265,8 @@ function normalizeEvalDatasets(value, label) {
|
|
|
236
265
|
`${label}[${index}].scoreboardColumns`,
|
|
237
266
|
{ optional: true, allowEmpty: true }
|
|
238
267
|
) ?? [],
|
|
268
|
+
quality: normalizeEvalQualityConfig(dataset.quality, `${label}[${index}].quality`),
|
|
269
|
+
agentEval: normalizeAgentEvalConfig(dataset.agentEval, `${label}[${index}].agentEval`),
|
|
239
270
|
sourceLangs: asStringArray(dataset.sourceLangs, `${label}[${index}].sourceLangs`, { optional: true, allowEmpty: true }),
|
|
240
271
|
targetLangs: asStringArray(dataset.targetLangs, `${label}[${index}].targetLangs`, { optional: true, allowEmpty: true }),
|
|
241
272
|
pairAllowlist: asStringArray(dataset.pairAllowlist, `${label}[${index}].pairAllowlist`, { optional: true, allowEmpty: true }),
|
|
@@ -243,6 +274,50 @@ function normalizeEvalDatasets(value, label) {
|
|
|
243
274
|
});
|
|
244
275
|
}
|
|
245
276
|
|
|
277
|
+
function normalizeAgentEvalConfig(value, label) {
|
|
278
|
+
const config = asObject(value, label, { optional: true });
|
|
279
|
+
if (!config) return null;
|
|
280
|
+
const categories = asStringArray(config.categories, `${label}.categories`);
|
|
281
|
+
for (const category of categories) {
|
|
282
|
+
if (!TRAINING_AGENT_EVAL_CATEGORIES.includes(category)) {
|
|
283
|
+
throw new Error(`${label}.categories contains unsupported category "${category}".`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
suiteId: asNonEmptyString(config.suiteId, `${label}.suiteId`),
|
|
288
|
+
categories,
|
|
289
|
+
minPassRate: asUnitInterval(config.minPassRate, `${label}.minPassRate`),
|
|
290
|
+
requirePatchApplies: asBoolean(config.requirePatchApplies, `${label}.requirePatchApplies`),
|
|
291
|
+
requireNoHallucinatedFiles: asBoolean(
|
|
292
|
+
config.requireNoHallucinatedFiles,
|
|
293
|
+
`${label}.requireNoHallucinatedFiles`
|
|
294
|
+
),
|
|
295
|
+
requireNoHallucinatedTools: asBoolean(
|
|
296
|
+
config.requireNoHallucinatedTools,
|
|
297
|
+
`${label}.requireNoHallucinatedTools`
|
|
298
|
+
),
|
|
299
|
+
allowedFiles: asStringArray(config.allowedFiles, `${label}.allowedFiles`, { allowEmpty: true }),
|
|
300
|
+
allowedTools: asStringArray(config.allowedTools, `${label}.allowedTools`, { allowEmpty: true }),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function normalizeEvalQualityConfig(value, label) {
|
|
305
|
+
const quality = asObject(value, label, { optional: true });
|
|
306
|
+
if (!quality) return null;
|
|
307
|
+
return {
|
|
308
|
+
baseline: asNonEmptyString(quality.baseline ?? 'base_model', `${label}.baseline`),
|
|
309
|
+
requireImprovement: asBoolean(quality.requireImprovement ?? false, `${label}.requireImprovement`),
|
|
310
|
+
minAbsoluteImprovement: asFiniteNumber(
|
|
311
|
+
quality.minAbsoluteImprovement ?? 0,
|
|
312
|
+
`${label}.minAbsoluteImprovement`
|
|
313
|
+
),
|
|
314
|
+
minRelativeImprovement: asFiniteNumber(
|
|
315
|
+
quality.minRelativeImprovement ?? 0,
|
|
316
|
+
`${label}.minRelativeImprovement`
|
|
317
|
+
),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
246
321
|
function normalizeFreezeConfig(value, label) {
|
|
247
322
|
const freeze = asObject(value, label, { optional: true }) || {};
|
|
248
323
|
return {
|
|
@@ -254,6 +329,19 @@ function normalizeFreezeConfig(value, label) {
|
|
|
254
329
|
};
|
|
255
330
|
}
|
|
256
331
|
|
|
332
|
+
function normalizeLoraTrainerConfig(value, label) {
|
|
333
|
+
const trainer = asObject(value, label, { optional: true });
|
|
334
|
+
if (!trainer) return null;
|
|
335
|
+
return {
|
|
336
|
+
modulePath: asNonEmptyString(trainer.modulePath ?? trainer.path, `${label}.modulePath`),
|
|
337
|
+
exportName: asNonEmptyString(
|
|
338
|
+
trainer.exportName ?? 'trainCausalLmLora',
|
|
339
|
+
`${label}.exportName`
|
|
340
|
+
),
|
|
341
|
+
runnerId: asNonEmptyString(trainer.runnerId, `${label}.runnerId`, { optional: true }),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
257
345
|
function normalizeStagePlan(value, label) {
|
|
258
346
|
if (!Array.isArray(value) || value.length === 0) {
|
|
259
347
|
throw new Error(`${label} must be a non-empty array.`);
|
|
@@ -285,6 +373,12 @@ function normalizeStagePlan(value, label) {
|
|
|
285
373
|
});
|
|
286
374
|
}
|
|
287
375
|
|
|
376
|
+
function isSftStageEntry(stage) {
|
|
377
|
+
const trainingStage = String(stage?.trainingStage || '').trim().toLowerCase().replace(/[\s-]+/g, '_');
|
|
378
|
+
const objective = String(stage?.objective || '').trim().toLowerCase().replace(/[\s-]+/g, '_');
|
|
379
|
+
return trainingStage === 'sft' || objective === 'sft';
|
|
380
|
+
}
|
|
381
|
+
|
|
288
382
|
function normalizeLoraConfig(value, label) {
|
|
289
383
|
const lora = asObject(value, label);
|
|
290
384
|
const adapter = asObject(lora.adapter, `${label}.adapter`);
|
|
@@ -299,6 +393,10 @@ function normalizeLoraConfig(value, label) {
|
|
|
299
393
|
return {
|
|
300
394
|
datasetFormat: asNonEmptyString(lora.datasetFormat, `${label}.datasetFormat`),
|
|
301
395
|
taskType: asNonEmptyString(lora.taskType, `${label}.taskType`),
|
|
396
|
+
baseModelRef: asNonEmptyString(lora.baseModelRef, `${label}.baseModelRef`, { optional: true }),
|
|
397
|
+
maxLength: asPositiveInteger(lora.maxLength, `${label}.maxLength`, { optional: true }),
|
|
398
|
+
sequenceLength: asPositiveInteger(lora.sequenceLength, `${label}.sequenceLength`, { optional: true }),
|
|
399
|
+
joinWith: asStringValue(lora.joinWith, `${label}.joinWith`, { optional: true }),
|
|
302
400
|
adapter: {
|
|
303
401
|
rank: asPositiveInteger(adapter.rank, `${label}.adapter.rank`),
|
|
304
402
|
alpha: asFiniteNumber(adapter.alpha, `${label}.adapter.alpha`),
|
|
@@ -323,9 +421,15 @@ function normalizeLoraConfig(value, label) {
|
|
|
323
421
|
smokePrompt: asNonEmptyString(activation.smokePrompt, `${label}.activation.smokePrompt`, { optional: true }),
|
|
324
422
|
}
|
|
325
423
|
: null,
|
|
424
|
+
trainer: normalizeLoraTrainerConfig(lora.trainer, `${label}.trainer`),
|
|
326
425
|
};
|
|
327
426
|
}
|
|
328
427
|
|
|
428
|
+
function normalizeDistillSftLoraConfig(value, label) {
|
|
429
|
+
if (value === undefined || value === null) return null;
|
|
430
|
+
return normalizeLoraConfig(value, label);
|
|
431
|
+
}
|
|
432
|
+
|
|
329
433
|
function normalizeDistillConfig(value, label) {
|
|
330
434
|
const distill = asObject(value, label);
|
|
331
435
|
return {
|
|
@@ -340,6 +444,7 @@ function normalizeDistillConfig(value, label) {
|
|
|
340
444
|
pairAllowlist: asStringArray(distill.pairAllowlist, `${label}.pairAllowlist`, { optional: true, allowEmpty: true }),
|
|
341
445
|
strictPairContract: asBoolean(distill.strictPairContract, `${label}.strictPairContract`),
|
|
342
446
|
subsetSpec: asObject(distill.subsetSpec, `${label}.subsetSpec`, { optional: true }),
|
|
447
|
+
sftLora: normalizeDistillSftLoraConfig(distill.sftLora, `${label}.sftLora`),
|
|
343
448
|
};
|
|
344
449
|
}
|
|
345
450
|
|
|
@@ -462,13 +567,17 @@ export function normalizeTrainingWorkloadPack(payload, context = {}) {
|
|
|
462
567
|
workload.pipeline = normalizeLoraConfig(payload.lora ?? payload.pipeline, `${contextLabel}.lora`);
|
|
463
568
|
} else if (kind === 'distill') {
|
|
464
569
|
workload.pipeline = normalizeDistillConfig(payload.distill ?? payload.pipeline, `${contextLabel}.distill`);
|
|
465
|
-
const
|
|
570
|
+
const hasSftStage = workload.pipeline.stagePlan.some((stage) => isSftStageEntry(stage));
|
|
571
|
+
const stageRequiresTeacher = workload.pipeline.stagePlan.some((stage) => !isSftStageEntry(stage));
|
|
466
572
|
if (stageRequiresTeacher && !workload.teacherModelId) {
|
|
467
573
|
throw new Error(`${contextLabel}.teacherModelId is required when stagePlan includes non-SFT stages.`);
|
|
468
574
|
}
|
|
469
575
|
if (!workload.studentModelId) {
|
|
470
576
|
throw new Error(`${contextLabel}.studentModelId is required for distill workloads.`);
|
|
471
577
|
}
|
|
578
|
+
if (hasSftStage && !workload.pipeline.sftLora) {
|
|
579
|
+
throw new Error(`${contextLabel}.distill.sftLora is required when stagePlan includes SFT stages.`);
|
|
580
|
+
}
|
|
472
581
|
}
|
|
473
582
|
|
|
474
583
|
return withHashes(workload);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export interface FunctionalDescriptorProofGate {
|
|
2
|
+
sensitivity?: string;
|
|
3
|
+
compression?: string;
|
|
4
|
+
determinism?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface FunctionalDescriptorManifest {
|
|
8
|
+
schema_version: 'manifoldgguf.v0.1';
|
|
9
|
+
tensor_name?: string;
|
|
10
|
+
source_shape?: [number, number];
|
|
11
|
+
slice_shape: [number, number];
|
|
12
|
+
crop_shape?: [number, number];
|
|
13
|
+
padded_shape?: [number, number];
|
|
14
|
+
tile_shape?: [number, number];
|
|
15
|
+
padding?: {
|
|
16
|
+
rows?: number;
|
|
17
|
+
cols?: number;
|
|
18
|
+
};
|
|
19
|
+
storage_type: 'functional_descriptor';
|
|
20
|
+
descriptor_hash?: string;
|
|
21
|
+
descriptor_bytes?: number;
|
|
22
|
+
dense_f16_bytes?: number;
|
|
23
|
+
compression_ratio?: number;
|
|
24
|
+
proof_status?: string;
|
|
25
|
+
proof_status_gate?: FunctionalDescriptorProofGate;
|
|
26
|
+
components: {
|
|
27
|
+
prng_substrate: {
|
|
28
|
+
algorithm: 'coord_hash_normal_v1';
|
|
29
|
+
seed: number;
|
|
30
|
+
learned_scale: number;
|
|
31
|
+
learned_scale_frozen?: boolean;
|
|
32
|
+
};
|
|
33
|
+
kronecker_sum: {
|
|
34
|
+
shard_file: string;
|
|
35
|
+
shard_hash?: string;
|
|
36
|
+
rank_terms?: number;
|
|
37
|
+
factor_shapes?: unknown[];
|
|
38
|
+
};
|
|
39
|
+
coordinate_inr: {
|
|
40
|
+
shard_file: string;
|
|
41
|
+
shard_hash?: string;
|
|
42
|
+
type: 'siren';
|
|
43
|
+
network_dims?: number[];
|
|
44
|
+
omega_0?: number;
|
|
45
|
+
};
|
|
46
|
+
sparse_outliers: {
|
|
47
|
+
shard_file: string;
|
|
48
|
+
shard_hash?: string;
|
|
49
|
+
format?: 'coo_v1';
|
|
50
|
+
value_dtype?: string;
|
|
51
|
+
actual_nnz?: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FunctionalDescriptorValidationResult {
|
|
57
|
+
valid: boolean;
|
|
58
|
+
errors: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare function isFunctionalDescriptorDtype(dtype: unknown): boolean;
|
|
62
|
+
|
|
63
|
+
export declare function getFunctionalDescriptorManifest(info: unknown): FunctionalDescriptorManifest | Record<string, unknown> | null;
|
|
64
|
+
|
|
65
|
+
export declare function validateFunctionalDescriptorManifest(
|
|
66
|
+
value: unknown,
|
|
67
|
+
label?: string
|
|
68
|
+
): FunctionalDescriptorValidationResult;
|
|
69
|
+
|
|
70
|
+
export declare function assertFunctionalDescriptorManifest(
|
|
71
|
+
value: unknown,
|
|
72
|
+
label?: string
|
|
73
|
+
): FunctionalDescriptorManifest;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
const DESCRIPTOR_SCHEMA_VERSION = 'manifoldgguf.v0.1';
|
|
2
|
+
const DESCRIPTOR_STORAGE_TYPE = 'functional_descriptor';
|
|
3
|
+
const DESCRIPTOR_PRNG_ALGORITHM = 'coord_hash_normal_v1';
|
|
4
|
+
const DESCRIPTOR_COORDINATE_INR_TYPE = 'siren';
|
|
5
|
+
const DESCRIPTOR_SPARSE_FORMAT = 'coo_v1';
|
|
6
|
+
|
|
7
|
+
function isPlainObject(value) {
|
|
8
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function isPositiveInteger(value) {
|
|
12
|
+
return Number.isInteger(value) && value > 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isNonNegativeInteger(value) {
|
|
16
|
+
return Number.isInteger(value) && value >= 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function validateShape2(errors, value, label) {
|
|
20
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
21
|
+
errors.push(`${label} must be [rows, cols]`);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const rows = Number(value[0]);
|
|
25
|
+
const cols = Number(value[1]);
|
|
26
|
+
if (!isPositiveInteger(rows) || !isPositiveInteger(cols)) {
|
|
27
|
+
errors.push(`${label} must contain positive integers`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return [rows, cols];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function validateOptionalShape2(errors, manifest, field, label) {
|
|
34
|
+
if (manifest[field] === undefined) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return validateShape2(errors, manifest[field], `${label}.${field}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function validateOptionalNonNegativeInteger(errors, object, field, label) {
|
|
41
|
+
if (object[field] === undefined) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!isNonNegativeInteger(Number(object[field]))) {
|
|
45
|
+
errors.push(`${label}.${field} must be a non-negative integer`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function validateOptionalPositiveInteger(errors, object, field, label) {
|
|
50
|
+
if (object[field] === undefined) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!isPositiveInteger(Number(object[field]))) {
|
|
54
|
+
errors.push(`${label}.${field} must be a positive integer`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function validateOptionalFiniteNumber(errors, object, field, label) {
|
|
59
|
+
if (object[field] === undefined) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!Number.isFinite(Number(object[field]))) {
|
|
63
|
+
errors.push(`${label}.${field} must be a finite number`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function validateOptionalSha256(errors, object, field, label) {
|
|
68
|
+
if (object[field] === undefined) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (typeof object[field] !== 'string' || !/^sha256:[a-f0-9]{64}$/i.test(object[field].trim())) {
|
|
72
|
+
errors.push(`${label}.${field} must be sha256:<64 hex chars>`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validateShardFile(errors, component, fieldLabel) {
|
|
77
|
+
if (!isPlainObject(component)) {
|
|
78
|
+
errors.push(`${fieldLabel} must be an object`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (typeof component.shard_file !== 'string' || component.shard_file.trim().length === 0) {
|
|
82
|
+
errors.push(`${fieldLabel}.shard_file must be a non-empty string`);
|
|
83
|
+
}
|
|
84
|
+
validateOptionalSha256(errors, component, 'shard_hash', fieldLabel);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function validateProofGate(errors, manifest, label) {
|
|
88
|
+
if (manifest.proof_status !== undefined) {
|
|
89
|
+
if (typeof manifest.proof_status !== 'string' || manifest.proof_status.trim().length === 0) {
|
|
90
|
+
errors.push(`${label}.proof_status must be a non-empty string when present`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (manifest.proof_status_gate === undefined) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!isPlainObject(manifest.proof_status_gate)) {
|
|
97
|
+
errors.push(`${label}.proof_status_gate must be an object`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const field of ['sensitivity', 'compression', 'determinism']) {
|
|
101
|
+
const value = manifest.proof_status_gate[field];
|
|
102
|
+
if (value === undefined) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
106
|
+
errors.push(`${label}.proof_status_gate.${field} must be a non-empty string when present`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function isFunctionalDescriptorDtype(dtype) {
|
|
112
|
+
return String(dtype || '').trim().toUpperCase() === 'FUNCTIONAL_DESCRIPTOR';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function getFunctionalDescriptorManifest(info) {
|
|
116
|
+
return info?.descriptorManifest
|
|
117
|
+
?? info?.descriptor_manifest
|
|
118
|
+
?? info?.functionalDescriptor
|
|
119
|
+
?? info?.functional_descriptor
|
|
120
|
+
?? null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function validateFunctionalDescriptorManifest(value, label = 'descriptorManifest') {
|
|
124
|
+
const errors = [];
|
|
125
|
+
if (!isPlainObject(value)) {
|
|
126
|
+
return {
|
|
127
|
+
valid: false,
|
|
128
|
+
errors: [`${label} must be an object`],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (value.schema_version !== DESCRIPTOR_SCHEMA_VERSION) {
|
|
133
|
+
errors.push(`${label}.schema_version must be "${DESCRIPTOR_SCHEMA_VERSION}"`);
|
|
134
|
+
}
|
|
135
|
+
if (value.storage_type !== DESCRIPTOR_STORAGE_TYPE) {
|
|
136
|
+
errors.push(`${label}.storage_type must be "${DESCRIPTOR_STORAGE_TYPE}"`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const sliceShape = validateShape2(errors, value.slice_shape, `${label}.slice_shape`);
|
|
140
|
+
const cropShape = validateOptionalShape2(errors, value, 'crop_shape', label);
|
|
141
|
+
const paddedShape = validateOptionalShape2(errors, value, 'padded_shape', label);
|
|
142
|
+
validateOptionalShape2(errors, value, 'source_shape', label);
|
|
143
|
+
validateOptionalShape2(errors, value, 'tile_shape', label);
|
|
144
|
+
|
|
145
|
+
const runtimeShape = paddedShape ?? sliceShape;
|
|
146
|
+
const effectiveCropShape = cropShape ?? sliceShape;
|
|
147
|
+
if (runtimeShape && effectiveCropShape) {
|
|
148
|
+
if (effectiveCropShape[0] > runtimeShape[0] || effectiveCropShape[1] > runtimeShape[1]) {
|
|
149
|
+
errors.push(`${label}.crop_shape must not exceed reconstruction shape`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (isPlainObject(value.padding)) {
|
|
154
|
+
validateOptionalNonNegativeInteger(errors, value.padding, 'rows', `${label}.padding`);
|
|
155
|
+
validateOptionalNonNegativeInteger(errors, value.padding, 'cols', `${label}.padding`);
|
|
156
|
+
} else if (value.padding !== undefined) {
|
|
157
|
+
errors.push(`${label}.padding must be an object`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
validateOptionalSha256(errors, value, 'descriptor_hash', label);
|
|
161
|
+
validateOptionalPositiveInteger(errors, value, 'descriptor_bytes', label);
|
|
162
|
+
validateOptionalPositiveInteger(errors, value, 'dense_f16_bytes', label);
|
|
163
|
+
validateOptionalFiniteNumber(errors, value, 'compression_ratio', label);
|
|
164
|
+
validateProofGate(errors, value, label);
|
|
165
|
+
|
|
166
|
+
const components = value.components;
|
|
167
|
+
if (!isPlainObject(components)) {
|
|
168
|
+
errors.push(`${label}.components must be an object`);
|
|
169
|
+
return { valid: errors.length === 0, errors };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const prng = components.prng_substrate;
|
|
173
|
+
if (!isPlainObject(prng)) {
|
|
174
|
+
errors.push(`${label}.components.prng_substrate must be an object`);
|
|
175
|
+
} else {
|
|
176
|
+
if (prng.algorithm !== DESCRIPTOR_PRNG_ALGORITHM) {
|
|
177
|
+
errors.push(`${label}.components.prng_substrate.algorithm must be "${DESCRIPTOR_PRNG_ALGORITHM}"`);
|
|
178
|
+
}
|
|
179
|
+
if (!Number.isInteger(Number(prng.seed))) {
|
|
180
|
+
errors.push(`${label}.components.prng_substrate.seed must be an integer`);
|
|
181
|
+
}
|
|
182
|
+
if (!Number.isFinite(Number(prng.learned_scale))) {
|
|
183
|
+
errors.push(`${label}.components.prng_substrate.learned_scale must be a finite number`);
|
|
184
|
+
}
|
|
185
|
+
if (prng.learned_scale_frozen !== undefined && typeof prng.learned_scale_frozen !== 'boolean') {
|
|
186
|
+
errors.push(`${label}.components.prng_substrate.learned_scale_frozen must be boolean when present`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
validateShardFile(errors, components.kronecker_sum, `${label}.components.kronecker_sum`);
|
|
191
|
+
if (isPlainObject(components.kronecker_sum)) {
|
|
192
|
+
validateOptionalPositiveInteger(errors, components.kronecker_sum, 'rank_terms', `${label}.components.kronecker_sum`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
validateShardFile(errors, components.coordinate_inr, `${label}.components.coordinate_inr`);
|
|
196
|
+
if (isPlainObject(components.coordinate_inr)) {
|
|
197
|
+
if (components.coordinate_inr.type !== DESCRIPTOR_COORDINATE_INR_TYPE) {
|
|
198
|
+
errors.push(`${label}.components.coordinate_inr.type must be "${DESCRIPTOR_COORDINATE_INR_TYPE}"`);
|
|
199
|
+
}
|
|
200
|
+
if (components.coordinate_inr.network_dims !== undefined) {
|
|
201
|
+
if (!Array.isArray(components.coordinate_inr.network_dims) ||
|
|
202
|
+
components.coordinate_inr.network_dims.some((dim) => !isPositiveInteger(Number(dim)))) {
|
|
203
|
+
errors.push(`${label}.components.coordinate_inr.network_dims must contain positive integers`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
validateOptionalFiniteNumber(errors, components.coordinate_inr, 'omega_0', `${label}.components.coordinate_inr`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
validateShardFile(errors, components.sparse_outliers, `${label}.components.sparse_outliers`);
|
|
210
|
+
if (isPlainObject(components.sparse_outliers)) {
|
|
211
|
+
if (components.sparse_outliers.format !== undefined &&
|
|
212
|
+
components.sparse_outliers.format !== DESCRIPTOR_SPARSE_FORMAT) {
|
|
213
|
+
errors.push(`${label}.components.sparse_outliers.format must be "${DESCRIPTOR_SPARSE_FORMAT}"`);
|
|
214
|
+
}
|
|
215
|
+
validateOptionalNonNegativeInteger(errors, components.sparse_outliers, 'actual_nnz', `${label}.components.sparse_outliers`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
valid: errors.length === 0,
|
|
220
|
+
errors,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function assertFunctionalDescriptorManifest(value, label = 'descriptorManifest') {
|
|
225
|
+
const validation = validateFunctionalDescriptorManifest(value, label);
|
|
226
|
+
if (!validation.valid) {
|
|
227
|
+
throw new Error(`Invalid ${label}:\n - ${validation.errors.join('\n - ')}`);
|
|
228
|
+
}
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
import { validateManifest } from './validation.js';
|
|
4
4
|
import { RDRR_VERSION } from './types.js';
|
|
5
5
|
import { normalizeTensorStorageDescriptor } from './storage-descriptor.js';
|
|
6
|
+
import {
|
|
7
|
+
assertFunctionalDescriptorManifest,
|
|
8
|
+
getFunctionalDescriptorManifest,
|
|
9
|
+
isFunctionalDescriptorDtype,
|
|
10
|
+
} from './functional-descriptor.js';
|
|
11
|
+
import { log } from '../../debug/index.js';
|
|
6
12
|
|
|
7
13
|
const KNOWN_MANIFEST_VERSIONS = new Set([RDRR_VERSION]);
|
|
8
14
|
|
|
@@ -36,7 +42,8 @@ export function parseManifest(jsonString) {
|
|
|
36
42
|
? parseFloat(manifest.version)
|
|
37
43
|
: manifest.version;
|
|
38
44
|
if (typeof parsedVersion === 'number' && !KNOWN_MANIFEST_VERSIONS.has(parsedVersion)) {
|
|
39
|
-
|
|
45
|
+
log.warn(
|
|
46
|
+
'RDRR',
|
|
40
47
|
`[RDRR] Unknown manifest version ${manifest.version} ` +
|
|
41
48
|
`(known: ${[...KNOWN_MANIFEST_VERSIONS].join(', ')}). ` +
|
|
42
49
|
'Parsing will continue but results may be unreliable.'
|
|
@@ -77,16 +84,17 @@ export function parseTensorMap(jsonString) {
|
|
|
77
84
|
const normalizedTensorMap = {};
|
|
78
85
|
|
|
79
86
|
for (const [name, loc] of Object.entries(tensorMap)) {
|
|
87
|
+
const isFunctionalDescriptor = isFunctionalDescriptorDtype(loc?.dtype);
|
|
80
88
|
const shardIndex = typeof loc.shardIndex === 'number'
|
|
81
89
|
? loc.shardIndex
|
|
82
90
|
: loc.shard;
|
|
83
|
-
if (typeof shardIndex !== 'number') {
|
|
91
|
+
if (!isFunctionalDescriptor && typeof shardIndex !== 'number') {
|
|
84
92
|
throw new Error(`Tensor '${name}' missing shard index`);
|
|
85
93
|
}
|
|
86
|
-
if (typeof loc.offset !== 'number') {
|
|
94
|
+
if (!isFunctionalDescriptor && typeof loc.offset !== 'number') {
|
|
87
95
|
throw new Error(`Tensor '${name}' missing offset`);
|
|
88
96
|
}
|
|
89
|
-
if (typeof loc.size !== 'number') {
|
|
97
|
+
if (!isFunctionalDescriptor && typeof loc.size !== 'number') {
|
|
90
98
|
throw new Error(`Tensor '${name}' missing size`);
|
|
91
99
|
}
|
|
92
100
|
if (!Array.isArray(loc.shape)) {
|
|
@@ -95,6 +103,12 @@ export function parseTensorMap(jsonString) {
|
|
|
95
103
|
if (typeof loc.role !== 'string') {
|
|
96
104
|
throw new Error(`Tensor '${name}' missing role`);
|
|
97
105
|
}
|
|
106
|
+
const descriptorManifest = isFunctionalDescriptor
|
|
107
|
+
? assertFunctionalDescriptorManifest(
|
|
108
|
+
getFunctionalDescriptorManifest(loc),
|
|
109
|
+
`Tensor '${name}' descriptorManifest`
|
|
110
|
+
)
|
|
111
|
+
: null;
|
|
98
112
|
|
|
99
113
|
let spans = undefined;
|
|
100
114
|
if (loc.spans !== undefined) {
|
|
@@ -124,9 +138,11 @@ export function parseTensorMap(jsonString) {
|
|
|
124
138
|
|
|
125
139
|
normalizedTensorMap[name] = {
|
|
126
140
|
...loc,
|
|
127
|
-
shard: shardIndex,
|
|
128
|
-
|
|
141
|
+
...(typeof shardIndex === 'number' ? { shard: shardIndex, shardIndex } : {}),
|
|
142
|
+
...(typeof loc.offset === 'number' ? { offset: loc.offset } : {}),
|
|
143
|
+
...(typeof loc.size === 'number' ? { size: loc.size } : { size: 0 }),
|
|
129
144
|
spans,
|
|
145
|
+
...(descriptorManifest ? { descriptorManifest } : {}),
|
|
130
146
|
...(loc.storage === undefined
|
|
131
147
|
? {}
|
|
132
148
|
: { storage: normalizeTensorStorageDescriptor(loc.storage, `tensor "${name}"`) }),
|
|
@@ -224,7 +224,7 @@ export function normalizeTensorSourceTransform(location, tensorName, options = {
|
|
|
224
224
|
`Tensor "${tensorName}" has unsupported sourceTransform.scheme "${transform.scheme}".`
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
const normalized = {
|
|
228
228
|
kind,
|
|
229
229
|
scheme: transform.scheme,
|
|
230
230
|
sourceDtype,
|
|
@@ -232,6 +232,15 @@ export function normalizeTensorSourceTransform(location, tensorName, options = {
|
|
|
232
232
|
scale: normalizePositiveNumber(transform.scale, tensorName, errorPrefix, 'sourceTransform.scale'),
|
|
233
233
|
zeroPoint: normalizeSafeInteger(transform.zeroPoint, tensorName, errorPrefix, 'sourceTransform.zeroPoint'),
|
|
234
234
|
};
|
|
235
|
+
if (transform.storageEncoding != null) {
|
|
236
|
+
normalized.storageEncoding = normalizeStorageEncoding(
|
|
237
|
+
transform.storageEncoding,
|
|
238
|
+
tensorName,
|
|
239
|
+
errorPrefix,
|
|
240
|
+
'sourceTransform.storageEncoding'
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return normalized;
|
|
235
244
|
}
|
|
236
245
|
|
|
237
246
|
if (kind === 'litert_rowwise_dequant') {
|