doppler-gpu 0.4.2 → 0.4.4
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 +210 -0
- package/README.md +63 -38
- package/assets/doppler.svg +57 -1601
- package/package.json +111 -32
- package/src/cli/cli-model-resolution.js +275 -0
- package/src/cli/cli-output.js +486 -0
- package/src/cli/doppler-cli.d.ts +18 -0
- package/src/cli/doppler-cli.js +885 -744
- package/src/cli/doppler-quickstart.d.ts +7 -23
- package/src/cli/doppler-quickstart.js +4 -2
- package/src/cli/doppler-serve.d.ts +210 -0
- package/src/cli/doppler-serve.js +469 -43
- package/src/cli/runtime-profiles.d.ts +40 -0
- package/src/cli/runtime-profiles.js +225 -0
- package/src/client/doppler-api.js +1 -6
- package/src/client/doppler-registry.d.ts +12 -0
- package/src/client/doppler-registry.js +27 -0
- package/src/client/doppler-registry.json +66 -10
- package/src/client/failure-taxonomy.js +139 -0
- package/src/client/fault-injection.js +30 -0
- package/src/client/provider.d.ts +151 -0
- package/src/client/provider.js +374 -0
- package/src/client/receipt.js +156 -0
- package/src/client/runtime/index.js +69 -4
- package/src/client/runtime/lora.d.ts +11 -1
- package/src/client/runtime/lora.js +28 -7
- package/src/client/runtime/model-manager.d.ts +0 -14
- package/src/client/runtime/model-manager.js +34 -50
- package/src/client/runtime/model-session.d.ts +2 -1
- package/src/client/runtime/model-session.js +35 -2
- package/src/client/runtime/model-source.d.ts +13 -1
- package/src/client/runtime/model-source.js +148 -3
- package/src/client/runtime/node-quickstart-cache.d.ts +22 -0
- package/src/client/runtime/node-quickstart-cache.js +353 -0
- package/src/client/runtime/source-runtime.js +1 -10
- package/src/client/runtime/types.d.ts +8 -60
- package/src/client/wrap-pipeline-handle.d.ts +82 -0
- package/src/client/wrap-pipeline-handle.js +259 -0
- package/src/config/README.md +3 -1
- package/src/config/conversion/README.md +28 -157
- 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 +21 -6
- package/src/config/conversion/gemma3/gemma-3-1b-it-f16-af32.json +19 -12
- package/src/config/conversion/gemma3/gemma-3-1b-it-q4k-ehf16-af32.json +27 -12
- 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 +39 -16
- package/src/config/conversion/gemma3/translategemma-4b-1b-enes-q4k-ehf16-af32.json +19 -12
- package/src/config/conversion/gemma3/translategemma-4b-it-q4k-ehf16-af32.json +27 -12
- 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 +719 -0
- package/src/config/conversion/gemma4/gemma-4-31b-it-text-q4k-ehf16-af32.json +715 -0
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af16-int4ple.json +591 -0
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32-int4ple.json +566 -0
- package/src/config/conversion/gemma4/gemma-4-e2b-it-q4k-ehf16-af32.json +367 -61
- package/src/config/conversion/gemma4/gemma-4-moe-q4k-ehf16-af32.json +212 -55
- package/src/config/conversion/gpt-oss-20b-f16-xmxfp4.json +216 -57
- package/src/config/conversion/janus/janus-pro-1b-text-q4k-ehaf16.json +229 -57
- package/src/config/conversion/lfm2/lfm2.5-1.2b-instruct-q4k-ehf16-af32.json +19 -12
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +82 -36
- package/src/config/conversion/qwen3/qwen-3-5-2b-q4k-ehaf16.json +96 -60
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-eaf16.json +521 -0
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-ehaf16.json +515 -0
- package/src/config/execution-contract-check.js +6 -5
- package/src/config/goal-completion-matrix.json +552 -0
- package/src/config/kernel-path-loader.d.ts +8 -2
- package/src/config/kernel-path-loader.js +192 -38
- package/src/config/kernels/kernel-ref-digests.js +163 -126
- package/src/config/kernels/registry.d.ts +0 -35
- package/src/config/kernels/registry.js +5 -9
- package/src/config/kernels/registry.json +3593 -1146
- package/src/config/merge-contract-check.js +7 -3
- package/src/config/merge-helpers.d.ts +3 -1
- package/src/config/merge-helpers.js +2 -1
- package/src/config/merge.d.ts +1 -0
- package/src/config/merge.js +65 -7
- 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-categories.d.ts +0 -9
- package/src/config/param-categories.js +1 -5
- package/src/config/param-validator.d.ts +2 -0
- package/src/config/param-validator.js +20 -0
- package/src/config/platforms/loader.d.ts +0 -27
- package/src/config/platforms/loader.js +0 -30
- package/src/config/required-inference-fields-contract-check.js +1 -7
- package/src/config/runtime/README.md +28 -0
- package/src/config/runtime/experiments/bench/gemma4-bench-q4k.json +1 -1
- package/src/config/runtime/experiments/bench/qwen3-bench-q4k-batched.json +2 -2
- package/src/config/runtime/experiments/debug/gemma4-e2b-browser-diagnose-q4k.json +85 -0
- package/src/config/runtime/experiments/verify/lfm2-verify.json +3 -3
- package/src/config/runtime/platform/metal-apple-q4k.json +19 -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/runtime/profiles/gemma4-31b-f16-activations-probe.json +65 -0
- package/src/config/runtime/profiles/gemma4-e2b-baseline-probe.json +41 -0
- package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-probe.json +44 -0
- package/src/config/runtime/profiles/gemma4-e2b-fused-rmsnorm-test.json +19 -0
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-baseline-probe.json +31 -0
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-f16a-probe.json +34 -0
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-reference-export.json +64 -0
- package/src/config/runtime/profiles/gemma4-e2b-int4ple-retain-q4k-probe.json +47 -0
- package/src/config/runtime/profiles/gemma4-e2b-prefill-profile.json +35 -0
- package/src/config/runtime/profiles/gemma4-e2b-throughput-probe.json +16 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-prefill-profile.json +35 -0
- package/src/config/runtime/profiles/qwen-3-5-0-8b-throughput-probe.json +16 -0
- package/src/config/runtime/profiles/qwen3-6-27b-f16-activations-probe.json +62 -0
- package/src/config/schema/bridge.schema.d.ts +16 -0
- package/src/config/schema/browser-suite-metrics.schema.d.ts +1 -0
- package/src/config/schema/browser-suite-metrics.schema.js +2 -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 +16 -0
- package/src/config/schema/converter.schema.js +11 -0
- package/src/config/schema/debug.schema.d.ts +22 -1
- package/src/config/schema/debug.schema.js +1 -0
- package/src/config/schema/distill-training.schema.d.ts +0 -1
- package/src/config/schema/distill-training.schema.js +1 -1
- package/src/config/schema/doppler.schema.d.ts +13 -2
- package/src/config/schema/doppler.schema.js +140 -8
- package/src/config/schema/emulation.schema.d.ts +3 -0
- package/src/config/schema/emulation.schema.js +16 -16
- package/src/config/schema/execution-v1.schema.d.ts +39 -1
- package/src/config/schema/execution-v1.schema.js +35 -20
- package/src/config/schema/goal-completion-matrix.schema.json +223 -0
- package/src/config/schema/index.d.ts +52 -1
- package/src/config/schema/index.js +14 -0
- package/src/config/schema/inference.schema.d.ts +14 -3
- package/src/config/schema/kernel-path.schema.d.ts +6 -27
- package/src/config/schema/kernel-thresholds.schema.d.ts +0 -2
- package/src/config/schema/kernel-thresholds.schema.js +3 -7
- package/src/config/schema/kvcache.schema.js +0 -9
- package/src/config/schema/loading.schema.d.ts +12 -0
- package/src/config/schema/loading.schema.js +4 -0
- package/src/config/schema/manifest.schema.d.ts +175 -2
- package/src/config/schema/manifest.schema.js +58 -3
- 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 -9
- package/src/config/schema/policy-schema-registry.json +26 -0
- package/src/config/schema/program-bundle.schema.d.ts +233 -0
- package/src/config/schema/program-bundle.schema.js +393 -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/schema/ul-training.schema.d.ts +0 -1
- package/src/config/schema/ul-training.schema.js +1 -1
- package/src/config/source-packages/litert/gemma-4-12b-it.json +390 -0
- package/src/config/source-packages/litert/gemma-4-e2b-it.json +41 -20
- 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.d.ts +14 -0
- package/src/config/supported-operations.js +34 -0
- package/src/config/supported-operations.json +183 -0
- package/src/config/training-defaults.js +1 -7
- package/src/config/transforms/capability-transform-resolver.d.ts +13 -2
- package/src/config/transforms/capability-transform-resolver.js +3 -1
- package/src/config/transforms/execution-graph-transforms.d.ts +97 -0
- package/src/config/transforms/execution-graph-transforms.js +829 -168
- package/src/converter/conversion-plan.d.ts +2 -0
- package/src/converter/conversion-plan.js +31 -14
- package/src/converter/core.d.ts +65 -0
- package/src/converter/core.js +1153 -22
- package/src/converter/parsers/diffusion.js +1 -33
- package/src/converter/quantization-info.d.ts +5 -4
- package/src/converter/quantization-info.js +218 -5
- package/src/converter/quantizer.d.ts +24 -4
- package/src/converter/quantizer.js +92 -2
- package/src/debug/config.d.ts +0 -4
- package/src/debug/config.js +0 -17
- package/src/debug/index.d.ts +28 -30
- package/src/debug/index.js +0 -18
- package/src/debug/stats.d.ts +0 -8
- package/src/debug/stats.js +3 -3
- package/src/debug/tensor.d.ts +9 -2
- package/src/debug/tensor.js +11 -4
- package/src/debug/trace.js +2 -15
- package/src/errors/doppler-error.js +20 -0
- package/src/experimental/adapters/lora-loader.js +109 -24
- package/src/experimental/browser/quantization.d.ts +5 -0
- 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/distribution/shard-delivery.js +179 -23
- package/src/experimental/training/README.md +11 -0
- package/src/experimental/training/artifacts.js +1 -14
- package/src/experimental/training/autograd.js +33 -8
- package/src/experimental/training/checkpoint.js +1 -14
- 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/datasets/token-batch.d.ts +1 -1
- package/src/experimental/training/datasets/token-batch.js +2 -2
- package/src/experimental/training/distillation/dataset.js +2 -15
- package/src/experimental/training/distillation/eval.js +3 -3
- package/src/experimental/training/distillation/runtime.js +3 -16
- package/src/experimental/training/distillation/student-fixture.d.ts +5 -0
- package/src/experimental/training/distillation/student-fixture.js +296 -38
- 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 +1733 -58
- package/src/experimental/training/lora.js +23 -1
- package/src/experimental/training/loss.js +1 -1
- package/src/experimental/training/objectives/base.d.ts +2 -2
- package/src/experimental/training/objectives/cross_entropy.d.ts +2 -2
- package/src/experimental/training/objectives/distill_kd.d.ts +2 -2
- package/src/experimental/training/objectives/distill_kd.js +2 -2
- package/src/experimental/training/objectives/distill_triplet.d.ts +2 -2
- package/src/experimental/training/objectives/distill_triplet.js +2 -2
- package/src/experimental/training/objectives/ul_stage1_joint.d.ts +2 -2
- package/src/experimental/training/objectives/ul_stage2_base.d.ts +2 -2
- package/src/experimental/training/objectives/ul_stage2_base.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-artifacts.js +1 -14
- package/src/experimental/training/operator-command.js +310 -51
- package/src/experimental/training/runner.d.ts +1 -0
- package/src/experimental/training/runner.js +5 -14
- 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 +192 -12
- package/src/experimental/training/workloads.d.ts +37 -0
- package/src/experimental/training/workloads.js +111 -2
- package/src/formats/gguf/types.d.ts +0 -63
- package/src/formats/gguf/types.js +58 -38
- package/src/formats/litert/types.d.ts +0 -13
- package/src/formats/litert/types.js +2 -2
- package/src/formats/rdrr/distributed/index.d.ts +34 -0
- package/src/formats/rdrr/distributed/index.js +3 -0
- package/src/formats/rdrr/distributed/parsing.d.ts +6 -0
- package/src/formats/rdrr/distributed/parsing.js +23 -0
- package/src/formats/rdrr/distributed/validation.d.ts +23 -0
- package/src/formats/rdrr/distributed/validation.js +131 -0
- package/src/formats/rdrr/functional-descriptor.d.ts +73 -0
- package/src/formats/rdrr/functional-descriptor.js +230 -0
- package/src/formats/rdrr/groups.d.ts +1 -13
- package/src/formats/rdrr/groups.js +0 -34
- package/src/formats/rdrr/index.d.ts +10 -0
- package/src/formats/rdrr/index.js +10 -0
- package/src/formats/rdrr/integrity.d.ts +51 -0
- package/src/formats/rdrr/integrity.js +200 -0
- package/src/formats/rdrr/lowerings.d.ts +28 -0
- package/src/formats/rdrr/lowerings.js +112 -0
- package/src/formats/rdrr/manifest.d.ts +0 -14
- package/src/formats/rdrr/manifest.js +5 -58
- package/src/formats/rdrr/merkle.d.ts +24 -0
- package/src/formats/rdrr/merkle.js +118 -0
- package/src/formats/rdrr/parsing.js +26 -6
- package/src/formats/rdrr/slice-compiler.d.ts +29 -0
- package/src/formats/rdrr/slice-compiler.js +188 -0
- package/src/formats/rdrr/source-transform-contract.js +10 -1
- package/src/formats/rdrr/storage-descriptor.d.ts +36 -0
- package/src/formats/rdrr/storage-descriptor.js +193 -0
- package/src/formats/rdrr/tensor-config-validator.d.ts +0 -9
- package/src/formats/rdrr/tensor-config-validator.js +0 -30
- package/src/formats/rdrr/types.d.ts +111 -2
- package/src/formats/rdrr/validation.js +260 -1
- package/src/formats/tflite/types.d.ts +0 -31
- package/src/formats/tflite/types.js +5 -5
- package/src/gpu/command-recorder.d.ts +45 -23
- package/src/gpu/command-recorder.js +122 -25
- package/src/gpu/device.d.ts +17 -3
- package/src/gpu/device.js +130 -14
- package/src/gpu/kernel-runtime.d.ts +8 -15
- package/src/gpu/kernel-selection-log.d.ts +0 -8
- package/src/gpu/kernel-selection-log.js +0 -15
- package/src/gpu/kernel-tuner/cache.js +1 -8
- package/src/gpu/kernels/README.md +50 -18
- package/src/gpu/kernels/activation_static_qdq.wgsl +3 -1
- package/src/gpu/kernels/attention.d.ts +28 -19
- package/src/gpu/kernels/attention.js +458 -16
- package/src/gpu/kernels/attention_decode_contiguous_turboquant_f16kv.wgsl +0 -1
- package/src/gpu/kernels/attention_decode_contiguous_turboquant_prod_f16kv.wgsl +0 -1
- package/src/gpu/kernels/attention_decode_f16.wgsl +1 -1
- package/src/gpu/kernels/attention_decode_f16kv.wgsl +1 -1
- package/src/gpu/kernels/attention_decode_online_f16.wgsl +32 -29
- package/src/gpu/kernels/attention_decode_online_f16kv.wgsl +1 -1
- package/src/gpu/kernels/attention_decode_online_head256_f16kv.wgsl +236 -0
- package/src/gpu/kernels/attention_decode_paged_f16kv.wgsl +1 -1
- package/src/gpu/kernels/attention_decode_tiered_f16kv.wgsl +1 -1
- package/src/gpu/kernels/attention_decode_tiered_turboquant_f16kv.wgsl +0 -1
- package/src/gpu/kernels/attention_decode_tiered_turboquant_prod_f16kv.wgsl +0 -1
- package/src/gpu/kernels/attention_f16.wgsl +88 -30
- package/src/gpu/kernels/attention_f16kv.wgsl +45 -15
- package/src/gpu/kernels/attention_head512_f16.wgsl +270 -0
- package/src/gpu/kernels/attention_head512_f16kv.wgsl +271 -0
- package/src/gpu/kernels/attention_prefill_flash_head256_f16kv.wgsl +306 -0
- package/src/gpu/kernels/attention_prefill_flash_reduce.wgsl +101 -0
- package/src/gpu/kernels/attention_small_f16.wgsl +22 -20
- package/src/gpu/kernels/attention_small_f16kv.wgsl +1 -1
- package/src/gpu/kernels/attention_streaming_f16.wgsl +34 -9
- package/src/gpu/kernels/attention_streaming_f16kv.wgsl +22 -3
- 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/backward/index.d.ts +6 -0
- package/src/gpu/kernels/backward/layernorm_backward.wgsl +0 -1
- package/src/gpu/kernels/backward/utils.d.ts +35 -0
- package/src/gpu/kernels/bf16_to_f32.wgsl +0 -16
- package/src/gpu/kernels/bias_add_f16.wgsl +1 -1
- package/src/gpu/kernels/cast.js +74 -67
- package/src/gpu/kernels/cast_f32_to_f16.wgsl +0 -1
- package/src/gpu/kernels/codegen/patches/attention_f16.from.attention.diff +19 -215
- package/src/gpu/kernels/codegen/patches/attention_f16kv.from.attention.diff +8 -82
- package/src/gpu/kernels/codegen/patches/attention_small_f16.from.attention_small.diff +92 -59
- package/src/gpu/kernels/codegen/patches/attention_streaming_f16.from.attention_streaming.diff +12 -50
- package/src/gpu/kernels/codegen/patches/gelu_f16.from.gelu.diff +16 -33
- package/src/gpu/kernels/codegen/patches/residual_f16.from.residual.diff +15 -12
- package/src/gpu/kernels/codegen/patches/rmsnorm_f16.from.rmsnorm.diff +255 -170
- package/src/gpu/kernels/codegen/patches/rope_f16.from.rope.diff +133 -235
- package/src/gpu/kernels/codegen/patches/sample_f16.from.sample.diff +119 -90
- package/src/gpu/kernels/codegen/wgsl-variants.js +142 -8
- package/src/gpu/kernels/constants.d.ts +9 -48
- package/src/gpu/kernels/constants.js +0 -23
- package/src/gpu/kernels/conv2d.d.ts +0 -4
- package/src/gpu/kernels/conv2d_f16.wgsl +1 -1
- package/src/gpu/kernels/dequant.d.ts +0 -16
- package/src/gpu/kernels/dequant.js +1 -71
- package/src/gpu/kernels/dequant_mxfp4_expert_f16.wgsl +1 -1
- package/src/gpu/kernels/dequant_shared.wgsl +1 -55
- 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.d.ts +12 -97
- package/src/gpu/kernels/dispatch.js +13 -120
- package/src/gpu/kernels/energy_eval_f16.wgsl +1 -1
- package/src/gpu/kernels/energy_quintel_grad_f16.wgsl +1 -1
- package/src/gpu/kernels/energy_quintel_reduce_f16.wgsl +1 -1
- package/src/gpu/kernels/energy_quintel_update_f16.wgsl +1 -1
- package/src/gpu/kernels/energy_update_f16.wgsl +1 -1
- package/src/gpu/kernels/fused-gate-up-gelu.js +121 -0
- package/src/gpu/kernels/fused_ffn.js +3 -4
- package/src/gpu/kernels/fused_ffn_f16.wgsl +1 -1
- package/src/gpu/kernels/fused_ffn_q4k.wgsl +0 -19
- package/src/gpu/kernels/fused_ffn_q4k_f16.wgsl +0 -18
- package/src/gpu/kernels/fused_gate_up_gelu_gated_f16.wgsl +124 -0
- 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_q4.wgsl +23 -439
- package/src/gpu/kernels/fused_matmul_q4_batched_f16.wgsl +1 -1
- package/src/gpu/kernels/fused_matmul_q4_batched_f16a.wgsl +0 -1
- package/src/gpu/kernels/fused_matmul_q4_batched_f16acc_f16a.wgsl +158 -0
- package/src/gpu/kernels/fused_matmul_q4_f16a.wgsl +0 -1
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16.wgsl +0 -1
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16a.wgsl +32 -33
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16a_f32acc.wgsl +209 -0
- package/src/gpu/kernels/fused_matmul_q4_prefill_tiled_f16.wgsl +261 -0
- package/src/gpu/kernels/fused_matmul_q4_widetile.wgsl +164 -0
- package/src/gpu/kernels/fused_matmul_q4_widetile_f16.wgsl +198 -0
- package/src/gpu/kernels/fused_matmul_q4_widetile_f16a.wgsl +161 -0
- package/src/gpu/kernels/fused_matmul_q4_widetile_residual.wgsl +173 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +101 -80
- package/src/gpu/kernels/fused_matmul_rmsnorm_f16.wgsl +1 -1
- 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/fused_rmsnorm_q4_widetile.wgsl +271 -0
- package/src/gpu/kernels/fused_swiglu_f16.wgsl +1 -1
- package/src/gpu/kernels/gather.d.ts +84 -8
- package/src/gpu/kernels/gather.js +353 -5
- package/src/gpu/kernels/gather_f16.wgsl +1 -1
- 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 +25 -22
- 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/groupnorm.d.ts +0 -4
- package/src/gpu/kernels/groupnorm_apply_f16.wgsl +1 -1
- package/src/gpu/kernels/groupnorm_stats_f16.wgsl +1 -1
- package/src/gpu/kernels/index.d.ts +77 -5
- package/src/gpu/kernels/index.js +55 -4
- 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/kv_quantize_turboquant.wgsl +0 -2
- package/src/gpu/kernels/kv_quantize_turboquant_prod.wgsl +0 -2
- package/src/gpu/kernels/layernorm.d.ts +0 -4
- package/src/gpu/kernels/layernorm_f16.wgsl +1 -1
- package/src/gpu/kernels/{sana_linear_attention.d.ts → linear_attention.d.ts} +5 -5
- package/src/gpu/kernels/{sana_linear_attention.js → linear_attention.js} +16 -16
- 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/logit-merge.d.ts +0 -24
- package/src/gpu/kernels/logit-merge.js +1 -17
- package/src/gpu/kernels/matmul-dispatch.d.ts +11 -0
- package/src/gpu/kernels/matmul-dispatch.js +44 -2
- package/src/gpu/kernels/matmul-selection.d.ts +5 -5
- package/src/gpu/kernels/matmul-selection.js +172 -10
- package/src/gpu/kernels/matmul.d.ts +1 -29
- package/src/gpu/kernels/matmul.js +240 -38
- package/src/gpu/kernels/matmul_f16_tiled.wgsl +33 -34
- package/src/gpu/kernels/matmul_gemv_residual_f16.wgsl +1 -1
- package/src/gpu/kernels/matmul_gemv_subgroup.wgsl +0 -1
- package/src/gpu/kernels/matmul_gemv_subgroup_f16a.wgsl +24 -25
- package/src/gpu/kernels/modulate_f16.wgsl +1 -1
- package/src/gpu/kernels/moe.d.ts +1 -56
- package/src/gpu/kernels/moe.js +46 -33
- package/src/gpu/kernels/moe_gather_f16.wgsl +1 -1
- package/src/gpu/kernels/pipeline-cache.d.ts +8 -0
- package/src/gpu/kernels/pipeline-cache.js +24 -0
- package/src/gpu/kernels/pixel_shuffle_f16.wgsl +1 -1
- 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 -12
- package/src/gpu/kernels/residual.js +13 -1
- package/src/gpu/kernels/residual.wgsl +3 -3
- package/src/gpu/kernels/residual_f16.wgsl +6 -4
- 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 +30 -7
- package/src/gpu/kernels/rmsnorm.js +49 -8
- package/src/gpu/kernels/rmsnorm.wgsl +15 -12
- package/src/gpu/kernels/rmsnorm_f16.wgsl +69 -39
- 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.d.ts +1 -5
- package/src/gpu/kernels/rope.js +12 -2
- package/src/gpu/kernels/rope.wgsl +33 -19
- package/src/gpu/kernels/rope_f16.wgsl +39 -25
- 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.d.ts +0 -5
- package/src/gpu/kernels/sample.js +212 -187
- package/src/gpu/kernels/sample.wgsl +7 -6
- package/src/gpu/kernels/sample_f16.wgsl +28 -30
- package/src/gpu/kernels/scatter_add_dynamic_expert_scale.wgsl +47 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16.wgsl +1 -1
- 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.d.ts +13 -0
- package/src/gpu/kernels/shader-cache.js +28 -21
- package/src/gpu/kernels/silu_f16.wgsl +1 -1
- 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 +8 -223
- 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_qg_f16.wgsl +1 -1
- package/src/gpu/kernels/split_qkv_f16.wgsl +1 -1
- 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/topk_f16.wgsl +1 -1
- package/src/gpu/kernels/turboquant-codebook.js +11 -40
- package/src/gpu/kernels/uniform-utils.d.ts +18 -0
- package/src/gpu/kernels/uniform-utils.js +2 -5
- package/src/gpu/kernels/upsample2d.d.ts +0 -4
- package/src/gpu/kernels/upsample2d_f16.wgsl +1 -1
- package/src/gpu/kernels/utils.d.ts +43 -0
- package/src/gpu/kernels/utils.js +81 -11
- package/src/gpu/perf-guards.d.ts +0 -12
- package/src/gpu/perf-guards.js +0 -62
- package/src/gpu/profiler.d.ts +0 -21
- package/src/gpu/profiler.js +0 -34
- package/src/gpu/readback-utils.js +10 -2
- package/src/gpu/submit-tracker.d.ts +0 -57
- package/src/gpu/submit-tracker.js +3 -62
- package/src/gpu/tensor.d.ts +0 -23
- package/src/gpu/tensor.js +0 -41
- package/src/gpu/uniform-cache.d.ts +10 -12
- package/src/gpu/uniform-cache.js +25 -30
- package/src/gpu/weight-buffer.d.ts +76 -7
- package/src/gpu/weight-buffer.js +85 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/inference/browser-harness-diffusion-energy-suites.js +269 -1
- package/src/inference/browser-harness-model-helpers.d.ts +0 -9
- package/src/inference/browser-harness-model-helpers.js +22 -13
- package/src/inference/browser-harness-runtime-helpers.d.ts +0 -5
- package/src/inference/browser-harness-runtime-helpers.js +2 -2
- package/src/inference/browser-harness-suite-helpers.d.ts +13 -1
- package/src/inference/browser-harness-suite-helpers.js +525 -3
- package/src/inference/browser-harness-text-helpers.d.ts +89 -0
- package/src/inference/browser-harness-text-helpers.js +459 -25
- package/src/inference/browser-harness.d.ts +7 -28
- package/src/inference/browser-harness.js +556 -79
- 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 +31 -0
- package/src/inference/kv-cache/base.js +125 -2
- package/src/inference/kv-cache/mixed-geometry.d.ts +11 -0
- package/src/inference/kv-cache/mixed-geometry.js +121 -4
- package/src/inference/kv-cache/quantized.js +2 -0
- package/src/inference/kv-cache/sliding-window.d.ts +14 -0
- package/src/inference/kv-cache/sliding-window.js +88 -0
- package/src/inference/kv-cache/tiered.js +7 -0
- package/src/inference/kv-cache/types.d.ts +2 -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/multi-model-network.d.ts +1 -1
- package/src/inference/multi-model-network.js +1 -2
- package/src/inference/network-evolution.d.ts +0 -12
- package/src/inference/network-evolution.js +2 -2
- package/src/inference/pipelines/audio/gemma4.js +52 -1
- package/src/inference/pipelines/context.js +17 -0
- package/src/inference/pipelines/diffusion/init.js +2 -2
- package/src/inference/pipelines/diffusion/pipeline.js +41 -96
- package/src/inference/pipelines/diffusion/text-encoder-gpu.d.ts +0 -5
- package/src/inference/pipelines/diffusion/text-encoder-gpu.js +0 -283
- package/src/inference/pipelines/diffusion/vae.js +4 -4
- 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/energy/quintel.d.ts +15 -0
- package/src/inference/pipelines/structured/index.d.ts +2 -0
- package/src/inference/pipelines/structured/index.js +2 -0
- package/src/inference/pipelines/structured/json-grammar-mask.js +143 -0
- package/src/inference/pipelines/structured/tsv-grammar-mask.js +166 -0
- package/src/inference/pipelines/text/attention/attn-config.d.ts +0 -5
- package/src/inference/pipelines/text/attention/attn-config.js +1 -1
- 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 +73 -2
- package/src/inference/pipelines/text/attention/projections.js +398 -71
- package/src/inference/pipelines/text/attention/quant-options.d.ts +38 -0
- package/src/inference/pipelines/text/attention/record.js +542 -56
- package/src/inference/pipelines/text/attention/rmsnorm-fusion-gate.d.ts +8 -0
- package/src/inference/pipelines/text/attention/rmsnorm-fusion-gate.js +19 -0
- package/src/inference/pipelines/text/attention/run.js +343 -50
- package/src/inference/pipelines/text/attention/types.d.ts +7 -1
- package/src/inference/pipelines/text/chat-format.d.ts +0 -10
- package/src/inference/pipelines/text/chat-format.js +1 -8
- package/src/inference/pipelines/text/config.d.ts +25 -26
- package/src/inference/pipelines/text/config.js +304 -25
- package/src/inference/pipelines/text/debug-utils/utils.js +2 -23
- package/src/inference/pipelines/text/drift-policy.js +1 -1
- 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 +25 -29
- package/src/inference/pipelines/text/embed.js +16 -45
- package/src/inference/pipelines/text/execution-plan.d.ts +13 -3
- package/src/inference/pipelines/text/execution-plan.js +21 -2
- package/src/inference/pipelines/text/execution-runtime-builders.d.ts +4 -4
- package/src/inference/pipelines/text/execution-runtime-builders.js +44 -39
- package/src/inference/pipelines/text/execution-v1.d.ts +20 -0
- package/src/inference/pipelines/text/execution-v1.js +461 -158
- package/src/inference/pipelines/text/ffn/dense.js +214 -6
- 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 +84 -17
- package/src/inference/pipelines/text/generator-decode-policy.d.ts +81 -0
- package/src/inference/pipelines/text/generator-decode-policy.js +233 -0
- package/src/inference/pipelines/text/generator-helpers.d.ts +0 -2
- package/src/inference/pipelines/text/generator-helpers.js +9 -7
- package/src/inference/pipelines/text/generator-prefill-helpers.d.ts +84 -0
- package/src/inference/pipelines/text/generator-prefill-helpers.js +359 -0
- package/src/inference/pipelines/text/generator-runtime.d.ts +1 -7
- package/src/inference/pipelines/text/generator-runtime.js +8 -6
- package/src/inference/pipelines/text/generator-steps.d.ts +57 -7
- package/src/inference/pipelines/text/generator-steps.js +275 -79
- package/src/inference/pipelines/text/generator.d.ts +38 -5
- package/src/inference/pipelines/text/generator.js +1259 -496
- package/src/inference/pipelines/text/init-chat-templates.js +86 -0
- package/src/inference/pipelines/text/init-qkv-fusion.js +201 -0
- package/src/inference/pipelines/text/init-rope.js +408 -0
- package/src/inference/pipelines/text/init.d.ts +13 -3
- package/src/inference/pipelines/text/init.js +213 -725
- package/src/inference/pipelines/text/kernel-trace.d.ts +0 -33
- package/src/inference/pipelines/text/kernel-trace.js +0 -33
- package/src/inference/pipelines/text/layer-plan-gpu.js +590 -0
- package/src/inference/pipelines/text/layer-plan.d.ts +0 -5
- package/src/inference/pipelines/text/layer-plan.js +1 -1
- package/src/inference/pipelines/text/layer.d.ts +70 -8
- package/src/inference/pipelines/text/layer.js +373 -558
- package/src/inference/pipelines/text/linear-attention.d.ts +2 -1
- package/src/inference/pipelines/text/linear-attention.js +6 -4
- package/src/inference/pipelines/text/load-errors.d.ts +21 -0
- package/src/inference/pipelines/text/load-errors.js +59 -0
- package/src/inference/pipelines/text/logits/cpu.js +2 -20
- package/src/inference/pipelines/text/logits/gpu.d.ts +49 -2
- package/src/inference/pipelines/text/logits/gpu.js +419 -66
- package/src/inference/pipelines/text/logits/index.d.ts +3 -3
- 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.d.ts +5 -4
- package/src/inference/pipelines/text/model-load.js +74 -17
- 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 +42 -4
- package/src/inference/pipelines/text/ops.js +20 -1
- package/src/inference/pipelines/text/per-layer-inputs.js +36 -6
- package/src/inference/pipelines/text/probes.d.ts +3 -6
- package/src/inference/pipelines/text/probes.js +119 -31
- 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.d.ts +0 -5
- package/src/inference/pipelines/text/sampling.js +153 -9
- package/src/inference/pipelines/text/stage-names.js +3 -0
- package/src/inference/pipelines/text/state.js +19 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.d.ts +57 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.js +408 -0
- package/src/inference/pipelines/text/types.d.ts +92 -81
- package/src/inference/pipelines/text/weights.d.ts +4 -52
- package/src/inference/pipelines/text/weights.js +6 -56
- package/src/inference/pipelines/text.d.ts +33 -1
- package/src/inference/pipelines/text.js +375 -55
- package/src/inference/pipelines/vision/gemma4.js +20 -9
- package/src/inference/pipelines/vision/index.js +0 -107
- package/src/inference/runtime-model.d.ts +0 -7
- package/src/inference/runtime-model.js +0 -23
- package/src/inference/test-harness.d.ts +6 -22
- package/src/inference/test-harness.js +97 -23
- package/src/inference/tokenizer.d.ts +30 -0
- package/src/inference/tokenizer.js +341 -174
- package/src/inference/tokenizers/bundled.js +71 -49
- package/src/inference/tokenizers/sentencepiece.js +65 -15
- package/src/inference/tokenizers/types.d.ts +0 -21
- package/src/loader/doppler-loader.d.ts +14 -0
- package/src/loader/doppler-loader.js +378 -25
- 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 +276 -11
- 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 +61 -2
- package/src/loader/manifest-config.d.ts +8 -0
- package/src/loader/manifest-config.js +25 -1
- package/src/loader/memory-monitor.d.ts +17 -5
- package/src/loader/quantization-constants.d.ts +6 -0
- package/src/loader/shard-resolver.d.ts +1 -0
- package/src/loader/shard-resolver.js +52 -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/source-transform.js +6 -1
- package/src/loader/tensors/tensor-loader.d.ts +36 -8
- package/src/loader/tensors/tensor-loader.js +521 -22
- 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/address-table.d.ts +1 -9
- package/src/memory/buffer-pool.d.ts +0 -16
- package/src/memory/buffer-pool.js +13 -42
- package/src/memory/heap-manager.d.ts +18 -43
- package/src/memory/unified-detect.d.ts +19 -34
- package/src/models/diffusiongemma.d.ts +7 -0
- package/src/models/diffusiongemma.js +25 -0
- package/src/models/embeddinggemma.d.ts +7 -0
- package/src/models/embeddinggemma.js +24 -0
- package/src/models/family.d.ts +24 -0
- package/src/models/family.js +25 -0
- package/src/models/gemma3.d.ts +7 -0
- package/src/models/gemma3.js +33 -0
- package/src/models/gemma4.d.ts +7 -0
- package/src/models/gemma4.js +57 -0
- package/src/models/qwen3.d.ts +7 -0
- package/src/models/qwen3.js +36 -0
- package/src/rules/converter/tokenizer.rules.json +5 -0
- package/src/rules/execution-rules-contract-check.js +162 -10
- package/src/rules/inference/capability-transforms.rules.json +111 -0
- 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 +117 -16
- package/src/rules/inference/ffn.rules.json +24 -2
- 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 +17 -0
- package/src/rules/rule-registry.js +59 -75
- package/src/storage/artifact-storage-context.d.ts +12 -3
- package/src/storage/artifact-storage-context.js +241 -26
- package/src/storage/backends/opfs-store.js +138 -88
- package/src/storage/blake3.js +9 -1
- package/src/storage/export.js +1 -5
- package/src/storage/normalize-model-id.js +3 -0
- package/src/storage/preflight.js +11 -0
- package/src/storage/quickstart-downloader.js +44 -67
- package/src/storage/reports.js +35 -11
- package/src/storage/shard-manager.d.ts +8 -2
- package/src/storage/shard-manager.js +176 -15
- package/src/storage/source-artifact-store.d.ts +0 -2
- package/src/storage/source-artifact-store.js +3 -9
- package/src/sw.js +0 -3
- package/src/tooling/browser-command-runner.d.ts +0 -3
- package/src/tooling/browser-command-runner.js +31 -4
- package/src/tooling/command-api-constants.js +1 -1
- package/src/tooling/command-api-family-normalizers.d.ts +1 -0
- package/src/tooling/command-api-family-normalizers.js +53 -9
- package/src/tooling/command-api-helpers.d.ts +0 -2
- package/src/tooling/command-api-helpers.js +8 -3
- package/src/tooling/command-api.d.ts +22 -1
- package/src/tooling/command-api.js +11 -1
- package/src/tooling/command-envelope.d.ts +0 -1
- package/src/tooling/command-envelope.js +1 -1
- package/src/tooling/command-runner-shared.d.ts +14 -0
- package/src/tooling/command-runner-shared.js +2 -1
- package/src/tooling/conversion-config-materializer.d.ts +0 -10
- package/src/tooling/conversion-config-materializer.js +1 -1
- package/src/tooling/diagnose-runner.js +3 -4
- package/src/tooling/hf-registry-utils.d.ts +2 -6
- package/src/tooling/hf-registry-utils.js +90 -19
- package/src/tooling/kernel-path-builder/index.js +1 -4
- package/src/tooling/kernel-path-builder/runtime-overlay.js +1 -3
- package/src/tooling/lean-execution-contract-runner.d.ts +0 -10
- package/src/tooling/lean-execution-contract-runner.js +2 -2
- package/src/tooling/litert-package-runtime.d.ts +1 -1
- package/src/tooling/litert-package-runtime.js +571 -37
- package/src/tooling/node-browser-command-runner.d.ts +15 -0
- package/src/tooling/node-browser-command-runner.js +107 -17
- package/src/tooling/node-command-runner.js +43 -2
- package/src/tooling/node-convert-worker-pool.js +15 -0
- package/src/tooling/node-convert-worker.js +11 -1
- package/src/tooling/node-converter.js +102 -1
- package/src/tooling/node-source-runtime.js +1 -10
- package/src/tooling/node-webgpu.d.ts +1 -0
- package/src/tooling/node-webgpu.js +23 -11
- package/src/tooling/opfs-cache.js +1 -4
- package/src/tooling/precision-replay-math.js +174 -0
- package/src/tooling/program-bundle-host.d.ts +16 -0
- package/src/tooling/program-bundle-host.js +20 -0
- package/src/tooling/program-bundle-parity.d.ts +28 -0
- package/src/tooling/program-bundle-parity.js +210 -0
- package/src/tooling/program-bundle.d.ts +112 -0
- package/src/tooling/program-bundle.js +1119 -0
- package/src/tooling/rdrr-integrity-refresh.d.ts +50 -0
- package/src/tooling/rdrr-integrity-refresh.js +271 -0
- package/src/tooling/reference-verify.js +191 -0
- package/src/tooling/source-artifact-adapter.d.ts +0 -20
- package/src/tooling/source-artifact-adapter.js +10 -5
- package/src/tooling/source-package-profiles.d.ts +18 -1
- package/src/tooling/source-package-profiles.js +110 -8
- package/src/tooling/source-runtime-bundle.d.ts +3 -0
- package/src/tooling/source-runtime-bundle.js +30 -22
- package/src/tooling/source-runtime-converter-config.d.ts +0 -5
- package/src/tooling/source-runtime-converter-config.js +25 -12
- package/src/tooling/source-runtime-materializer.js +1 -7
- package/src/tooling-experimental-exports.shared.d.ts +10 -0
- package/src/tooling-experimental-exports.shared.js +10 -0
- package/src/tooling-exports/device.d.ts +11 -0
- package/src/tooling-exports/device.js +14 -0
- package/src/tooling-exports/manifest.d.ts +8 -0
- package/src/tooling-exports/manifest.js +11 -0
- package/src/tooling-exports/storage.d.ts +25 -0
- package/src/tooling-exports/storage.js +29 -0
- package/src/tooling-exports/structured.d.ts +1 -0
- package/src/tooling-exports/structured.js +5 -0
- package/src/tooling-exports.d.ts +23 -0
- package/src/tooling-exports.js +17 -0
- package/src/tooling-exports.shared.d.ts +27 -30
- package/src/tooling-exports.shared.js +28 -29
- package/src/types/index.d.ts +0 -3
- package/src/types/index.js +0 -3
- package/src/utils/array-buffer.d.ts +4 -0
- package/src/utils/array-buffer.js +9 -0
- package/src/utils/canonical-hash.d.ts +7 -0
- package/src/utils/canonical-hash.js +74 -0
- package/src/utils/clone-json.d.ts +1 -0
- package/src/utils/clone-json.js +7 -0
- package/src/utils/encode-utf8.js +5 -0
- package/src/utils/index.d.ts +4 -1
- package/src/utils/index.js +4 -1
- package/src/utils/runtime-env.js +7 -0
- package/src/utils/sha256.d.ts +1 -0
- package/src/utils/sha256.js +18 -4
- package/src/utils/stable-sort-object.d.ts +1 -0
- package/src/utils/stable-sort-object.js +13 -0
- package/src/version.js +1 -1
- package/tools/convert-safetensors-node.js +1 -2
- package/src/bootstrap.d.ts +0 -1
- package/src/config/conversion/sana/sana-sprint-0.6b-f16.json +0 -247
- package/src/config/kernels/kernel-ref.d.ts +0 -17
- package/src/config/kernels/kernel-ref.js +0 -75
- package/src/config/runtime/kernels/dequant-f16-q4k.json +0 -13
- package/src/config/runtime/kernels/dequant-f32-q4k.json +0 -13
- package/src/config/runtime/kernels/embeddinggemma-q4k-dequant-f32a.json +0 -37
- package/src/config/runtime/kernels/fused-q4k.json +0 -13
- package/src/config/runtime/kernels/gemma2-q4k-dequant-f16a.json +0 -33
- package/src/config/runtime/kernels/gemma2-q4k-dequant-f32a-nosubgroups.json +0 -33
- package/src/config/runtime/kernels/gemma2-q4k-fused-f32a.json +0 -33
- package/src/config/runtime/kernels/safe-q4k.json +0 -13
- package/src/config/runtime/overlays/debug-f32a.json +0 -3
- package/src/config/runtime/overlays/trace-config.json +0 -28
- package/src/config/runtime/profiles/gemma4-e2b-throughput.json +0 -39
- package/src/debug/perf.d.ts +0 -33
- package/src/debug/perf.js +0 -51
- package/src/errors/index.d.ts +0 -1
- package/src/errors/index.js +0 -1
- package/src/formats/gguf/index.d.ts +0 -8
- package/src/formats/gguf/index.js +0 -4
- package/src/formats/litert/index.d.ts +0 -1
- package/src/formats/litert/index.js +0 -1
- package/src/formats/safetensors/index.d.ts +0 -8
- package/src/formats/safetensors/index.js +0 -4
- package/src/formats/tflite/index.d.ts +0 -1
- package/src/formats/tflite/index.js +0 -1
- package/src/gpu/kernels/attention_decode_optimized.wgsl +0 -445
- package/src/gpu/kernels/dequant_mxfp4_vec4.wgsl +0 -116
- package/src/gpu/kernels/dequant_q8_0.wgsl +0 -98
- package/src/gpu/kernels/dequant_shared_vec4.wgsl +0 -160
- package/src/gpu/kernels/moe_gather_vec4.wgsl +0 -74
- package/src/inference/functiongemma.d.ts +0 -15
- package/src/inference/functiongemma.js +0 -1
- package/src/inference/pipelines/diffusion/sana-transformer.d.ts +0 -53
- package/src/inference/pipelines/diffusion/sana-transformer.js +0 -738
- package/src/rules/kernels/kernel-validator.d.ts +0 -24
- package/src/rules/kernels/kernel-validator.js +0 -160
- package/src/sw.d.ts +0 -1
- package/src/tooling/bench-runner.js +0 -64
- package/src/tooling/distill-runner.js +0 -56
- package/src/tooling/lora-runner.js +0 -37
- package/src/tooling/verify-runner.js +0 -63
- package/src/types/gpu.d.ts +0 -185
- package/src/types/gpu.js +0 -5
- package/src/types/inference.d.ts +0 -197
- package/src/types/inference.js +0 -5
- package/src/types/model.d.ts +0 -130
- package/src/types/model.js +0 -5
- package/src/utils/format-bytes.js +0 -20
- /package/src/config/{runtime/diagnostics → diagnostics}/drift-policies.json +0 -0
- /package/src/gpu/kernels/{sana_linear_attention_apply.wgsl → linear_attention_apply.wgsl} +0 -0
- /package/src/gpu/kernels/{sana_linear_attention_apply_f16.wgsl → linear_attention_apply_f16.wgsl} +0 -0
- /package/src/gpu/kernels/{sana_linear_attention_summary.wgsl → linear_attention_summary.wgsl} +0 -0
- /package/src/gpu/kernels/{sana_linear_attention_summary_f16.wgsl → linear_attention_summary_f16.wgsl} +0 -0
- /package/src/rules/kernels/{sana-linear-attention.rules.json → linear-attention.rules.json} +0 -0
|
@@ -42,6 +42,21 @@ export declare function runBrowserCommandInNode(
|
|
|
42
42
|
options?: NodeBrowserCommandRunOptions
|
|
43
43
|
): Promise<BrowserCommandRunResult>;
|
|
44
44
|
|
|
45
|
+
export declare function runBrowserCommandEvaluationWithTimeout<T>(
|
|
46
|
+
operation: () => Promise<T>,
|
|
47
|
+
timeoutMs: number
|
|
48
|
+
): Promise<T>;
|
|
49
|
+
|
|
45
50
|
export declare function normalizeNodeBrowserCommand(
|
|
46
51
|
commandRequest: ToolingCommandRequestInput
|
|
47
52
|
): ToolingCommandRequest;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Validate a browser-relay response envelope and stamp the original
|
|
56
|
+
* request onto it. Throws when the envelope does not match the success
|
|
57
|
+
* shape.
|
|
58
|
+
*/
|
|
59
|
+
export declare function finalizeBrowserRelayResponse(
|
|
60
|
+
response: unknown,
|
|
61
|
+
request: ToolingCommandRequest
|
|
62
|
+
): BrowserCommandRunResult & { request: ToolingCommandRequest };
|
|
@@ -365,6 +365,15 @@ async function createLocalFileRelayMount(filePath, fieldLabel, urlPrefixRoot, op
|
|
|
365
365
|
const mountName = encodeURIComponent(fileName);
|
|
366
366
|
const mountPrefix = `${urlPrefixRoot}/${mountName}-${process.pid}-${Date.now()}`;
|
|
367
367
|
if (expectDirectory) {
|
|
368
|
+
if (options.mountParentDirectory === true) {
|
|
369
|
+
return {
|
|
370
|
+
url: `${mountPrefix}/${mountName}`,
|
|
371
|
+
staticMount: {
|
|
372
|
+
urlPrefix: mountPrefix,
|
|
373
|
+
rootDir: path.dirname(filePath),
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
}
|
|
368
377
|
return {
|
|
369
378
|
url: mountPrefix,
|
|
370
379
|
staticMount: {
|
|
@@ -409,6 +418,7 @@ export async function resolveLocalFileModelUrlForBrowserRelay(request, options =
|
|
|
409
418
|
originalUrl: request.modelUrl,
|
|
410
419
|
kind: 'directory',
|
|
411
420
|
fallbackName: 'model',
|
|
421
|
+
mountParentDirectory: true,
|
|
412
422
|
});
|
|
413
423
|
relayRequest = {
|
|
414
424
|
...relayRequest,
|
|
@@ -475,10 +485,10 @@ function normalizeBrowserArgs(value) {
|
|
|
475
485
|
|
|
476
486
|
return value.map((arg) => {
|
|
477
487
|
if (arg === undefined || arg === null) {
|
|
478
|
-
throw new Error('browser command:
|
|
488
|
+
throw new Error('browser command: browserArgs values must be strings.');
|
|
479
489
|
}
|
|
480
490
|
if (typeof arg !== 'string') {
|
|
481
|
-
throw new Error('browser command:
|
|
491
|
+
throw new Error('browser command: browserArgs values must be strings.');
|
|
482
492
|
}
|
|
483
493
|
return arg.trim();
|
|
484
494
|
}).filter((arg) => arg.length > 0);
|
|
@@ -505,6 +515,7 @@ const PLATFORM_WEBGPU_ARGS = Object.freeze({
|
|
|
505
515
|
]),
|
|
506
516
|
win32: Object.freeze([]),
|
|
507
517
|
});
|
|
518
|
+
const BROWSER_LAUNCH_HINT = 'Install Playwright browsers (npx playwright install) or set run.browser.channel / run.browser.executablePath.';
|
|
508
519
|
|
|
509
520
|
function uniqueArgs(args) {
|
|
510
521
|
return [...new Set(args)];
|
|
@@ -588,6 +599,57 @@ function hasCrashRecoveryArgs(args = []) {
|
|
|
588
599
|
return CRASH_RECOVERY_BROWSER_ARGS.every((arg) => argSet.has(arg));
|
|
589
600
|
}
|
|
590
601
|
|
|
602
|
+
function formatBrowserEvaluationError(payload) {
|
|
603
|
+
if (!payload || typeof payload !== 'object') {
|
|
604
|
+
return new Error('browser command runner failed with an unserializable error.');
|
|
605
|
+
}
|
|
606
|
+
const message = asNonEmptyString(payload.message) || 'Unknown browser command error';
|
|
607
|
+
const stack = asNonEmptyString(payload.stack);
|
|
608
|
+
const causeMessage = asNonEmptyString(payload.cause?.message);
|
|
609
|
+
const text = [
|
|
610
|
+
`browser command runner failed: ${message}`,
|
|
611
|
+
stack,
|
|
612
|
+
causeMessage ? `Caused by: ${causeMessage}` : null,
|
|
613
|
+
].filter(Boolean).join('\n');
|
|
614
|
+
const error = new Error(text);
|
|
615
|
+
error.name = asNonEmptyString(payload.name) || 'BrowserCommandError';
|
|
616
|
+
error.code = asNonEmptyString(payload.code) || null;
|
|
617
|
+
error.retryable = typeof payload.retryable === 'boolean' ? payload.retryable : null;
|
|
618
|
+
error.details = {
|
|
619
|
+
...(payload.details && typeof payload.details === 'object' ? payload.details : {}),
|
|
620
|
+
browserErrorName: asNonEmptyString(payload.name),
|
|
621
|
+
browserStack: stack,
|
|
622
|
+
browserCause: payload.cause && typeof payload.cause === 'object'
|
|
623
|
+
? {
|
|
624
|
+
name: asNonEmptyString(payload.cause.name),
|
|
625
|
+
message: asNonEmptyString(payload.cause.message),
|
|
626
|
+
stack: asNonEmptyString(payload.cause.stack),
|
|
627
|
+
code: asNonEmptyString(payload.cause.code),
|
|
628
|
+
}
|
|
629
|
+
: null,
|
|
630
|
+
};
|
|
631
|
+
return error;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export async function runBrowserCommandEvaluationWithTimeout(operation, timeoutMs) {
|
|
635
|
+
let timeoutId = null;
|
|
636
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
637
|
+
timeoutId = setTimeout(() => {
|
|
638
|
+
reject(new Error(`browser command: runner did not finish within ${timeoutMs}ms.`));
|
|
639
|
+
}, timeoutMs);
|
|
640
|
+
});
|
|
641
|
+
try {
|
|
642
|
+
return await Promise.race([
|
|
643
|
+
operation(),
|
|
644
|
+
timeoutPromise,
|
|
645
|
+
]);
|
|
646
|
+
} finally {
|
|
647
|
+
if (timeoutId !== null) {
|
|
648
|
+
clearTimeout(timeoutId);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
591
653
|
function browserLaunchArgs(extraArgs = []) {
|
|
592
654
|
const platformArgs = PLATFORM_WEBGPU_ARGS[process.platform] ?? [];
|
|
593
655
|
return uniqueArgs([...DEFAULT_WEBGPU_BROWSER_ARGS, ...platformArgs, ...extraArgs]);
|
|
@@ -606,7 +668,7 @@ async function launchBrowser(chromium, launchOptions, options = {}) {
|
|
|
606
668
|
} catch (error) {
|
|
607
669
|
const message = error?.message || String(error);
|
|
608
670
|
throw new Error(
|
|
609
|
-
`browser command: failed to launch browser (${message}).
|
|
671
|
+
`browser command: failed to launch browser (${message}). ${BROWSER_LAUNCH_HINT}`
|
|
610
672
|
);
|
|
611
673
|
}
|
|
612
674
|
}
|
|
@@ -632,7 +694,7 @@ async function launchBrowser(chromium, launchOptions, options = {}) {
|
|
|
632
694
|
throw new Error(
|
|
633
695
|
`browser command: failed to launch browser (${allErrors}). ` +
|
|
634
696
|
`Tried default channels: ${resolveDefaultChannels().join(', ')}. ` +
|
|
635
|
-
|
|
697
|
+
BROWSER_LAUNCH_HINT
|
|
636
698
|
);
|
|
637
699
|
}
|
|
638
700
|
};
|
|
@@ -666,14 +728,14 @@ async function launchBrowser(chromium, launchOptions, options = {}) {
|
|
|
666
728
|
if (isRecoverablePersistentLaunchError(retryMessage)) {
|
|
667
729
|
throw new Error(
|
|
668
730
|
`browser command: failed to launch browser with crash recovery enabled (${retryMessage}). ` +
|
|
669
|
-
|
|
731
|
+
BROWSER_LAUNCH_HINT
|
|
670
732
|
);
|
|
671
733
|
}
|
|
672
734
|
|
|
673
735
|
throw new Error(
|
|
674
736
|
`browser command: failed to launch browser (${retryMessage}). ` +
|
|
675
737
|
`Tried default channels: ${resolveDefaultChannels().join(', ')}. ` +
|
|
676
|
-
|
|
738
|
+
BROWSER_LAUNCH_HINT
|
|
677
739
|
);
|
|
678
740
|
}
|
|
679
741
|
|
|
@@ -692,7 +754,7 @@ async function launchPersistentBrowser(chromium, userDataDir, launchOptions, opt
|
|
|
692
754
|
} catch (error) {
|
|
693
755
|
const message = error?.message || String(error);
|
|
694
756
|
throw new Error(
|
|
695
|
-
`browser command: failed to launch persistent browser (${message}).
|
|
757
|
+
`browser command: failed to launch persistent browser (${message}). ${BROWSER_LAUNCH_HINT}`
|
|
696
758
|
);
|
|
697
759
|
}
|
|
698
760
|
}
|
|
@@ -734,14 +796,14 @@ async function launchPersistentBrowser(chromium, userDataDir, launchOptions, opt
|
|
|
734
796
|
throw new Error(
|
|
735
797
|
`browser command: failed to launch persistent browser with crash recovery enabled (${retryMessage}). ` +
|
|
736
798
|
`Tried default channels: ${resolveDefaultChannels().join(', ')}. ` +
|
|
737
|
-
|
|
799
|
+
BROWSER_LAUNCH_HINT
|
|
738
800
|
);
|
|
739
801
|
}
|
|
740
802
|
|
|
741
803
|
throw new Error(
|
|
742
804
|
`browser command: failed to launch persistent browser (${retryMessage}). ` +
|
|
743
805
|
`Tried default channels: ${resolveDefaultChannels().join(', ')}. ` +
|
|
744
|
-
|
|
806
|
+
BROWSER_LAUNCH_HINT
|
|
745
807
|
);
|
|
746
808
|
}
|
|
747
809
|
|
|
@@ -758,10 +820,6 @@ export async function runBrowserCommandInNode(commandRequest, options = {}) {
|
|
|
758
820
|
);
|
|
759
821
|
}
|
|
760
822
|
|
|
761
|
-
if (request.command === 'convert') {
|
|
762
|
-
throw new Error('browser command relay does not support convert. Use --surface node for convert commands.');
|
|
763
|
-
}
|
|
764
|
-
|
|
765
823
|
let useOpfsCache = options.opfsCache !== false;
|
|
766
824
|
let relayRequest = request;
|
|
767
825
|
const userDataDir = options.userDataDir || DEFAULT_OPFS_CACHE_DIR;
|
|
@@ -791,7 +849,7 @@ export async function runBrowserCommandInNode(commandRequest, options = {}) {
|
|
|
791
849
|
}).catch((error) => {
|
|
792
850
|
const message = error?.message || String(error);
|
|
793
851
|
throw new Error(
|
|
794
|
-
`browser command: failed to start static server (${message}).
|
|
852
|
+
`browser command: failed to start static server (${message}). Set run.browser.baseUrl to reuse an existing server.`
|
|
795
853
|
);
|
|
796
854
|
});
|
|
797
855
|
|
|
@@ -945,17 +1003,49 @@ export async function runBrowserCommandInNode(commandRequest, options = {}) {
|
|
|
945
1003
|
}
|
|
946
1004
|
}
|
|
947
1005
|
|
|
948
|
-
const response = await page.evaluate(async (payload) => {
|
|
1006
|
+
const response = await runBrowserCommandEvaluationWithTimeout(() => page.evaluate(async (payload) => {
|
|
1007
|
+
const serializeError = (error, depth = 0) => {
|
|
1008
|
+
if (!error || typeof error !== 'object') {
|
|
1009
|
+
return {
|
|
1010
|
+
name: null,
|
|
1011
|
+
message: String(error || 'Unknown browser error'),
|
|
1012
|
+
stack: null,
|
|
1013
|
+
code: null,
|
|
1014
|
+
details: null,
|
|
1015
|
+
retryable: null,
|
|
1016
|
+
cause: null,
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
return {
|
|
1020
|
+
name: typeof error.name === 'string' ? error.name : null,
|
|
1021
|
+
message: typeof error.message === 'string' ? error.message : String(error),
|
|
1022
|
+
stack: typeof error.stack === 'string' ? error.stack : null,
|
|
1023
|
+
code: typeof error.code === 'string' ? error.code : null,
|
|
1024
|
+
details: error.details && typeof error.details === 'object' ? error.details : null,
|
|
1025
|
+
retryable: typeof error.retryable === 'boolean' ? error.retryable : null,
|
|
1026
|
+
cause: depth < 2 ? serializeError(error.cause, depth + 1) : null,
|
|
1027
|
+
};
|
|
1028
|
+
};
|
|
949
1029
|
if (typeof globalThis.__dopplerRunBrowserCommand !== 'function') {
|
|
950
1030
|
throw new Error('browser command runner is missing globalThis.__dopplerRunBrowserCommand');
|
|
951
1031
|
}
|
|
952
|
-
|
|
1032
|
+
try {
|
|
1033
|
+
return await globalThis.__dopplerRunBrowserCommand(payload.request, payload.options || {});
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
return {
|
|
1036
|
+
__dopplerBrowserError: serializeError(error),
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
953
1039
|
}, {
|
|
954
1040
|
request: relayRequest,
|
|
955
1041
|
options: {
|
|
956
1042
|
runtimeLoadOptions: options.runtimeLoadOptions || {},
|
|
957
1043
|
},
|
|
958
|
-
});
|
|
1044
|
+
}), timeoutMs);
|
|
1045
|
+
|
|
1046
|
+
if (response?.__dopplerBrowserError) {
|
|
1047
|
+
throw formatBrowserEvaluationError(response.__dopplerBrowserError);
|
|
1048
|
+
}
|
|
959
1049
|
|
|
960
1050
|
return finalizeBrowserRelayResponse(response, effectiveRequest);
|
|
961
1051
|
} catch (error) {
|
|
@@ -11,8 +11,14 @@ import { convertSafetensorsDirectory } from './node-converter.js';
|
|
|
11
11
|
import { installNodeFileFetchShim } from './node-file-fetch.js';
|
|
12
12
|
import { bootstrapNodeWebGPU } from './node-webgpu.js';
|
|
13
13
|
import { runDiagnoseCommand } from './diagnose-runner.js';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { checkProgramBundleParity } from './program-bundle-parity.js';
|
|
15
|
+
import {
|
|
16
|
+
applyRuntimeInputs,
|
|
17
|
+
buildSuiteOptions,
|
|
18
|
+
runWithRuntimeIsolation,
|
|
19
|
+
} from './command-runner-shared.js';
|
|
20
|
+
import { refreshManifestIntegrity } from './rdrr-integrity-refresh.js';
|
|
21
|
+
import { loadRuntimeConfigFromRef } from '../inference/browser-harness-runtime-helpers.js';
|
|
16
22
|
import { isPlainObject } from '../utils/plain-object.js';
|
|
17
23
|
import {
|
|
18
24
|
getActiveKernelPath,
|
|
@@ -125,6 +131,7 @@ export async function runNodeCommand(commandRequest, options = {}) {
|
|
|
125
131
|
outputDir: request.outputDir,
|
|
126
132
|
converterConfig,
|
|
127
133
|
execution,
|
|
134
|
+
configPath: convertPayload?.configPath ?? null,
|
|
128
135
|
onProgress: validatedOptions.onProgress,
|
|
129
136
|
});
|
|
130
137
|
return createToolingSuccessEnvelope({
|
|
@@ -134,6 +141,21 @@ export async function runNodeCommand(commandRequest, options = {}) {
|
|
|
134
141
|
});
|
|
135
142
|
}
|
|
136
143
|
|
|
144
|
+
if (request.command === 'refresh-integrity') {
|
|
145
|
+
const result = await refreshManifestIntegrity({
|
|
146
|
+
modelDir: request.modelDir,
|
|
147
|
+
manifestPath: request.manifestPath,
|
|
148
|
+
blockSize: request.blockSize ?? undefined,
|
|
149
|
+
dryRun: request.dryRun === true,
|
|
150
|
+
skipShardCheck: request.skipShardCheck === true,
|
|
151
|
+
});
|
|
152
|
+
return createToolingSuccessEnvelope({
|
|
153
|
+
surface: 'node',
|
|
154
|
+
request,
|
|
155
|
+
result,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
137
159
|
if (request.command === 'lora' || request.command === 'distill') {
|
|
138
160
|
const gpuOptionalActions = new Set(['compare', 'quality-gate', 'subsets']);
|
|
139
161
|
installNodeFileFetchShim();
|
|
@@ -159,9 +181,28 @@ export async function runNodeCommand(commandRequest, options = {}) {
|
|
|
159
181
|
});
|
|
160
182
|
}
|
|
161
183
|
|
|
184
|
+
if (
|
|
185
|
+
request.command === 'verify'
|
|
186
|
+
&& request.workload === 'inference'
|
|
187
|
+
&& request.workloadType === 'program-bundle'
|
|
188
|
+
) {
|
|
189
|
+
const result = await checkProgramBundleParity({
|
|
190
|
+
bundle: request.programBundle ?? undefined,
|
|
191
|
+
bundlePath: request.programBundlePath ?? undefined,
|
|
192
|
+
providers: request.parityProviders ?? undefined,
|
|
193
|
+
mode: request.programBundleParityMode ?? 'contract',
|
|
194
|
+
});
|
|
195
|
+
return createToolingSuccessEnvelope({
|
|
196
|
+
surface: 'node',
|
|
197
|
+
request,
|
|
198
|
+
result,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
162
202
|
await assertNodeWebGPUSupport();
|
|
163
203
|
const modules = await loadRuntimeModules();
|
|
164
204
|
const runtimeBridge = {
|
|
205
|
+
loadRuntimeConfigFromRef,
|
|
165
206
|
applyRuntimeProfile: modules.harness.applyRuntimeProfile,
|
|
166
207
|
applyRuntimeConfigFromUrl: modules.harness.applyRuntimeConfigFromUrl,
|
|
167
208
|
getRuntimeConfig: modules.runtime.getRuntimeConfig,
|
|
@@ -150,10 +150,25 @@ export class NodeConvertWorkerPool {
|
|
|
150
150
|
if (!(resultBytes instanceof ArrayBuffer)) {
|
|
151
151
|
job.reject(new Error('node convert worker returned invalid tensorData.'));
|
|
152
152
|
} else {
|
|
153
|
+
const companionBytes = message?.result?.companionData;
|
|
154
|
+
if (companionBytes != null && !(companionBytes instanceof ArrayBuffer)) {
|
|
155
|
+
job.reject(new Error('node convert worker returned invalid companionData.'));
|
|
156
|
+
this.#dispatch();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
153
159
|
job.resolve({
|
|
154
160
|
tensorData: new Uint8Array(resultBytes),
|
|
155
161
|
outDtype: message?.result?.outDtype ?? null,
|
|
156
162
|
outLayout: message?.result?.outLayout ?? null,
|
|
163
|
+
...(companionBytes instanceof ArrayBuffer
|
|
164
|
+
? { companionData: new Uint8Array(companionBytes) }
|
|
165
|
+
: {}),
|
|
166
|
+
...(message?.result?.sourceTransform
|
|
167
|
+
? { sourceTransform: message.result.sourceTransform }
|
|
168
|
+
: {}),
|
|
169
|
+
...(message?.result?.storage
|
|
170
|
+
? { storage: message.result.storage }
|
|
171
|
+
: {}),
|
|
157
172
|
});
|
|
158
173
|
}
|
|
159
174
|
this.#dispatch();
|
|
@@ -36,6 +36,13 @@ parentPort.on('message', (message) => {
|
|
|
36
36
|
|
|
37
37
|
const transformed = transformTensorBytes(tensor, new Uint8Array(rawData), job.transformContext ?? {});
|
|
38
38
|
const outBytes = toOwnedUint8Array(transformed.tensorData);
|
|
39
|
+
const companionBytes = transformed.companionData instanceof Uint8Array
|
|
40
|
+
? toOwnedUint8Array(transformed.companionData)
|
|
41
|
+
: null;
|
|
42
|
+
const transferList = [outBytes.buffer];
|
|
43
|
+
if (companionBytes && companionBytes.buffer !== outBytes.buffer) {
|
|
44
|
+
transferList.push(companionBytes.buffer);
|
|
45
|
+
}
|
|
39
46
|
parentPort.postMessage({
|
|
40
47
|
id,
|
|
41
48
|
ok: true,
|
|
@@ -43,8 +50,11 @@ parentPort.on('message', (message) => {
|
|
|
43
50
|
tensorData: outBytes.buffer,
|
|
44
51
|
outDtype: transformed.outDtype ?? tensor.dtype ?? null,
|
|
45
52
|
outLayout: transformed.outLayout ?? null,
|
|
53
|
+
...(companionBytes ? { companionData: companionBytes.buffer } : {}),
|
|
54
|
+
...(transformed.sourceTransform ? { sourceTransform: transformed.sourceTransform } : {}),
|
|
55
|
+
...(transformed.storage ? { storage: transformed.storage } : {}),
|
|
46
56
|
},
|
|
47
|
-
},
|
|
57
|
+
}, transferList);
|
|
48
58
|
} catch (error) {
|
|
49
59
|
const messageText = error instanceof Error ? error.message : String(error);
|
|
50
60
|
const stack = error instanceof Error ? error.stack : null;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
1
2
|
import fs from 'node:fs/promises';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
4
6
|
import { installNodeFileFetchShim } from './node-file-fetch.js';
|
|
5
7
|
import { NodeConvertWorkerPool } from './node-convert-worker-pool.js';
|
|
6
8
|
import { bootstrapNodeWebGPU } from './node-webgpu.js';
|
|
9
|
+
import { buildManifestIntegrityFromModelDir } from './rdrr-integrity-refresh.js';
|
|
7
10
|
import { isPlainObject } from '../utils/plain-object.js';
|
|
8
11
|
import { selectRuleValue } from '../rules/rule-registry.js';
|
|
9
12
|
import { log, trace } from '../debug/index.js';
|
|
@@ -159,10 +162,15 @@ function normalizeWorkerTransformResult(result, tensor) {
|
|
|
159
162
|
tensorData: result.tensorData,
|
|
160
163
|
outDtype: result.outDtype ?? tensor.dtype,
|
|
161
164
|
outLayout: result.outLayout ?? null,
|
|
165
|
+
...(result.companionData instanceof Uint8Array
|
|
166
|
+
? { companionData: result.companionData }
|
|
167
|
+
: {}),
|
|
168
|
+
...(result.sourceTransform ? { sourceTransform: result.sourceTransform } : {}),
|
|
169
|
+
...(result.storage ? { storage: result.storage } : {}),
|
|
162
170
|
};
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
const MAX_NODE_CONVERT_BUFFER_BYTES =
|
|
173
|
+
const MAX_NODE_CONVERT_BUFFER_BYTES = Math.min(Buffer.kMaxLength, 0x7fff_ffff);
|
|
166
174
|
|
|
167
175
|
function resolveRowChunkTransformPlan(input) {
|
|
168
176
|
const tensor = input?.tensor;
|
|
@@ -435,6 +443,13 @@ function readOptionalNonEmptyString(value) {
|
|
|
435
443
|
return trimmed || null;
|
|
436
444
|
}
|
|
437
445
|
|
|
446
|
+
function toRepoRelativePath(filePath) {
|
|
447
|
+
const normalized = readOptionalNonEmptyString(filePath);
|
|
448
|
+
if (!normalized) return null;
|
|
449
|
+
const relative = path.relative(process.cwd(), path.resolve(normalized)).replace(/\\/g, '/');
|
|
450
|
+
return relative && !relative.startsWith('..') ? relative : path.resolve(normalized);
|
|
451
|
+
}
|
|
452
|
+
|
|
438
453
|
function resolveConfiguredModelId(explicitModelId, converterConfig) {
|
|
439
454
|
return (
|
|
440
455
|
readOptionalNonEmptyString(explicitModelId)
|
|
@@ -533,6 +548,7 @@ async function resolveGgufPathFromDirectory(inputDir) {
|
|
|
533
548
|
|
|
534
549
|
function createFileRangeReader() {
|
|
535
550
|
const handleMap = new Map();
|
|
551
|
+
const maxNodeFdReadInt32 = 0x7fff_ffff;
|
|
536
552
|
|
|
537
553
|
async function getHandleEntry(filePath) {
|
|
538
554
|
const existingPromise = handleMap.get(filePath);
|
|
@@ -576,6 +592,25 @@ function createFileRangeReader() {
|
|
|
576
592
|
return new ArrayBuffer(0);
|
|
577
593
|
}
|
|
578
594
|
|
|
595
|
+
if (start > maxNodeFdReadInt32 || (end - start) > maxNodeFdReadInt32) {
|
|
596
|
+
const chunks = [];
|
|
597
|
+
let totalBytes = 0;
|
|
598
|
+
await new Promise((resolve, reject) => {
|
|
599
|
+
const stream = createReadStream(filePath, {
|
|
600
|
+
start,
|
|
601
|
+
end: end - 1,
|
|
602
|
+
});
|
|
603
|
+
stream.on('data', (chunk) => {
|
|
604
|
+
chunks.push(chunk);
|
|
605
|
+
totalBytes += chunk.byteLength;
|
|
606
|
+
});
|
|
607
|
+
stream.on('end', resolve);
|
|
608
|
+
stream.on('error', reject);
|
|
609
|
+
});
|
|
610
|
+
const out = Buffer.concat(chunks, totalBytes);
|
|
611
|
+
return out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength);
|
|
612
|
+
}
|
|
613
|
+
|
|
579
614
|
const out = Buffer.allocUnsafe(end - start);
|
|
580
615
|
await entry.fd.read(out, 0, out.length, start);
|
|
581
616
|
return out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength);
|
|
@@ -660,6 +695,10 @@ function createNodeConvertIO(outputDir, options) {
|
|
|
660
695
|
async readTensorData(tensor) {
|
|
661
696
|
return readRange(tensor.sourcePath, tensor.offset, tensor.size);
|
|
662
697
|
},
|
|
698
|
+
async readShardRange(index, offset, length) {
|
|
699
|
+
const filename = generateShardFilename(index);
|
|
700
|
+
return readRange(path.join(outputDir, filename), offset, length);
|
|
701
|
+
},
|
|
663
702
|
async writeShard(index, data) {
|
|
664
703
|
const filename = generateShardFilename(index);
|
|
665
704
|
await fs.writeFile(path.join(outputDir, filename), data);
|
|
@@ -804,6 +843,7 @@ function createNodeTensorTransformer(options) {
|
|
|
804
843
|
const transformed = await pool.transformTensor(chunkTensor, chunkTensorData, {
|
|
805
844
|
...transformContext,
|
|
806
845
|
forceQuantizeDecision: chunkPlan.forceQuantizeDecision,
|
|
846
|
+
originalTensorShape: tensor.shape,
|
|
807
847
|
});
|
|
808
848
|
const normalized = normalizeWorkerTransformResult(transformed, chunkTensor);
|
|
809
849
|
processedBytes += chunkTensorData.byteLength;
|
|
@@ -820,6 +860,7 @@ function createNodeTensorTransformer(options) {
|
|
|
820
860
|
|
|
821
861
|
const outDtype = chunkResults[0].outDtype ?? tensor.dtype;
|
|
822
862
|
const outLayout = chunkResults[0].outLayout ?? null;
|
|
863
|
+
const storage = chunkResults[0].storage ?? null;
|
|
823
864
|
for (const chunkResult of chunkResults) {
|
|
824
865
|
if ((chunkResult.outDtype ?? tensor.dtype) !== outDtype) {
|
|
825
866
|
throw new Error(`node convert: inconsistent chunk dtype for ${tensor.name}.`);
|
|
@@ -827,6 +868,9 @@ function createNodeTensorTransformer(options) {
|
|
|
827
868
|
if ((chunkResult.outLayout ?? null) !== outLayout) {
|
|
828
869
|
throw new Error(`node convert: inconsistent chunk layout for ${tensor.name}.`);
|
|
829
870
|
}
|
|
871
|
+
if (JSON.stringify(chunkResult.storage ?? null) !== JSON.stringify(storage)) {
|
|
872
|
+
throw new Error(`node convert: inconsistent chunk storage descriptor for ${tensor.name}.`);
|
|
873
|
+
}
|
|
830
874
|
}
|
|
831
875
|
|
|
832
876
|
const totalOutputBytes = chunkResults.reduce((sum, chunkResult) => (
|
|
@@ -839,10 +883,37 @@ function createNodeTensorTransformer(options) {
|
|
|
839
883
|
outputOffset += chunkResult.tensorData.byteLength;
|
|
840
884
|
}
|
|
841
885
|
|
|
886
|
+
const companionResults = chunkResults.filter((chunkResult) => (
|
|
887
|
+
chunkResult.companionData instanceof Uint8Array
|
|
888
|
+
));
|
|
889
|
+
let companionData = null;
|
|
890
|
+
let sourceTransform = null;
|
|
891
|
+
if (companionResults.length > 0) {
|
|
892
|
+
if (companionResults.length !== chunkResults.length) {
|
|
893
|
+
throw new Error(`node convert: inconsistent chunk companion data for ${tensor.name}.`);
|
|
894
|
+
}
|
|
895
|
+
sourceTransform = chunkResults[0].sourceTransform ?? null;
|
|
896
|
+
if (!sourceTransform) {
|
|
897
|
+
throw new Error(`node convert: chunk companion data is missing sourceTransform for ${tensor.name}.`);
|
|
898
|
+
}
|
|
899
|
+
const totalCompanionBytes = companionResults.reduce((sum, chunkResult) => (
|
|
900
|
+
sum + chunkResult.companionData.byteLength
|
|
901
|
+
), 0);
|
|
902
|
+
companionData = new Uint8Array(totalCompanionBytes);
|
|
903
|
+
let companionOffset = 0;
|
|
904
|
+
for (const chunkResult of companionResults) {
|
|
905
|
+
companionData.set(chunkResult.companionData, companionOffset);
|
|
906
|
+
companionOffset += chunkResult.companionData.byteLength;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
842
910
|
return {
|
|
843
911
|
tensorData: combined,
|
|
844
912
|
outDtype,
|
|
845
913
|
outLayout,
|
|
914
|
+
...(storage ? { storage } : {}),
|
|
915
|
+
...(companionData ? { companionData } : {}),
|
|
916
|
+
...(sourceTransform ? { sourceTransform } : {}),
|
|
846
917
|
};
|
|
847
918
|
};
|
|
848
919
|
}
|
|
@@ -914,6 +985,7 @@ function createNodeLargeTensorTransformer(options) {
|
|
|
914
985
|
let processedBytes = 0;
|
|
915
986
|
let outDtype = null;
|
|
916
987
|
let outLayout = null;
|
|
988
|
+
let storage = null;
|
|
917
989
|
|
|
918
990
|
for (let rowStart = 0; rowStart < chunkPlan.rows; rowStart += chunkPlan.rowChunkRows) {
|
|
919
991
|
const rowCount = Math.min(chunkPlan.rowChunkRows, chunkPlan.rows - rowStart);
|
|
@@ -933,11 +1005,13 @@ function createNodeLargeTensorTransformer(options) {
|
|
|
933
1005
|
const transformed = await pool.transformTensor(chunkTensor, chunkTensorData, {
|
|
934
1006
|
...transformContext,
|
|
935
1007
|
forceQuantizeDecision: chunkPlan.forceQuantizeDecision,
|
|
1008
|
+
originalTensorShape: tensor.shape,
|
|
936
1009
|
});
|
|
937
1010
|
const normalized = normalizeWorkerTransformResult(transformed, chunkTensor);
|
|
938
1011
|
if (outDtype == null) {
|
|
939
1012
|
outDtype = normalized.outDtype ?? tensor.dtype;
|
|
940
1013
|
outLayout = normalized.outLayout ?? null;
|
|
1014
|
+
storage = normalized.storage ?? null;
|
|
941
1015
|
} else {
|
|
942
1016
|
if ((normalized.outDtype ?? tensor.dtype) !== outDtype) {
|
|
943
1017
|
throw new Error(`node convert: inconsistent streamed chunk dtype for ${tensor.name}.`);
|
|
@@ -945,6 +1019,9 @@ function createNodeLargeTensorTransformer(options) {
|
|
|
945
1019
|
if ((normalized.outLayout ?? null) !== outLayout) {
|
|
946
1020
|
throw new Error(`node convert: inconsistent streamed chunk layout for ${tensor.name}.`);
|
|
947
1021
|
}
|
|
1022
|
+
if (JSON.stringify(normalized.storage ?? null) !== JSON.stringify(storage)) {
|
|
1023
|
+
throw new Error(`node convert: inconsistent streamed chunk storage descriptor for ${tensor.name}.`);
|
|
1024
|
+
}
|
|
948
1025
|
}
|
|
949
1026
|
await writeChunk(normalized);
|
|
950
1027
|
processedBytes += chunkLength;
|
|
@@ -957,6 +1034,7 @@ function createNodeLargeTensorTransformer(options) {
|
|
|
957
1034
|
return {
|
|
958
1035
|
outDtype: outDtype ?? tensor.dtype,
|
|
959
1036
|
outLayout: outLayout ?? null,
|
|
1037
|
+
...(storage ? { storage } : {}),
|
|
960
1038
|
};
|
|
961
1039
|
};
|
|
962
1040
|
}
|
|
@@ -1009,6 +1087,9 @@ export async function convertSafetensorsDirectory(options) {
|
|
|
1009
1087
|
import('../storage/shard-manager.js'),
|
|
1010
1088
|
]);
|
|
1011
1089
|
|
|
1090
|
+
const hashStringSha256 = async (value) => (
|
|
1091
|
+
computeHash(new TextEncoder().encode(String(value)), 'sha256')
|
|
1092
|
+
);
|
|
1012
1093
|
const converterConfig = createConverterConfig(converterConfigOverride ?? undefined);
|
|
1013
1094
|
const executionConfig = normalizeExecutionConfig(
|
|
1014
1095
|
options?.execution,
|
|
@@ -1324,6 +1405,10 @@ export async function convertSafetensorsDirectory(options) {
|
|
|
1324
1405
|
quantization: targetQuantization,
|
|
1325
1406
|
tokenizerJson,
|
|
1326
1407
|
tokenizerConfig,
|
|
1408
|
+
// GGUF inputs carry the tokenizer (eos/bos/pad IDs, chat template, etc.)
|
|
1409
|
+
// inside config.tokenizer; lift it to model.tokenizer so resolveEosTokenId
|
|
1410
|
+
// and other manifest helpers find it without a GGUF-specific branch.
|
|
1411
|
+
tokenizer: tokenizerConfig ?? config?.tokenizer ?? null,
|
|
1327
1412
|
generationConfig,
|
|
1328
1413
|
tokenizerModel: hasTokenizerModel ? 'tokenizer.model' : null,
|
|
1329
1414
|
embeddingPostprocessor,
|
|
@@ -1429,6 +1514,12 @@ export async function convertSafetensorsDirectory(options) {
|
|
|
1429
1514
|
architecture: manifestArchitecture,
|
|
1430
1515
|
inference,
|
|
1431
1516
|
converterConfig,
|
|
1517
|
+
source: pathToFileURL(inputDir).href,
|
|
1518
|
+
sourcePath: inputDir,
|
|
1519
|
+
sourceFormat: isInputGgufFile ? 'gguf' : 'safetensors',
|
|
1520
|
+
conversionConfigPath: toRepoRelativePath(options?.configPath),
|
|
1521
|
+
conversionConfig: converterConfigOverride ?? null,
|
|
1522
|
+
hashString: hashStringSha256,
|
|
1432
1523
|
tensorTransformer,
|
|
1433
1524
|
largeTensorTransformer,
|
|
1434
1525
|
onProgress(update) {
|
|
@@ -1463,6 +1554,16 @@ export async function convertSafetensorsDirectory(options) {
|
|
|
1463
1554
|
if (!deferredManifestState.manifest) {
|
|
1464
1555
|
throw new Error('node convert: convert core did not produce a manifest.');
|
|
1465
1556
|
}
|
|
1557
|
+
const builtIntegrity = await buildManifestIntegrityFromModelDir(result.manifest, {
|
|
1558
|
+
modelDir: outputDir,
|
|
1559
|
+
tensorMap: result.manifest.tensors ?? undefined,
|
|
1560
|
+
readRange: fileRangeReader.readRange,
|
|
1561
|
+
});
|
|
1562
|
+
result.manifest = {
|
|
1563
|
+
...result.manifest,
|
|
1564
|
+
integrityExtensions: builtIntegrity.integrityExtensions,
|
|
1565
|
+
};
|
|
1566
|
+
deferredManifestState.manifest = result.manifest;
|
|
1466
1567
|
await io.writeManifest(result.manifest);
|
|
1467
1568
|
|
|
1468
1569
|
const report = buildConvertReport(result, {
|
|
@@ -15,6 +15,7 @@ import { parseSafetensorsHeader } from '../formats/safetensors/types.js';
|
|
|
15
15
|
import { parseTFLiteFromSource } from '../formats/tflite/types.js';
|
|
16
16
|
import { log } from '../debug/index.js';
|
|
17
17
|
import { formatBytes } from '../storage/quota.js';
|
|
18
|
+
import { toArrayBuffer } from '../utils/array-buffer.js';
|
|
18
19
|
import {
|
|
19
20
|
createSourceStorageContext,
|
|
20
21
|
} from './source-runtime-bundle.js';
|
|
@@ -30,16 +31,6 @@ import {
|
|
|
30
31
|
} from './litert-package-runtime.js';
|
|
31
32
|
const MAX_NODE_READ_BYTES = 64 * 1024 * 1024;
|
|
32
33
|
|
|
33
|
-
function toArrayBuffer(value, label) {
|
|
34
|
-
if (value instanceof ArrayBuffer) {
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
if (value instanceof Uint8Array) {
|
|
38
|
-
return value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength);
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`${label} must return ArrayBuffer or Uint8Array.`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
function normalizePath(value) {
|
|
44
35
|
return String(value || '').trim();
|
|
45
36
|
}
|