doppler-gpu 0.2.2 → 0.4.3
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 +182 -0
- package/README.md +20 -8
- package/assets/doppler.svg +1601 -0
- package/package.json +82 -33
- package/src/cli/cli-model-resolution.js +275 -0
- package/src/cli/cli-output.js +453 -0
- package/src/cli/doppler-cli.js +817 -709
- package/src/cli/doppler-quickstart.d.ts +7 -23
- package/src/cli/doppler-quickstart.js +20 -4
- package/src/cli/doppler-serve.js +1 -1
- 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 +79 -5
- 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 +56 -4
- package/src/client/runtime/model-manager.d.ts +0 -14
- package/src/client/runtime/model-manager.js +2 -42
- package/src/client/runtime/model-session.js +33 -0
- package/src/client/runtime/model-source.d.ts +13 -1
- package/src/client/runtime/model-source.js +128 -2
- 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 +0 -60
- package/src/client/wrap-pipeline-handle.d.ts +20 -0
- package/src/client/wrap-pipeline-handle.js +84 -0
- package/src/config/README.md +3 -1
- package/src/config/conversion/README.md +23 -157
- package/src/config/conversion/embeddinggemma/google-embeddinggemma-300m-q4k-ehf16-af32.json +19 -4
- package/src/config/conversion/gemma3/gemma-3-1b-it-f16-af32.json +16 -9
- package/src/config/conversion/gemma3/gemma-3-1b-it-q4k-ehf16-af32.json +24 -9
- package/src/config/conversion/gemma3/gemma-3-270m-it-q4k-ehf16-af32.json +24 -9
- package/src/config/conversion/gemma3/translategemma-4b-1b-enes-q4k-ehf16-af32.json +16 -9
- package/src/config/conversion/gemma3/translategemma-4b-it-q4k-ehf16-af32.json +24 -9
- 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 +589 -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 +368 -62
- 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 +17 -10
- package/src/config/conversion/qwen3/qwen-3-5-0-8b-q4k-ehaf16.json +75 -33
- package/src/config/conversion/qwen3/qwen-3-5-2b-q4k-ehaf16.json +91 -59
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-eaf16.json +517 -0
- package/src/config/conversion/qwen3/qwen-3-6-27b-q4k-ehaf16.json +511 -0
- package/src/config/execution-contract-check.js +6 -5
- package/src/config/kernel-path-loader.d.ts +8 -2
- package/src/config/kernels/kernel-ref-digests.js +125 -122
- package/src/config/kernels/registry.d.ts +0 -35
- package/src/config/kernels/registry.js +5 -9
- package/src/config/kernels/registry.json +615 -368
- package/src/config/merge-helpers.d.ts +1 -1
- package/src/config/merge-helpers.js +1 -1
- package/src/config/merge.js +35 -7
- 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 +16 -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 +32 -0
- 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/platform/metal-apple-q4k.json +19 -3
- 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/benchmark.schema.d.ts +2 -0
- package/src/config/schema/benchmark.schema.js +1 -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/converter.schema.d.ts +5 -0
- package/src/config/schema/converter.schema.js +3 -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 +21 -3
- package/src/config/schema/doppler.schema.js +116 -9
- 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 +12 -1
- package/src/config/schema/execution-v1.schema.js +7 -1
- package/src/config/schema/index.d.ts +54 -1
- package/src/config/schema/index.js +15 -0
- package/src/config/schema/inference.schema.d.ts +3 -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 +73 -1
- package/src/config/schema/manifest.schema.js +48 -2
- package/src/config/schema/moe.schema.js +0 -8
- 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/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-e2b-it.json +36 -15
- package/src/config/supported-operations.d.ts +14 -0
- package/src/config/supported-operations.js +34 -0
- package/src/config/supported-operations.json +178 -0
- package/src/config/training-defaults.js +1 -7
- package/src/config/transforms/capability-transform-resolver.js +3 -1
- package/src/config/transforms/execution-graph-transforms.d.ts +55 -0
- package/src/config/transforms/execution-graph-transforms.js +693 -29
- package/src/converter/conversion-plan.js +13 -10
- package/src/converter/core.d.ts +57 -0
- package/src/converter/core.js +582 -13
- package/src/converter/parsers/diffusion.js +1 -33
- package/src/converter/quantization-info.d.ts +5 -4
- package/src/converter/quantization-info.js +39 -3
- package/src/converter/quantizer.d.ts +19 -0
- package/src/converter/quantizer.js +81 -4
- 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/browser/quantization.d.ts +5 -0
- package/src/experimental/distribution/shard-delivery.js +179 -23
- package/src/experimental/training/artifacts.js +1 -14
- package/src/experimental/training/checkpoint.js +1 -14
- 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.js +6 -6
- package/src/experimental/training/lora-pipeline.js +1 -14
- 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-artifacts.js +1 -14
- package/src/experimental/training/runner.js +1 -14
- package/src/experimental/training/workload-packs/registry.json +6 -6
- package/src/experimental/training/workloads.js +1 -1
- 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/groups.d.ts +1 -13
- package/src/formats/rdrr/groups.js +0 -34
- package/src/formats/rdrr/index.d.ts +9 -0
- package/src/formats/rdrr/index.js +9 -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 +4 -0
- 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 +390 -0
- package/src/formats/rdrr/storage-descriptor.d.ts +36 -0
- package/src/formats/rdrr/storage-descriptor.js +186 -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 +115 -1
- package/src/formats/rdrr/validation.js +245 -0
- package/src/formats/tflite/types.d.ts +8 -31
- package/src/formats/tflite/types.js +50 -5
- package/src/gpu/command-recorder.d.ts +9 -21
- package/src/gpu/command-recorder.js +41 -2
- package/src/gpu/device.d.ts +17 -3
- package/src/gpu/device.js +20 -4
- 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 +0 -3
- package/src/gpu/kernels/README.md +50 -18
- package/src/gpu/kernels/activation-static-qdq.d.ts +22 -0
- package/src/gpu/kernels/activation-static-qdq.js +69 -0
- package/src/gpu/kernels/activation_static_qdq.wgsl +25 -0
- package/src/gpu/kernels/attention.d.ts +28 -19
- package/src/gpu/kernels/attention.js +443 -9
- 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_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 +39 -16
- package/src/gpu/kernels/attention_streaming_f16kv.wgsl +22 -3
- 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_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 +2 -85
- package/src/gpu/kernels/codegen/patches/gelu_f16.from.gelu.diff +27 -24
- package/src/gpu/kernels/codegen/patches/residual_f16.from.residual.diff +1 -1
- package/src/gpu/kernels/codegen/patches/rmsnorm_f16.from.rmsnorm.diff +249 -179
- 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/dispatch.d.ts +12 -97
- package/src/gpu/kernels/dispatch.js +0 -117
- 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_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_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_f16.wgsl +1 -1
- 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 +0 -7
- package/src/gpu/kernels/gather_f16.wgsl +1 -1
- package/src/gpu/kernels/gelu_f16.wgsl +14 -15
- 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 +13 -5
- package/src/gpu/kernels/index.js +9 -4
- 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/logit-merge.d.ts +0 -24
- package/src/gpu/kernels/logit-merge.js +1 -17
- package/src/gpu/kernels/matmul-dispatch.js +7 -1
- package/src/gpu/kernels/matmul-selection.js +68 -1
- package/src/gpu/kernels/matmul.d.ts +0 -28
- package/src/gpu/kernels/matmul.js +101 -7
- 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 +0 -56
- package/src/gpu/kernels/moe.js +0 -15
- package/src/gpu/kernels/moe_gather_f16.wgsl +1 -1
- package/src/gpu/kernels/pixel_shuffle_f16.wgsl +1 -1
- package/src/gpu/kernels/residual.d.ts +0 -12
- package/src/gpu/kernels/residual_f16.wgsl +2 -2
- package/src/gpu/kernels/residual_f16_vec4.wgsl +5 -5
- package/src/gpu/kernels/rmsnorm.d.ts +0 -8
- package/src/gpu/kernels/rmsnorm.js +17 -1
- package/src/gpu/kernels/rmsnorm.wgsl +5 -6
- package/src/gpu/kernels/rmsnorm_f16.wgsl +65 -39
- 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/sample.d.ts +0 -5
- package/src/gpu/kernels/sample.wgsl +7 -6
- package/src/gpu/kernels/sample_f16.wgsl +28 -30
- package/src/gpu/kernels/scatter_add_dynamic_f16.wgsl +1 -1
- package/src/gpu/kernels/shader-cache.d.ts +13 -0
- package/src/gpu/kernels/shader-cache.js +27 -0
- package/src/gpu/kernels/silu_f16.wgsl +1 -1
- package/src/gpu/kernels/softmax.wgsl +4 -144
- package/src/gpu/kernels/split_qg_f16.wgsl +1 -1
- package/src/gpu/kernels/split_qkv_f16.wgsl +1 -1
- 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/upsample2d.d.ts +0 -4
- package/src/gpu/kernels/upsample2d_f16.wgsl +1 -1
- package/src/gpu/kernels/utils.d.ts +28 -0
- package/src/gpu/kernels/utils.js +41 -0
- 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/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 +0 -11
- package/src/gpu/uniform-cache.js +0 -23
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- 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 +4 -1
- package/src/inference/browser-harness-suite-helpers.js +87 -1
- package/src/inference/browser-harness-text-helpers.d.ts +13 -0
- package/src/inference/browser-harness-text-helpers.js +267 -18
- package/src/inference/browser-harness.d.ts +0 -29
- package/src/inference/browser-harness.js +271 -71
- package/src/inference/kv-cache/base.d.ts +6 -0
- package/src/inference/kv-cache/base.js +16 -1
- package/src/inference/kv-cache/mixed-geometry.d.ts +1 -0
- package/src/inference/kv-cache/mixed-geometry.js +12 -2
- package/src/inference/kv-cache/quantized.js +2 -0
- package/src/inference/kv-cache/tiered.js +7 -0
- package/src/inference/kv-cache/types.d.ts +2 -0
- 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/context.js +21 -2
- 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/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/projections.d.ts +2 -0
- package/src/inference/pipelines/text/attention/projections.js +70 -23
- package/src/inference/pipelines/text/attention/record.js +118 -5
- 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 +97 -6
- package/src/inference/pipelines/text/attention/types.d.ts +2 -0
- package/src/inference/pipelines/text/attention/types.js +9 -4
- 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 +3 -25
- package/src/inference/pipelines/text/config.js +105 -3
- 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/embed.d.ts +23 -27
- package/src/inference/pipelines/text/embed.js +10 -43
- package/src/inference/pipelines/text/execution-plan.d.ts +5 -3
- package/src/inference/pipelines/text/execution-plan.js +15 -2
- package/src/inference/pipelines/text/execution-runtime-builders.d.ts +0 -4
- package/src/inference/pipelines/text/execution-runtime-builders.js +0 -11
- package/src/inference/pipelines/text/execution-v1.d.ts +18 -0
- package/src/inference/pipelines/text/execution-v1.js +94 -25
- package/src/inference/pipelines/text/ffn/dense.js +180 -3
- package/src/inference/pipelines/text/ffn/standard.js +40 -13
- package/src/inference/pipelines/text/generator-decode-policy.js +243 -0
- package/src/inference/pipelines/text/generator-helpers.d.ts +6 -2
- package/src/inference/pipelines/text/generator-helpers.js +20 -2
- package/src/inference/pipelines/text/generator-prefill-helpers.js +293 -0
- package/src/inference/pipelines/text/generator-runtime.d.ts +0 -7
- package/src/inference/pipelines/text/generator-runtime.js +8 -6
- package/src/inference/pipelines/text/generator-steps.d.ts +22 -7
- package/src/inference/pipelines/text/generator-steps.js +23 -9
- package/src/inference/pipelines/text/generator.d.ts +0 -6
- package/src/inference/pipelines/text/generator.js +254 -530
- 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 +8 -2
- package/src/inference/pipelines/text/init.js +190 -710
- 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 +542 -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 +105 -537
- package/src/inference/pipelines/text/linear-attention.d.ts +2 -1
- 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 +5 -4
- package/src/inference/pipelines/text/logits/gpu.js +148 -11
- package/src/inference/pipelines/text/logits/index.d.ts +1 -1
- 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/ops.d.ts +13 -2
- package/src/inference/pipelines/text/ops.js +1 -1
- package/src/inference/pipelines/text/per-layer-inputs.js +347 -59
- package/src/inference/pipelines/text/probes.d.ts +3 -6
- package/src/inference/pipelines/text/probes.js +198 -31
- package/src/inference/pipelines/text/sampling.d.ts +0 -5
- package/src/inference/pipelines/text/sampling.js +140 -0
- package/src/inference/pipelines/text/stage-names.js +12 -0
- package/src/inference/pipelines/text/state.js +2 -0
- package/src/inference/pipelines/text/tsir-fixture-writer.js +409 -0
- package/src/inference/pipelines/text/types.d.ts +8 -78
- package/src/inference/pipelines/text/weights.d.ts +0 -50
- package/src/inference/pipelines/text/weights.js +2 -51
- package/src/inference/pipelines/text.d.ts +9 -1
- package/src/inference/pipelines/text.js +233 -29
- 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.js +1 -10
- package/src/inference/tokenizers/sentencepiece.js +65 -15
- package/src/inference/tokenizers/types.d.ts +0 -21
- package/src/loader/doppler-loader.d.ts +3 -0
- package/src/loader/doppler-loader.js +90 -12
- package/src/loader/embedding-loader.js +30 -5
- package/src/loader/loader-types.d.ts +4 -0
- package/src/loader/manifest-config.d.ts +2 -7
- package/src/loader/manifest-config.js +25 -1
- package/src/loader/memory-monitor.d.ts +17 -5
- package/src/loader/per-layer-input-loader.js +114 -1
- package/src/loader/quantization-constants.d.ts +6 -0
- package/src/loader/shard-resolver.d.ts +1 -0
- package/src/loader/shard-resolver.js +15 -0
- package/src/loader/tensors/source-transform.d.ts +15 -0
- package/src/loader/tensors/source-transform.js +317 -34
- package/src/loader/tensors/tensor-loader.d.ts +2 -9
- package/src/loader/tensors/tensor-loader.js +84 -1
- package/src/loader/tensors/tensor-reader.js +28 -2
- package/src/memory/address-table.d.ts +1 -9
- package/src/memory/buffer-pool.d.ts +0 -16
- package/src/memory/buffer-pool.js +1 -33
- package/src/memory/heap-manager.d.ts +18 -43
- package/src/memory/unified-detect.d.ts +19 -34
- 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 +33 -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 +72 -3
- package/src/rules/inference/capability-transforms.rules.json +87 -0
- package/src/rules/inference/execution.rules.json +11 -1
- package/src/rules/inference/ffn.rules.json +6 -2
- package/src/rules/loader/tensor-loader.rules.json +9 -0
- package/src/rules/rule-registry.js +53 -75
- package/src/storage/artifact-storage-context.d.ts +12 -3
- package/src/storage/artifact-storage-context.js +389 -98
- 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 +22 -0
- package/src/storage/quickstart-downloader.js +44 -56
- 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.js +39 -0
- 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 +49 -7
- package/src/tooling/command-api-helpers.d.ts +0 -2
- package/src/tooling/command-api-helpers.js +6 -2
- package/src/tooling/command-api.d.ts +20 -1
- package/src/tooling/command-api.js +10 -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 +10 -0
- 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 +1 -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 +373 -21
- package/src/tooling/node-browser-command-runner.d.ts +15 -0
- package/src/tooling/node-browser-command-runner.js +97 -13
- package/src/tooling/node-command-runner.js +36 -0
- package/src/tooling/node-convert-worker-pool.js +12 -0
- package/src/tooling/node-convert-worker.js +10 -1
- package/src/tooling/node-converter.js +90 -1
- package/src/tooling/node-source-runtime.js +257 -150
- 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 +61 -0
- package/src/tooling/program-bundle.js +1119 -0
- package/src/tooling/rdrr-integrity-refresh.d.ts +32 -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 +4 -4
- package/src/tooling/source-package-profiles.js +1 -7
- package/src/tooling/source-runtime-bundle.d.ts +27 -0
- package/src/tooling/source-runtime-bundle.js +56 -23
- package/src/tooling/source-runtime-converter-config.d.ts +0 -5
- package/src/tooling/source-runtime-converter-config.js +13 -9
- package/src/tooling/source-runtime-materializer.js +4 -8
- 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
|
@@ -102,39 +102,7 @@ const FLUX_LAYOUT = {
|
|
|
102
102
|
],
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
const
|
|
106
|
-
id: 'sana',
|
|
107
|
-
requiredComponents: ['transformer', 'text_encoder', 'tokenizer', 'vae', 'scheduler'],
|
|
108
|
-
weightedComponents: ['transformer', 'text_encoder', 'vae'],
|
|
109
|
-
matches(modelIndex) {
|
|
110
|
-
return (
|
|
111
|
-
getComponentClassName(modelIndex?.transformer) === 'SanaTransformer2DModel' &&
|
|
112
|
-
getComponentClassName(modelIndex?.text_encoder) === 'Gemma2Model'
|
|
113
|
-
);
|
|
114
|
-
},
|
|
115
|
-
tokenizerSpecs: [
|
|
116
|
-
{
|
|
117
|
-
modelIndexKey: 'tokenizer',
|
|
118
|
-
componentId: 'text_encoder',
|
|
119
|
-
type: 'bundled',
|
|
120
|
-
assets: [
|
|
121
|
-
{ suffix: 'tokenizer/tokenizer.json', targetName: 'tokenizer_tokenizer.json', kind: 'text', required: true },
|
|
122
|
-
{ suffix: 'tokenizer/tokenizer_config.json', targetName: 'tokenizer_config.json', kind: 'text', required: false },
|
|
123
|
-
{ suffix: 'tokenizer/special_tokens_map.json', targetName: 'tokenizer_special_tokens_map.json', kind: 'text', required: false },
|
|
124
|
-
{ suffix: 'tokenizer/tokenizer.model', targetName: 'tokenizer_tokenizer.model', kind: 'binary', required: false },
|
|
125
|
-
],
|
|
126
|
-
config: {
|
|
127
|
-
type: 'bundled',
|
|
128
|
-
tokenizerFile: 'tokenizer_tokenizer.json',
|
|
129
|
-
configFile: 'tokenizer_config.json',
|
|
130
|
-
specialTokensFile: 'tokenizer_special_tokens_map.json',
|
|
131
|
-
sentencePieceFile: 'tokenizer_tokenizer.model',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const LAYOUTS = [SD3_LAYOUT, FLUX_LAYOUT, SANA_LAYOUT];
|
|
105
|
+
const LAYOUTS = [SD3_LAYOUT, FLUX_LAYOUT];
|
|
138
106
|
|
|
139
107
|
function toAbortError(message = 'Cancelled') {
|
|
140
108
|
if (typeof DOMException === 'function') {
|
|
@@ -9,12 +9,8 @@ import type { ConverterConfigSchema, QuantizationInfoSchema } from '../config/in
|
|
|
9
9
|
|
|
10
10
|
export declare function normalizeQuantTag(value: string | null | undefined): string;
|
|
11
11
|
|
|
12
|
-
export declare function validateQuantType(value: string | null, flagName: string): void;
|
|
13
|
-
|
|
14
12
|
export declare function resolveManifestQuantization(quantize: string | null, fallback: string): string;
|
|
15
13
|
|
|
16
|
-
export declare function buildVariantTag(info: QuantizationInfoSchema): string;
|
|
17
|
-
|
|
18
14
|
export declare function normalizeQ4KLayout(value: string | null | undefined): string | null;
|
|
19
15
|
|
|
20
16
|
export declare function buildQuantizationInfo(
|
|
@@ -35,3 +31,8 @@ export declare function resolveModelId(
|
|
|
35
31
|
): string;
|
|
36
32
|
|
|
37
33
|
export declare function toWebGPUDtype(dtype: string): string;
|
|
34
|
+
|
|
35
|
+
export declare function resolveEffectiveQuantizationInfo(
|
|
36
|
+
baseInfo: QuantizationInfoSchema,
|
|
37
|
+
tensors: Record<string, unknown>
|
|
38
|
+
): QuantizationInfoSchema;
|
|
@@ -50,14 +50,25 @@ const QUANT_TAG_ALIASES = {
|
|
|
50
50
|
'int4': 'i4',
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
const PER_LAYER_EMBEDDING_QUANT_ALIASES = {
|
|
54
|
+
'int4_per_row': 'int4_per_row',
|
|
55
|
+
'int4-per-row': 'int4_per_row',
|
|
56
|
+
'i4-per-row': 'int4_per_row',
|
|
57
|
+
'i4_per_row': 'int4_per_row',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Human-facing variant suffixes for naming-only artifacts.
|
|
61
|
+
const PER_LAYER_EMBEDDING_VARIANT_TAGS = {
|
|
62
|
+
int4_per_row: 'int4ple',
|
|
63
|
+
};
|
|
64
|
+
|
|
53
65
|
export function normalizeQuantTag(value) {
|
|
54
66
|
if (!value) return DEFAULT_QUANT_TAG;
|
|
55
67
|
const lower = value.toLowerCase();
|
|
56
68
|
return QUANT_TAG_ALIASES[lower] ?? lower;
|
|
57
69
|
}
|
|
58
70
|
|
|
59
|
-
|
|
60
|
-
export function validateQuantType(value, source) {
|
|
71
|
+
function validateQuantType(value, source) {
|
|
61
72
|
if (!value) return;
|
|
62
73
|
const normalized = normalizeQuantTag(value);
|
|
63
74
|
|
|
@@ -76,6 +87,22 @@ export function validateQuantType(value, source) {
|
|
|
76
87
|
throw new Error(`Unknown quantization type: "${value}" (source: ${source})`);
|
|
77
88
|
}
|
|
78
89
|
|
|
90
|
+
function normalizePerLayerEmbeddingQuant(value) {
|
|
91
|
+
if (value == null) return null;
|
|
92
|
+
const normalized = String(value).trim().toLowerCase().replace(/\s+/g, '_');
|
|
93
|
+
if (!normalized) return null;
|
|
94
|
+
const canonical = PER_LAYER_EMBEDDING_QUANT_ALIASES[normalized];
|
|
95
|
+
if (canonical) return canonical;
|
|
96
|
+
throw new Error(
|
|
97
|
+
`converter.quantization.perLayerEmbeddings must be "int4_per_row" or null; got ${JSON.stringify(value)}.`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function perLayerEmbeddingVariantTag(value) {
|
|
102
|
+
if (!value) return null;
|
|
103
|
+
return PER_LAYER_EMBEDDING_VARIANT_TAGS[value] ?? null;
|
|
104
|
+
}
|
|
105
|
+
|
|
79
106
|
|
|
80
107
|
// Canonical dtype to manifest format mapping.
|
|
81
108
|
const MANIFEST_QUANT_NAMES = {
|
|
@@ -91,7 +118,7 @@ export function resolveManifestQuantization(quantize, fallback) {
|
|
|
91
118
|
}
|
|
92
119
|
|
|
93
120
|
|
|
94
|
-
|
|
121
|
+
function buildVariantTag(info) {
|
|
95
122
|
const weights = info.weights;
|
|
96
123
|
const embeddings = info.embeddings ?? weights;
|
|
97
124
|
const lmHead = info.lmHead ?? embeddings;
|
|
@@ -144,6 +171,11 @@ export function buildVariantTag(info) {
|
|
|
144
171
|
parts.push(`p${info.projector}`);
|
|
145
172
|
}
|
|
146
173
|
|
|
174
|
+
const perLayerTag = perLayerEmbeddingVariantTag(info.perLayerEmbeddings);
|
|
175
|
+
if (perLayerTag) {
|
|
176
|
+
parts.push(perLayerTag);
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
return parts.join('-');
|
|
148
180
|
}
|
|
149
181
|
|
|
@@ -229,6 +261,7 @@ export function buildQuantizationInfo(
|
|
|
229
261
|
const audioQuant = quantization.audio ?? null;
|
|
230
262
|
const projectorQuant = quantization.projector ?? null;
|
|
231
263
|
const computePrecision = quantization.computePrecision ?? null;
|
|
264
|
+
const perLayerEmbeddings = normalizePerLayerEmbeddingQuant(quantization.perLayerEmbeddings ?? null);
|
|
232
265
|
|
|
233
266
|
validateQuantType(weightQuant, 'converter.quantization.weights');
|
|
234
267
|
validateQuantType(embedQuant, 'converter.quantization.embeddings');
|
|
@@ -306,6 +339,9 @@ export function buildQuantizationInfo(
|
|
|
306
339
|
if (computePrecision) {
|
|
307
340
|
info.compute = computePrecision;
|
|
308
341
|
}
|
|
342
|
+
if (perLayerEmbeddings) {
|
|
343
|
+
info.perLayerEmbeddings = perLayerEmbeddings;
|
|
344
|
+
}
|
|
309
345
|
|
|
310
346
|
// Q4K layout: 'row' (fused kernel compatible) or 'col' (dequant fallback)
|
|
311
347
|
// Default to 'row' for Q4K weights since that's the performant path
|
|
@@ -99,3 +99,22 @@ export declare function shouldQuantize(
|
|
|
99
99
|
): boolean;
|
|
100
100
|
|
|
101
101
|
export declare function getQuantizedSize(shape: number[]): number;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Per-row symmetric int4 quantization for a 2D weight matrix.
|
|
105
|
+
* Returns packed int4 nibbles (rows × cols/2 bytes) plus per-row scales.
|
|
106
|
+
*/
|
|
107
|
+
export declare function quantizeToInt4PerRowSymmetric(
|
|
108
|
+
f32Data: Float32Array,
|
|
109
|
+
shape: [number, number]
|
|
110
|
+
): { quantized: Uint8Array; scales: Float32Array };
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Inverse of quantizeToInt4PerRowSymmetric — dequantize packed int4
|
|
114
|
+
* rows back to Float32 using the saved per-row scales.
|
|
115
|
+
*/
|
|
116
|
+
export declare function dequantizeInt4PerRowSymmetric(
|
|
117
|
+
quantized: Uint8Array,
|
|
118
|
+
scales: Float32Array,
|
|
119
|
+
shape: [number, number]
|
|
120
|
+
): Float32Array;
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
// Re-export for backward compatibility
|
|
10
10
|
export { QK_K, K_SCALE_SIZE, QK4_K_BLOCK_SIZE };
|
|
11
11
|
|
|
12
|
+
const f32ToF16ScratchF32 = new Float32Array(1);
|
|
13
|
+
const f32ToF16ScratchU32 = new Uint32Array(f32ToF16ScratchF32.buffer);
|
|
14
|
+
|
|
12
15
|
export function float32ToFloat16(value) {
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
floatView[0] = value;
|
|
16
|
-
const f = int32View[0];
|
|
16
|
+
f32ToF16ScratchF32[0] = value;
|
|
17
|
+
const f = f32ToF16ScratchU32[0];
|
|
17
18
|
|
|
18
19
|
const sign = (f >> 31) & 0x1;
|
|
19
20
|
let exp = (f >> 23) & 0xff;
|
|
@@ -283,6 +284,82 @@ export function quantizeToQ4KMRowWise(data, shape) {
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
|
|
287
|
+
// Symmetric per-row INT4 quantization matching the MediaPipe LiteRT-LM
|
|
288
|
+
// per_layer_embedder convention (extracted from gemma-4-E2B-it.litertlm
|
|
289
|
+
// composite0..composite34 PLE tensors). Each row of `data` (shape [rows, cols])
|
|
290
|
+
// gets its own F32 scale = max(|row|) / 7. Values are quantized to signed INT4
|
|
291
|
+
// in [-7, +7], stored as offset_binary uint4 [1, 15] (uint4 = qvar + 8) packed
|
|
292
|
+
// 2 nibbles per byte, low-nibble-first.
|
|
293
|
+
//
|
|
294
|
+
// Returns:
|
|
295
|
+
// quantized: Uint8Array of length rows * cols / 2 (assumes cols is even)
|
|
296
|
+
// scales: Float32Array of length rows
|
|
297
|
+
//
|
|
298
|
+
// The runtime side already handles this convention via `litert_axis_dequant`
|
|
299
|
+
// + `scaleSemantics: 'step'` + `storageEncoding: 'offset_binary'`. Manifest
|
|
300
|
+
// entries for these tensors should set sourceTransform.kind=litert_axis_dequant,
|
|
301
|
+
// sourceDtype=INT4, scaleSemantics=step, storageShape=[cols, rows] (transposed
|
|
302
|
+
// so quantAxis=0 indexes the per-row scales by output row).
|
|
303
|
+
export function quantizeToInt4PerRowSymmetric(f32Data, shape) {
|
|
304
|
+
if (!Array.isArray(shape) || shape.length !== 2) {
|
|
305
|
+
throw new Error('quantizeToInt4PerRowSymmetric requires a 2D shape, got ' + JSON.stringify(shape));
|
|
306
|
+
}
|
|
307
|
+
const [rows, cols] = shape;
|
|
308
|
+
if (!Number.isInteger(rows) || rows <= 0 || !Number.isInteger(cols) || cols <= 0) {
|
|
309
|
+
throw new Error('quantizeToInt4PerRowSymmetric: invalid shape ' + JSON.stringify(shape));
|
|
310
|
+
}
|
|
311
|
+
if ((cols & 1) !== 0) {
|
|
312
|
+
throw new Error('quantizeToInt4PerRowSymmetric: cols must be even for nibble packing, got ' + cols);
|
|
313
|
+
}
|
|
314
|
+
if (f32Data.length !== rows * cols) {
|
|
315
|
+
throw new Error('quantizeToInt4PerRowSymmetric: data length ' + f32Data.length + ' != rows*cols ' + (rows * cols));
|
|
316
|
+
}
|
|
317
|
+
const scales = new Float32Array(rows);
|
|
318
|
+
const quantized = new Uint8Array((rows * cols) >> 1);
|
|
319
|
+
for (let r = 0; r < rows; r++) {
|
|
320
|
+
const rowOff = r * cols;
|
|
321
|
+
let maxAbs = 0;
|
|
322
|
+
for (let c = 0; c < cols; c++) {
|
|
323
|
+
const v = Math.abs(f32Data[rowOff + c]);
|
|
324
|
+
if (v > maxAbs) maxAbs = v;
|
|
325
|
+
}
|
|
326
|
+
// Use scale_bound = 7 (signed range -8..+7 reachable, but symmetric uses |max|/7
|
|
327
|
+
// per MediaPipe quantization_util.reduce_precision symmetric path).
|
|
328
|
+
const scale = maxAbs > 0 ? maxAbs / 7 : 1;
|
|
329
|
+
scales[r] = scale;
|
|
330
|
+
const inv = 1 / scale;
|
|
331
|
+
for (let c = 0; c < cols; c += 2) {
|
|
332
|
+
const a = f32Data[rowOff + c];
|
|
333
|
+
const b = f32Data[rowOff + c + 1];
|
|
334
|
+
// round-half-to-even via Math.round (good enough for per-row INT4)
|
|
335
|
+
let qa = Math.round(a * inv);
|
|
336
|
+
let qb = Math.round(b * inv);
|
|
337
|
+
if (qa < -8) qa = -8; else if (qa > 7) qa = 7;
|
|
338
|
+
if (qb < -8) qb = -8; else if (qb > 7) qb = 7;
|
|
339
|
+
// offset_binary: stored = qvar + 8, range [0, 15]
|
|
340
|
+
quantized[(rowOff + c) >> 1] = ((qa + 8) & 0xf) | (((qb + 8) & 0xf) << 4);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return { quantized, scales };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export function dequantizeInt4PerRowSymmetric(quantized, scales, shape) {
|
|
347
|
+
const [rows, cols] = shape;
|
|
348
|
+
const out = new Float32Array(rows * cols);
|
|
349
|
+
for (let r = 0; r < rows; r++) {
|
|
350
|
+
const scale = scales[r];
|
|
351
|
+
const rowOff = r * cols;
|
|
352
|
+
for (let c = 0; c < cols; c += 2) {
|
|
353
|
+
const byte = quantized[(rowOff + c) >> 1];
|
|
354
|
+
const lo = (byte & 0xf) - 8;
|
|
355
|
+
const hi = ((byte >> 4) & 0xf) - 8;
|
|
356
|
+
out[rowOff + c] = lo * scale;
|
|
357
|
+
out[rowOff + c + 1] = hi * scale;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return out;
|
|
361
|
+
}
|
|
362
|
+
|
|
286
363
|
export function transposeF32(data, shape) {
|
|
287
364
|
const [rows, cols] = shape;
|
|
288
365
|
const transposed = new Float32Array(rows * cols);
|
package/src/debug/config.d.ts
CHANGED
|
@@ -68,10 +68,6 @@ export function getDecodeStep(): number;
|
|
|
68
68
|
export function shouldBreakOnAnomaly(): boolean;
|
|
69
69
|
export function setSilentMode(enabled: boolean): void;
|
|
70
70
|
export function isSilentMode(): boolean;
|
|
71
|
-
/** @deprecated Use setSilentMode instead */
|
|
72
|
-
export function setBenchmarkMode(enabled: boolean): void;
|
|
73
|
-
/** @deprecated Use isSilentMode instead */
|
|
74
|
-
export function isBenchmarkMode(): boolean;
|
|
75
71
|
export function enableModules(...modules: string[]): void;
|
|
76
72
|
export function disableModules(...modules: string[]): void;
|
|
77
73
|
export function resetModuleFilters(): void;
|
package/src/debug/config.js
CHANGED
|
@@ -48,7 +48,6 @@ const originalConsoleLog = console.log;
|
|
|
48
48
|
const originalConsoleDebug = console.debug;
|
|
49
49
|
const originalConsoleInfo = console.info;
|
|
50
50
|
const originalConsoleWarn = console.warn;
|
|
51
|
-
let warnedBenchmarkMode = false;
|
|
52
51
|
|
|
53
52
|
function requirePlainObject(value, label) {
|
|
54
53
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
@@ -309,22 +308,6 @@ export function isSilentMode() {
|
|
|
309
308
|
return silentMode;
|
|
310
309
|
}
|
|
311
310
|
|
|
312
|
-
export function setBenchmarkMode(enabled) {
|
|
313
|
-
if (!warnedBenchmarkMode) {
|
|
314
|
-
warnedBenchmarkMode = true;
|
|
315
|
-
originalConsoleWarn('[Doppler] setBenchmarkMode is deprecated; use setSilentMode instead.');
|
|
316
|
-
}
|
|
317
|
-
setSilentMode(enabled);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
export function isBenchmarkMode() {
|
|
321
|
-
if (!warnedBenchmarkMode) {
|
|
322
|
-
warnedBenchmarkMode = true;
|
|
323
|
-
originalConsoleWarn('[Doppler] isBenchmarkMode is deprecated; use isSilentMode instead.');
|
|
324
|
-
}
|
|
325
|
-
return isSilentMode();
|
|
326
|
-
}
|
|
327
|
-
|
|
328
311
|
export function enableModules(...modules) {
|
|
329
312
|
enabledModules = new Set(modules.map((m) => m.toLowerCase()));
|
|
330
313
|
console.log(`[Doppler] Enabled modules: ${modules.join(', ')}`);
|
package/src/debug/index.d.ts
CHANGED
|
@@ -55,27 +55,21 @@
|
|
|
55
55
|
|
|
56
56
|
export {
|
|
57
57
|
SIGNALS,
|
|
58
|
-
SignalType,
|
|
59
|
-
DonePayload,
|
|
60
58
|
signalDone,
|
|
61
59
|
signalResult,
|
|
62
60
|
signalError,
|
|
63
61
|
signalProgress,
|
|
64
62
|
} from './signals.js';
|
|
65
63
|
|
|
64
|
+
export type { SignalType, DonePayload } from './signals.js';
|
|
65
|
+
|
|
66
66
|
// ============================================================================
|
|
67
67
|
// Re-exports from config.js
|
|
68
68
|
// ============================================================================
|
|
69
69
|
|
|
70
70
|
export {
|
|
71
|
-
// Types and constants
|
|
72
71
|
LOG_LEVELS,
|
|
73
72
|
TRACE_CATEGORIES,
|
|
74
|
-
LogLevel,
|
|
75
|
-
LogLevelValue,
|
|
76
|
-
TraceCategory,
|
|
77
|
-
LogEntry,
|
|
78
|
-
// Configuration functions
|
|
79
73
|
setLogLevel,
|
|
80
74
|
getLogLevel,
|
|
81
75
|
setTrace,
|
|
@@ -88,14 +82,19 @@ export {
|
|
|
88
82
|
shouldBreakOnAnomaly,
|
|
89
83
|
setSilentMode,
|
|
90
84
|
isSilentMode,
|
|
91
|
-
setBenchmarkMode,
|
|
92
|
-
isBenchmarkMode,
|
|
93
85
|
enableModules,
|
|
94
86
|
disableModules,
|
|
95
87
|
resetModuleFilters,
|
|
96
88
|
setGPUDevice,
|
|
97
89
|
} from './config.js';
|
|
98
90
|
|
|
91
|
+
export type {
|
|
92
|
+
LogLevel,
|
|
93
|
+
LogLevelValue,
|
|
94
|
+
TraceCategory,
|
|
95
|
+
LogEntry,
|
|
96
|
+
} from './config.js';
|
|
97
|
+
|
|
99
98
|
// ============================================================================
|
|
100
99
|
// Re-exports from log.js
|
|
101
100
|
// ============================================================================
|
|
@@ -112,20 +111,15 @@ export { trace } from './trace.js';
|
|
|
112
111
|
// Re-exports from tensor.js
|
|
113
112
|
// ============================================================================
|
|
114
113
|
|
|
115
|
-
export {
|
|
116
|
-
|
|
114
|
+
export { tensor } from './tensor.js';
|
|
115
|
+
|
|
116
|
+
export type {
|
|
117
117
|
TensorStats,
|
|
118
118
|
TensorCompareResult,
|
|
119
119
|
TensorHealthResult,
|
|
120
120
|
TensorInspectOptions,
|
|
121
121
|
} from './tensor.js';
|
|
122
122
|
|
|
123
|
-
// ============================================================================
|
|
124
|
-
// Re-exports from perf.js
|
|
125
|
-
// ============================================================================
|
|
126
|
-
|
|
127
|
-
export { perf } from './perf.js';
|
|
128
|
-
|
|
129
123
|
// ============================================================================
|
|
130
124
|
// Re-exports from history.js
|
|
131
125
|
// ============================================================================
|
|
@@ -135,10 +129,24 @@ export {
|
|
|
135
129
|
clearLogHistory,
|
|
136
130
|
printLogSummary,
|
|
137
131
|
getDebugSnapshot,
|
|
138
|
-
LogHistoryFilter,
|
|
139
|
-
DebugSnapshot,
|
|
140
132
|
} from './history.js';
|
|
141
133
|
|
|
134
|
+
export type { LogHistoryFilter, DebugSnapshot } from './history.js';
|
|
135
|
+
|
|
136
|
+
// ============================================================================
|
|
137
|
+
// Re-exports from capture-policy.js
|
|
138
|
+
// ============================================================================
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
CAPTURE_LEVELS,
|
|
142
|
+
resolveCapturePolicy,
|
|
143
|
+
escalateCaptureLevel,
|
|
144
|
+
buildCaptureArtifact,
|
|
145
|
+
createEscalationPolicy,
|
|
146
|
+
createDefaultCaptureConfig,
|
|
147
|
+
validateCaptureConfig,
|
|
148
|
+
} from './capture-policy.js';
|
|
149
|
+
|
|
142
150
|
// ============================================================================
|
|
143
151
|
// Browser Console Global API
|
|
144
152
|
// ============================================================================
|
|
@@ -146,7 +154,6 @@ export {
|
|
|
146
154
|
import { log } from './log.js';
|
|
147
155
|
import { trace } from './trace.js';
|
|
148
156
|
import { tensor } from './tensor.js';
|
|
149
|
-
import { perf } from './perf.js';
|
|
150
157
|
import {
|
|
151
158
|
SIGNALS,
|
|
152
159
|
signalDone,
|
|
@@ -162,8 +169,6 @@ import {
|
|
|
162
169
|
isTraceEnabled,
|
|
163
170
|
setSilentMode,
|
|
164
171
|
isSilentMode,
|
|
165
|
-
setBenchmarkMode,
|
|
166
|
-
isBenchmarkMode,
|
|
167
172
|
} from './config.js';
|
|
168
173
|
import {
|
|
169
174
|
getLogHistory,
|
|
@@ -186,13 +191,9 @@ export interface DopplerDebugAPI {
|
|
|
186
191
|
// Tensor inspection
|
|
187
192
|
tensor: typeof tensor;
|
|
188
193
|
inspect: typeof tensor.inspect;
|
|
189
|
-
// Performance
|
|
190
|
-
perf: typeof perf;
|
|
191
194
|
// Other
|
|
192
195
|
setSilentMode: typeof setSilentMode;
|
|
193
196
|
isSilentMode: typeof isSilentMode;
|
|
194
|
-
setBenchmarkMode: typeof setBenchmarkMode;
|
|
195
|
-
isBenchmarkMode: typeof isBenchmarkMode;
|
|
196
197
|
// History
|
|
197
198
|
getLogHistory: typeof getLogHistory;
|
|
198
199
|
printLogSummary: typeof printLogSummary;
|
|
@@ -213,7 +214,6 @@ declare const _default: {
|
|
|
213
214
|
log: typeof log;
|
|
214
215
|
trace: typeof trace;
|
|
215
216
|
tensor: typeof tensor;
|
|
216
|
-
perf: typeof perf;
|
|
217
217
|
setLogLevel: typeof setLogLevel;
|
|
218
218
|
getLogLevel: typeof getLogLevel;
|
|
219
219
|
setTrace: typeof setTrace;
|
|
@@ -221,8 +221,6 @@ declare const _default: {
|
|
|
221
221
|
isTraceEnabled: typeof isTraceEnabled;
|
|
222
222
|
setSilentMode: typeof setSilentMode;
|
|
223
223
|
isSilentMode: typeof isSilentMode;
|
|
224
|
-
setBenchmarkMode: typeof setBenchmarkMode;
|
|
225
|
-
isBenchmarkMode: typeof isBenchmarkMode;
|
|
226
224
|
setGPUDevice: (device: GPUDevice) => void;
|
|
227
225
|
enableModules: (...modules: string[]) => void;
|
|
228
226
|
disableModules: (...modules: string[]) => void;
|
package/src/debug/index.js
CHANGED
|
@@ -42,8 +42,6 @@ export {
|
|
|
42
42
|
shouldBreakOnAnomaly,
|
|
43
43
|
setSilentMode,
|
|
44
44
|
isSilentMode,
|
|
45
|
-
setBenchmarkMode,
|
|
46
|
-
isBenchmarkMode,
|
|
47
45
|
enableModules,
|
|
48
46
|
disableModules,
|
|
49
47
|
resetModuleFilters,
|
|
@@ -82,12 +80,6 @@ export {
|
|
|
82
80
|
validateCaptureConfig,
|
|
83
81
|
} from './capture-policy.js';
|
|
84
82
|
|
|
85
|
-
// ============================================================================
|
|
86
|
-
// Re-exports from perf.js
|
|
87
|
-
// ============================================================================
|
|
88
|
-
|
|
89
|
-
export { perf } from './perf.js';
|
|
90
|
-
|
|
91
83
|
// ============================================================================
|
|
92
84
|
// Re-exports from history.js
|
|
93
85
|
// ============================================================================
|
|
@@ -106,7 +98,6 @@ export {
|
|
|
106
98
|
import { log } from './log.js';
|
|
107
99
|
import { trace } from './trace.js';
|
|
108
100
|
import { tensor } from './tensor.js';
|
|
109
|
-
import { perf } from './perf.js';
|
|
110
101
|
import {
|
|
111
102
|
SIGNALS,
|
|
112
103
|
signalDone,
|
|
@@ -124,8 +115,6 @@ import {
|
|
|
124
115
|
isTraceEnabled,
|
|
125
116
|
setSilentMode,
|
|
126
117
|
isSilentMode,
|
|
127
|
-
setBenchmarkMode,
|
|
128
|
-
isBenchmarkMode,
|
|
129
118
|
enableModules,
|
|
130
119
|
disableModules,
|
|
131
120
|
resetModuleFilters,
|
|
@@ -150,13 +139,9 @@ const DOPPLER_API = {
|
|
|
150
139
|
// Tensor inspection
|
|
151
140
|
tensor,
|
|
152
141
|
inspect: tensor.inspect.bind(tensor),
|
|
153
|
-
// Performance
|
|
154
|
-
perf,
|
|
155
142
|
// Other
|
|
156
143
|
setSilentMode,
|
|
157
144
|
isSilentMode,
|
|
158
|
-
setBenchmarkMode,
|
|
159
|
-
isBenchmarkMode,
|
|
160
145
|
// History
|
|
161
146
|
getLogHistory,
|
|
162
147
|
printLogSummary,
|
|
@@ -186,7 +171,6 @@ export default {
|
|
|
186
171
|
log,
|
|
187
172
|
trace,
|
|
188
173
|
tensor,
|
|
189
|
-
perf,
|
|
190
174
|
setLogLevel,
|
|
191
175
|
getLogLevel,
|
|
192
176
|
setTrace,
|
|
@@ -194,8 +178,6 @@ export default {
|
|
|
194
178
|
isTraceEnabled,
|
|
195
179
|
setSilentMode,
|
|
196
180
|
isSilentMode,
|
|
197
|
-
setBenchmarkMode,
|
|
198
|
-
isBenchmarkMode,
|
|
199
181
|
setGPUDevice,
|
|
200
182
|
enableModules,
|
|
201
183
|
disableModules,
|
package/src/debug/stats.d.ts
CHANGED
|
@@ -34,14 +34,6 @@ export interface BasicStats {
|
|
|
34
34
|
|
|
35
35
|
export declare function percentile(sorted: number[], p: number): number;
|
|
36
36
|
export declare function median(sorted: number[]): number;
|
|
37
|
-
export declare function removeOutliersIQR(values: number[], multiplier?: number): {
|
|
38
|
-
filtered: number[];
|
|
39
|
-
removed: number;
|
|
40
|
-
lower: number;
|
|
41
|
-
upper: number;
|
|
42
|
-
};
|
|
43
|
-
export declare function sampleStdDev(values: number[], meanValue: number): number;
|
|
44
|
-
export declare function confidenceInterval95(stdDev: number, n: number): number;
|
|
45
37
|
export declare function computeSampleStats(values: number[], options?: { outlierIqrMultiplier?: number }): SampleStats;
|
|
46
38
|
export declare function computeArrayStats(values: ArrayLike<number>, limit?: number): ArrayStats;
|
|
47
39
|
export declare function computeBasicStats(values: number[]): BasicStats;
|
package/src/debug/stats.js
CHANGED
|
@@ -16,7 +16,7 @@ export function median(sorted) {
|
|
|
16
16
|
: sorted[mid];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
function removeOutliersIQR(values, multiplier = 1.5) {
|
|
20
20
|
if (values.length < 4) return { filtered: values, removed: 0, lower: -Infinity, upper: Infinity };
|
|
21
21
|
const sorted = [...values].sort((a, b) => a - b);
|
|
22
22
|
const q1 = percentile(sorted, 25);
|
|
@@ -28,14 +28,14 @@ export function removeOutliersIQR(values, multiplier = 1.5) {
|
|
|
28
28
|
return { filtered, removed: values.length - filtered.length, lower, upper };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
function sampleStdDev(values, meanValue) {
|
|
32
32
|
const n = values.length;
|
|
33
33
|
if (n < 2) return 0;
|
|
34
34
|
const variance = values.reduce((sum, v) => sum + (v - meanValue) ** 2, 0) / (n - 1);
|
|
35
35
|
return Math.sqrt(variance);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
function confidenceInterval95(stdDev, n) {
|
|
39
39
|
if (n < 2) return 0;
|
|
40
40
|
const tValue = n >= 30 ? 1.96 : 2.0 + 3.0 / n;
|
|
41
41
|
return tValue * (stdDev / Math.sqrt(n));
|
package/src/debug/tensor.d.ts
CHANGED
|
@@ -75,10 +75,15 @@ export interface TensorSnapshot {
|
|
|
75
75
|
std: number;
|
|
76
76
|
};
|
|
77
77
|
sample: number[];
|
|
78
|
+
data?: number[];
|
|
78
79
|
hasNaN: boolean;
|
|
79
80
|
hasInf: boolean;
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
export interface TensorSnapshotOptions {
|
|
84
|
+
includeData?: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
82
87
|
// ============================================================================
|
|
83
88
|
// Tensor Inspection Interface
|
|
84
89
|
// ============================================================================
|
|
@@ -115,11 +120,13 @@ export declare const tensor: {
|
|
|
115
120
|
export declare function snapshotTensor(
|
|
116
121
|
buffer: GPUBuffer,
|
|
117
122
|
shape?: number[],
|
|
118
|
-
dtype?: string
|
|
123
|
+
dtype?: string,
|
|
124
|
+
options?: TensorSnapshotOptions
|
|
119
125
|
): Promise<TensorSnapshot>;
|
|
120
126
|
|
|
121
127
|
export declare function snapshotFromArray(
|
|
122
128
|
arr: Float32Array,
|
|
123
129
|
shape: number[],
|
|
124
|
-
dtype?: string
|
|
130
|
+
dtype?: string,
|
|
131
|
+
options?: TensorSnapshotOptions
|
|
125
132
|
): TensorSnapshot;
|
package/src/debug/tensor.js
CHANGED
|
@@ -212,7 +212,7 @@ export const tensor = {
|
|
|
212
212
|
},
|
|
213
213
|
};
|
|
214
214
|
|
|
215
|
-
export async function snapshotTensor(buffer, shape, dtype = 'f32') {
|
|
215
|
+
export async function snapshotTensor(buffer, shape, dtype = 'f32', options = {}) {
|
|
216
216
|
try {
|
|
217
217
|
if (
|
|
218
218
|
!gpuDevice
|
|
@@ -241,7 +241,7 @@ export async function snapshotTensor(buffer, shape, dtype = 'f32') {
|
|
|
241
241
|
staging.unmap();
|
|
242
242
|
staging.destroy();
|
|
243
243
|
const arr = decodeSnapshotData(data, dtype);
|
|
244
|
-
return snapshotFromArray(arr, shape ?? [arr.length], dtype);
|
|
244
|
+
return snapshotFromArray(arr, shape ?? [arr.length], dtype, options);
|
|
245
245
|
} catch (error) {
|
|
246
246
|
const message = error instanceof Error ? error.message : String(error);
|
|
247
247
|
return {
|
|
@@ -257,11 +257,14 @@ export async function snapshotTensor(buffer, shape, dtype = 'f32') {
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
export function snapshotFromArray(arr, shape, dtype = 'f32') {
|
|
260
|
+
export function snapshotFromArray(arr, shape, dtype = 'f32', options = {}) {
|
|
261
261
|
const numElements = shape.reduce((a, b) => a * b, 1);
|
|
262
262
|
const stats = computeArrayStats(arr, Math.min(arr.length, numElements));
|
|
263
|
+
const data = options.includeData === true
|
|
264
|
+
? Array.from(arr.slice(0, numElements))
|
|
265
|
+
: undefined;
|
|
263
266
|
|
|
264
|
-
|
|
267
|
+
const snapshot = {
|
|
265
268
|
ok: true,
|
|
266
269
|
error: null,
|
|
267
270
|
shape,
|
|
@@ -277,4 +280,8 @@ export function snapshotFromArray(arr, shape, dtype = 'f32') {
|
|
|
277
280
|
hasNaN: stats.nanCount > 0,
|
|
278
281
|
hasInf: stats.infCount > 0,
|
|
279
282
|
};
|
|
283
|
+
if (data) {
|
|
284
|
+
snapshot.data = data;
|
|
285
|
+
}
|
|
286
|
+
return snapshot;
|
|
280
287
|
}
|
package/src/debug/trace.js
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* Trace subsystem — records per-category trace entries into the shared logHistory.
|
|
3
3
|
*
|
|
4
4
|
* Trace entries share the global logHistory buffer and are subject to the same
|
|
5
|
-
* max-size limit (oldest-first eviction).
|
|
6
|
-
*
|
|
7
|
-
* per-run isolation; the history is global.
|
|
5
|
+
* max-size limit (oldest-first eviction). History is global; there is no
|
|
6
|
+
* automatic per-run isolation.
|
|
8
7
|
*/
|
|
9
8
|
import {
|
|
10
9
|
enabledTraceCategories,
|
|
@@ -174,15 +173,3 @@ export const trace = {
|
|
|
174
173
|
},
|
|
175
174
|
};
|
|
176
175
|
|
|
177
|
-
/**
|
|
178
|
-
* Remove all TRACE-level entries from the shared logHistory.
|
|
179
|
-
* Useful for isolating trace output between runs without clearing
|
|
180
|
-
* non-trace log entries.
|
|
181
|
-
*/
|
|
182
|
-
export function clearTraceEntries() {
|
|
183
|
-
for (let i = logHistory.length - 1; i >= 0; i--) {
|
|
184
|
-
if (typeof logHistory[i]?.level === 'string' && logHistory[i].level.startsWith('TRACE:')) {
|
|
185
|
-
logHistory.splice(i, 1);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|