@simulatte/doppler 0.1.5 → 0.1.7
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 +126 -0
- package/README.md +25 -17
- package/package.json +20 -4
- package/src/adapters/adapter-registry.js +12 -1
- package/src/adapters/lora-loader.js +23 -6
- package/src/bridge/extension-client.d.ts +5 -0
- package/src/bridge/extension-client.js +40 -0
- package/src/bridge/index.d.ts +2 -1
- package/src/bridge/index.js +6 -4
- package/src/browser/browser-converter.js +26 -1
- package/src/browser/file-picker.js +6 -0
- package/src/browser/safetensors-parser-browser.js +84 -1
- package/src/browser/shard-io-browser.js +2 -2
- package/src/browser/tensor-source-download.js +8 -2
- package/src/browser/tensor-source-http.d.ts +1 -0
- package/src/browser/tensor-source-http.js +5 -1
- package/src/client/doppler-api.browser.js +20 -4
- package/src/client/doppler-api.js +19 -3
- package/src/client/doppler-provider/generation.js +12 -0
- package/src/client/doppler-provider/model-manager.d.ts +10 -0
- package/src/client/doppler-provider/model-manager.js +91 -19
- package/src/client/doppler-provider/source-runtime.d.ts +2 -1
- package/src/client/doppler-provider/source-runtime.js +132 -13
- package/src/client/doppler-registry.json +8 -7
- package/src/config/backward-registry-loader.js +17 -2
- package/src/config/execution-v0-contract-check.js +113 -15
- package/src/config/kernel-path-contract-check.js +57 -29
- package/src/config/kernel-path-loader.js +5 -36
- package/src/config/kernels/kernel-ref-digests.js +39 -39
- package/src/config/kernels/registry.js +14 -1
- package/src/config/kernels/registry.json +49 -7
- package/src/config/loader.d.ts +1 -1
- package/src/config/loader.js +43 -4
- package/src/config/merge-contract-check.js +59 -4
- package/src/config/merge-helpers.js +128 -7
- package/src/config/merge.d.ts +1 -0
- package/src/config/merge.js +28 -0
- package/src/config/param-validator.js +47 -2
- package/src/config/presets/kernel-paths/{gemma2-q4k-dequant-f32a.json → gemma2-q4k-dequant-f32a-nosubgroups.json} +3 -3
- package/src/config/presets/kernel-paths/gemma3-f16-fused-f32a-online-streamingprefill.json +223 -0
- package/src/config/presets/kernel-paths/{gemma3-q4k-dequant-f32a.json → gemma3-q4k-dequant-f32a-nosubgroups.json} +3 -3
- package/src/config/presets/kernel-paths/registry.json +29 -8
- package/src/config/presets/models/gemma2.json +2 -2
- package/src/config/presets/models/qwen3.json +9 -2
- package/src/config/presets/models/transformer.json +5 -0
- package/src/config/presets/runtime/experiments/bench/gemma3-bench-q4k.json +1 -1
- package/src/config/presets/runtime/experiments/debug/gemma3-debug-q4k.json +1 -1
- package/src/config/presets/runtime/experiments/verify/gemma3-verify.json +1 -1
- package/src/config/presets/runtime/kernels/dequant-f16-q4k.json +6 -13
- package/src/config/presets/runtime/kernels/dequant-f32-q4k.json +6 -13
- package/src/config/presets/runtime/kernels/embeddinggemma-q4k-dequant-f32a.json +37 -0
- package/src/config/presets/runtime/kernels/fused-q4k.json +6 -13
- package/src/config/presets/runtime/kernels/gemma2-q4k-dequant-f16a.json +33 -0
- package/src/config/presets/runtime/kernels/gemma2-q4k-dequant-f32a-nosubgroups.json +33 -0
- package/src/config/presets/runtime/kernels/gemma2-q4k-fused-f32a.json +33 -0
- package/src/config/presets/runtime/kernels/safe-q4k.json +6 -13
- package/src/config/presets/runtime/platform/metal-apple-q4k.json +1 -1
- package/src/config/required-inference-fields-contract-check.js +6 -0
- package/src/config/runtime.js +6 -1
- package/src/config/schema/debug.schema.d.ts +5 -0
- package/src/config/schema/doppler.schema.js +16 -21
- package/src/config/schema/inference-defaults.schema.js +6 -3
- package/src/config/schema/inference.schema.d.ts +9 -0
- package/src/config/schema/kernel-path.schema.d.ts +11 -1
- package/src/config/schema/kernel-thresholds.schema.js +12 -4
- package/src/config/schema/manifest.schema.d.ts +8 -1
- package/src/config/schema/manifest.schema.js +19 -3
- package/src/config/training-defaults.js +30 -22
- package/src/converter/conversion-plan.js +94 -9
- package/src/converter/core.d.ts +7 -0
- package/src/converter/core.js +14 -9
- package/src/converter/execution-v0-manifest.js +4 -1
- package/src/converter/index.d.ts +1 -0
- package/src/converter/index.js +1 -0
- package/src/converter/manifest-inference.js +43 -12
- package/src/converter/parsers/diffusion.js +0 -3
- package/src/converter/quantization-info.js +35 -15
- package/src/converter/rope-config.js +42 -0
- package/src/converter/shard-packer.d.ts +1 -1
- package/src/converter/shard-packer.js +4 -1
- package/src/debug/config.js +123 -11
- package/src/debug/signals.js +7 -1
- package/src/debug/tensor.d.ts +2 -0
- package/src/debug/tensor.js +13 -2
- package/src/distribution/p2p-control-plane.js +52 -12
- package/src/distribution/p2p-observability.js +43 -7
- package/src/distribution/p2p-webrtc-browser.js +20 -0
- package/src/distribution/shard-delivery.js +77 -26
- package/src/formats/gguf/types.js +33 -16
- package/src/formats/rdrr/groups.d.ts +12 -4
- package/src/formats/rdrr/groups.js +3 -6
- package/src/formats/rdrr/parsing.js +39 -2
- package/src/formats/rdrr/types.d.ts +2 -1
- package/src/gpu/command-recorder.js +86 -61
- package/src/gpu/device.d.ts +1 -0
- package/src/gpu/device.js +131 -19
- package/src/gpu/kernel-tuner/benchmarks.js +326 -316
- package/src/gpu/kernel-tuner/cache.js +71 -4
- package/src/gpu/kernel-tuner/tuner.js +22 -4
- package/src/gpu/kernels/attention.js +113 -34
- package/src/gpu/kernels/backward/adam.js +62 -58
- package/src/gpu/kernels/backward/attention_backward.js +257 -169
- package/src/gpu/kernels/backward/conv2d_backward.js +14 -1
- package/src/gpu/kernels/bias_add.wgsl +8 -6
- package/src/gpu/kernels/bias_add_f16.wgsl +8 -5
- package/src/gpu/kernels/cast.js +191 -149
- package/src/gpu/kernels/check-stop.js +33 -44
- package/src/gpu/kernels/conv2d.js +27 -17
- package/src/gpu/kernels/conv2d.wgsl +7 -8
- package/src/gpu/kernels/conv2d_f16.wgsl +7 -8
- package/src/gpu/kernels/cross_entropy_loss.js +21 -15
- package/src/gpu/kernels/depthwise_conv2d.js +37 -26
- package/src/gpu/kernels/depthwise_conv2d.wgsl +6 -9
- package/src/gpu/kernels/depthwise_conv2d_f16.wgsl +6 -9
- package/src/gpu/kernels/dequant.js +178 -126
- package/src/gpu/kernels/energy.d.ts +3 -21
- package/src/gpu/kernels/energy.js +111 -88
- package/src/gpu/kernels/feature-check.js +1 -1
- package/src/gpu/kernels/fused_ffn.js +84 -65
- package/src/gpu/kernels/fused_matmul_residual.js +56 -33
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +62 -45
- package/src/gpu/kernels/gather.js +33 -15
- package/src/gpu/kernels/gelu.js +19 -11
- package/src/gpu/kernels/grouped_pointwise_conv2d.js +34 -23
- package/src/gpu/kernels/grouped_pointwise_conv2d.wgsl +6 -9
- package/src/gpu/kernels/grouped_pointwise_conv2d_f16.wgsl +6 -9
- package/src/gpu/kernels/groupnorm.js +34 -23
- package/src/gpu/kernels/kv-quantize.js +5 -2
- package/src/gpu/kernels/layernorm.js +35 -19
- package/src/gpu/kernels/logit-merge.js +5 -3
- package/src/gpu/kernels/matmul.js +83 -39
- package/src/gpu/kernels/modulate.js +23 -15
- package/src/gpu/kernels/moe.js +221 -175
- package/src/gpu/kernels/pixel_shuffle.js +22 -14
- package/src/gpu/kernels/pixel_shuffle.wgsl +4 -5
- package/src/gpu/kernels/pixel_shuffle_f16.wgsl +4 -5
- package/src/gpu/kernels/relu.js +31 -10
- package/src/gpu/kernels/relu.wgsl +2 -1
- package/src/gpu/kernels/relu_f16.wgsl +2 -1
- package/src/gpu/kernels/repeat_channels.js +25 -17
- package/src/gpu/kernels/repeat_channels.wgsl +4 -5
- package/src/gpu/kernels/repeat_channels_f16.wgsl +4 -5
- package/src/gpu/kernels/residual.js +69 -23
- package/src/gpu/kernels/residual.wgsl +6 -3
- package/src/gpu/kernels/residual_f16.wgsl +2 -1
- package/src/gpu/kernels/residual_f16_vec4.wgsl +2 -1
- package/src/gpu/kernels/residual_vec4.wgsl +2 -1
- package/src/gpu/kernels/rmsnorm.js +96 -28
- package/src/gpu/kernels/rmsnorm.wgsl +14 -6
- package/src/gpu/kernels/rmsnorm_f16.wgsl +10 -2
- package/src/gpu/kernels/rope.d.ts +2 -0
- package/src/gpu/kernels/rope.js +14 -1
- package/src/gpu/kernels/rope.wgsl +56 -40
- package/src/gpu/kernels/sample.js +27 -38
- package/src/gpu/kernels/sana_linear_attention.js +19 -12
- package/src/gpu/kernels/sana_linear_attention_apply.wgsl +4 -5
- package/src/gpu/kernels/sana_linear_attention_apply_f16.wgsl +4 -5
- package/src/gpu/kernels/sana_linear_attention_summary.wgsl +4 -0
- package/src/gpu/kernels/sana_linear_attention_summary_f16.wgsl +4 -0
- package/src/gpu/kernels/scale.js +18 -11
- package/src/gpu/kernels/shader-cache.js +4 -2
- package/src/gpu/kernels/silu.d.ts +1 -0
- package/src/gpu/kernels/silu.js +148 -82
- package/src/gpu/kernels/silu.wgsl +19 -9
- package/src/gpu/kernels/silu_f16.wgsl +19 -9
- package/src/gpu/kernels/softmax.js +44 -25
- package/src/gpu/kernels/split_qkv.js +23 -13
- package/src/gpu/kernels/transpose.js +31 -10
- package/src/gpu/kernels/transpose.wgsl +6 -5
- package/src/gpu/kernels/upsample2d.js +22 -13
- package/src/gpu/kernels/upsample2d.wgsl +6 -9
- package/src/gpu/kernels/upsample2d_f16.wgsl +6 -9
- package/src/gpu/kernels/utils.js +35 -13
- package/src/gpu/partitioned-buffer-pool.js +10 -2
- package/src/gpu/perf-guards.js +2 -9
- package/src/gpu/profiler.js +27 -22
- package/src/gpu/readback-utils.d.ts +16 -0
- package/src/gpu/readback-utils.js +41 -0
- package/src/gpu/submit-tracker.js +13 -0
- package/src/gpu/uniform-cache.d.ts +1 -0
- package/src/gpu/uniform-cache.js +30 -9
- package/src/hotswap/intent-bundle.js +6 -0
- package/src/hotswap/manifest.d.ts +10 -1
- package/src/hotswap/manifest.js +12 -2
- package/src/hotswap/runtime.js +30 -8
- package/src/index-browser.d.ts +44 -0
- package/src/index-browser.js +14 -0
- package/src/inference/browser-harness-contract-helpers.d.ts +5 -0
- package/src/inference/browser-harness-contract-helpers.js +28 -0
- package/src/inference/browser-harness-diffusion-energy-suites.d.ts +2 -0
- package/src/inference/browser-harness-diffusion-energy-suites.js +269 -0
- package/src/inference/browser-harness-model-helpers.d.ts +16 -0
- package/src/inference/browser-harness-model-helpers.js +217 -0
- package/src/inference/browser-harness-report-helpers.d.ts +7 -0
- package/src/inference/browser-harness-report-helpers.js +42 -0
- package/src/inference/browser-harness-runtime-helpers.d.ts +61 -0
- package/src/inference/browser-harness-runtime-helpers.js +415 -0
- package/src/inference/browser-harness-suite-helpers.d.ts +28 -0
- package/src/inference/browser-harness-suite-helpers.js +268 -0
- package/src/inference/browser-harness-text-helpers.d.ts +27 -0
- package/src/inference/browser-harness-text-helpers.js +788 -0
- package/src/inference/browser-harness.d.ts +6 -0
- package/src/inference/browser-harness.js +130 -1950
- package/src/inference/kv-cache/base.js +140 -94
- package/src/inference/kv-cache/tiered.js +5 -3
- package/src/inference/moe-router.js +88 -56
- package/src/inference/multi-model-network.js +5 -3
- package/src/inference/network-evolution.d.ts +11 -2
- package/src/inference/network-evolution.js +20 -21
- package/src/inference/pipelines/context.d.ts +3 -0
- package/src/inference/pipelines/context.js +142 -2
- package/src/inference/pipelines/diffusion/helpers.js +7 -2
- package/src/inference/pipelines/diffusion/pipeline.js +17 -7
- package/src/inference/pipelines/diffusion/sd3-transformer.js +10 -10
- package/src/inference/pipelines/diffusion/text-encoder-gpu.d.ts +5 -0
- package/src/inference/pipelines/diffusion/text-encoder-gpu.js +27 -15
- package/src/inference/pipelines/diffusion/vae.js +3 -7
- package/src/inference/pipelines/energy/pipeline.js +27 -21
- package/src/inference/pipelines/energy/quintel.d.ts +5 -0
- package/src/inference/pipelines/energy/quintel.js +11 -0
- package/src/inference/pipelines/energy-head/row-head-pipeline.js +17 -13
- package/src/inference/pipelines/structured/json-head-pipeline.js +26 -11
- package/src/inference/pipelines/text/attention/projections.js +151 -101
- package/src/inference/pipelines/text/attention/record.js +73 -10
- package/src/inference/pipelines/text/attention/run.js +73 -10
- package/src/inference/pipelines/text/chat-format.js +25 -1
- package/src/inference/pipelines/text/config.d.ts +4 -0
- package/src/inference/pipelines/text/config.js +71 -5
- package/src/inference/pipelines/text/embed.js +2 -8
- package/src/inference/pipelines/text/execution-plan.js +64 -50
- package/src/inference/pipelines/text/execution-v0-contract-helpers.d.ts +59 -0
- package/src/inference/pipelines/text/execution-v0-contract-helpers.js +937 -0
- package/src/inference/pipelines/text/execution-v0-runtime-builders.d.ts +15 -0
- package/src/inference/pipelines/text/execution-v0-runtime-builders.js +279 -0
- package/src/inference/pipelines/text/execution-v0.js +78 -1002
- package/src/inference/pipelines/text/ffn/standard.js +3 -0
- package/src/inference/pipelines/text/generator-steps.d.ts +46 -0
- package/src/inference/pipelines/text/generator-steps.js +298 -207
- package/src/inference/pipelines/text/generator.js +6 -23
- package/src/inference/pipelines/text/init.d.ts +4 -0
- package/src/inference/pipelines/text/init.js +134 -29
- package/src/inference/pipelines/text/kernel-path-auto-select.js +2 -0
- package/src/inference/pipelines/text/kernel-trace.d.ts +2 -0
- package/src/inference/pipelines/text/kernel-trace.js +6 -0
- package/src/inference/pipelines/text/layer.js +14 -9
- package/src/inference/pipelines/text/linear-attention.d.ts +10 -0
- package/src/inference/pipelines/text/linear-attention.js +80 -6
- package/src/inference/pipelines/text/logits/gpu.js +10 -5
- package/src/inference/pipelines/text/logits/index.js +10 -11
- package/src/inference/pipelines/text/logits/utils.d.ts +7 -0
- package/src/inference/pipelines/text/logits/utils.js +9 -0
- package/src/inference/pipelines/text/lora-apply.js +50 -32
- package/src/inference/pipelines/text/model-load.js +279 -104
- package/src/inference/pipelines/text/moe-cache.js +5 -4
- package/src/inference/pipelines/text/moe-cpu-gptoss.js +74 -69
- package/src/inference/pipelines/text/moe-cpu.js +42 -38
- package/src/inference/pipelines/text/moe-gpu.js +110 -86
- package/src/inference/pipelines/text/ops.js +90 -90
- package/src/inference/pipelines/text/probes.js +9 -9
- package/src/inference/pipelines/text/weights.js +17 -7
- package/src/inference/pipelines/text.js +17 -1
- package/src/inference/speculative.d.ts +2 -2
- package/src/inference/speculative.js +4 -18
- package/src/inference/test-harness.d.ts +1 -1
- package/src/inference/test-harness.js +15 -5
- package/src/inference/tokenizer.d.ts +0 -5
- package/src/inference/tokenizer.js +4 -23
- package/src/inference/tokenizers/bpe.js +9 -0
- package/src/inference/tokenizers/bundled.js +176 -33
- package/src/inference/tokenizers/sentencepiece.js +12 -0
- package/src/loader/doppler-loader.js +38 -22
- package/src/loader/dtype-utils.js +3 -44
- package/src/loader/embedding-loader.js +7 -3
- package/src/loader/experts/expert-cache.js +13 -6
- package/src/loader/experts/expert-loader.js +10 -6
- package/src/loader/final-weights-loader.js +8 -4
- package/src/loader/layer-loader.js +2 -1
- package/src/loader/loader-state.js +2 -2
- package/src/loader/memory-monitor.js +8 -0
- package/src/loader/multi-model-loader.d.ts +14 -0
- package/src/loader/multi-model-loader.js +70 -24
- package/src/loader/shard-cache.js +81 -12
- package/src/loader/shard-resolver.js +25 -3
- package/src/loader/tensors/tensor-loader.js +209 -144
- package/src/loader/tensors/tensor-reader.js +76 -19
- package/src/loader/weight-downcast.js +1 -1
- package/src/memory/buffer-pool.d.ts +9 -1
- package/src/memory/buffer-pool.js +109 -44
- package/src/memory/unified-detect.js +1 -1
- package/src/rules/inference/kernel-path.rules.json +24 -8
- package/src/rules/rule-registry.js +25 -1
- package/src/rules/tooling/command-runtime.rules.json +18 -0
- package/src/storage/backends/opfs-store.js +68 -24
- package/src/storage/downloader.js +364 -83
- package/src/storage/index.d.ts +3 -0
- package/src/storage/index.js +3 -0
- package/src/storage/preflight.d.ts +2 -2
- package/src/storage/preflight.js +24 -2
- package/src/storage/quickstart-downloader.js +11 -5
- package/src/storage/registry.js +10 -4
- package/src/storage/reports.js +1 -1
- package/src/storage/shard-manager.d.ts +15 -1
- package/src/storage/shard-manager.js +51 -3
- package/src/storage/source-artifact-store.d.ts +52 -0
- package/src/storage/source-artifact-store.js +234 -0
- package/src/tooling/command-api-constants.d.ts +9 -0
- package/src/tooling/command-api-constants.js +9 -0
- package/src/tooling/command-api-family-normalizers.d.ts +9 -0
- package/src/tooling/command-api-family-normalizers.js +343 -0
- package/src/tooling/command-api-helpers.d.ts +25 -0
- package/src/tooling/command-api-helpers.js +262 -0
- package/src/tooling/command-api.d.ts +27 -1
- package/src/tooling/command-api.js +26 -473
- package/src/tooling/command-envelope.js +4 -1
- package/src/tooling/command-runner-shared.js +52 -18
- package/src/tooling/lean-execution-contract.js +150 -3
- package/src/tooling/node-browser-command-runner.d.ts +4 -0
- package/src/tooling/node-browser-command-runner.js +218 -273
- package/src/tooling/node-command-runner.js +44 -3
- package/src/tooling/node-converter.js +27 -1
- package/src/tooling/node-source-runtime.d.ts +1 -1
- package/src/tooling/node-source-runtime.js +84 -3
- package/src/tooling/node-webgpu.js +30 -105
- package/src/tooling/opfs-cache.js +21 -4
- package/src/tooling/runtime-input-composition.d.ts +38 -0
- package/src/tooling/runtime-input-composition.js +86 -0
- package/src/tooling/source-runtime-bundle.d.ts +40 -5
- package/src/tooling/source-runtime-bundle.js +261 -34
- package/src/tooling/source-runtime-materializer.d.ts +6 -0
- package/src/tooling/source-runtime-materializer.js +93 -0
- package/src/training/attention-backward.js +32 -17
- package/src/training/autograd.js +80 -52
- package/src/training/checkpoint-watch.d.ts +8 -0
- package/src/training/checkpoint-watch.js +139 -0
- package/src/training/checkpoint.d.ts +6 -1
- package/src/training/checkpoint.js +46 -7
- package/src/training/clip.js +2 -1
- package/src/training/datasets/token-batch.js +20 -8
- package/src/training/distillation/artifacts.d.ts +71 -0
- package/src/training/distillation/artifacts.js +132 -0
- package/src/training/distillation/checkpoint-watch.d.ts +10 -0
- package/src/training/distillation/checkpoint-watch.js +58 -0
- package/src/training/distillation/dataset.d.ts +59 -0
- package/src/training/distillation/dataset.js +337 -0
- package/src/training/distillation/eval.d.ts +34 -0
- package/src/training/distillation/eval.js +310 -0
- package/src/training/distillation/index.d.ts +29 -0
- package/src/training/distillation/index.js +29 -0
- package/src/training/distillation/runtime.d.ts +20 -0
- package/src/training/distillation/runtime.js +121 -0
- package/src/training/distillation/scoreboard.d.ts +6 -0
- package/src/training/distillation/scoreboard.js +8 -0
- package/src/training/distillation/stage-a.d.ts +45 -0
- package/src/training/distillation/stage-a.js +338 -0
- package/src/training/distillation/stage-b.d.ts +24 -0
- package/src/training/distillation/stage-b.js +20 -0
- package/src/training/distillation/student-fixture.d.ts +22 -0
- package/src/training/distillation/student-fixture.js +846 -0
- package/src/training/distillation/suite-data.d.ts +45 -0
- package/src/training/distillation/suite-data.js +189 -0
- package/src/training/index.d.ts +10 -0
- package/src/training/index.js +10 -0
- package/src/training/lora-pipeline.d.ts +40 -0
- package/src/training/lora-pipeline.js +793 -0
- package/src/training/lora.js +26 -12
- package/src/training/loss.js +5 -6
- package/src/training/objectives/cross_entropy.js +2 -5
- package/src/training/objectives/distill_kd.js +4 -8
- package/src/training/objectives/distill_triplet.js +4 -8
- package/src/training/objectives/ul_stage2_base.js +4 -8
- package/src/training/operator-artifacts.d.ts +62 -0
- package/src/training/operator-artifacts.js +140 -0
- package/src/training/operator-command.d.ts +5 -0
- package/src/training/operator-command.js +455 -0
- package/src/training/operator-eval.d.ts +48 -0
- package/src/training/operator-eval.js +230 -0
- package/src/training/operator-scoreboard.d.ts +5 -0
- package/src/training/operator-scoreboard.js +44 -0
- package/src/training/optimizer.js +19 -7
- package/src/training/runner.d.ts +52 -0
- package/src/training/runner.js +31 -5
- package/src/training/suite.d.ts +112 -0
- package/src/training/suite.js +24 -984
- package/src/training/tensor-factory.d.ts +9 -0
- package/src/training/tensor-factory.js +13 -0
- package/src/training/trainer.js +3 -5
- package/src/training/ul_dataset.js +3 -5
- package/src/training/workloads.d.ts +164 -0
- package/src/training/workloads.js +530 -0
- package/src/version.js +1 -1
- package/tools/convert-safetensors-node.js +22 -16
- package/tools/doppler-cli.js +179 -63
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
export function buildSuiteSummary(suiteName, results, startTimeMs) {
|
|
2
|
+
let passed = 0;
|
|
3
|
+
let failed = 0;
|
|
4
|
+
let skipped = 0;
|
|
5
|
+
const safeResults = Array.isArray(results) ? results : [];
|
|
6
|
+
for (const result of safeResults) {
|
|
7
|
+
if (result.skipped) {
|
|
8
|
+
skipped++;
|
|
9
|
+
} else if (result.passed) {
|
|
10
|
+
passed++;
|
|
11
|
+
} else {
|
|
12
|
+
failed++;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const duration = Math.max(0, performance.now() - (Number.isFinite(startTimeMs) ? startTimeMs : performance.now()));
|
|
16
|
+
return { suite: suiteName, passed, failed, skipped, duration, results: safeResults };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function normalizeCacheMode(value) {
|
|
20
|
+
return value === 'cold' || value === 'warm' ? value : 'warm';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function normalizeLoadMode(value, hasModelUrl) {
|
|
24
|
+
if (value === 'opfs' || value === 'http' || value === 'memory') {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return hasModelUrl ? 'http' : 'opfs';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function normalizeWorkloadType(value) {
|
|
31
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
32
|
+
return normalized || null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function safeStatsValue(value) {
|
|
36
|
+
return Number.isFinite(value) ? Number(value) : 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function calculateRatePerSecond(count, durationMs) {
|
|
40
|
+
const safeCount = safeStatsValue(count);
|
|
41
|
+
const safeDurationMs = safeStatsValue(durationMs);
|
|
42
|
+
if (safeCount <= 0 || safeDurationMs <= 0) return 0;
|
|
43
|
+
return Number(((safeCount * 1000) / safeDurationMs).toFixed(2));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function buildDiffusionPerformanceArtifact({
|
|
47
|
+
warmupRuns,
|
|
48
|
+
timedRuns,
|
|
49
|
+
width,
|
|
50
|
+
height,
|
|
51
|
+
steps,
|
|
52
|
+
guidanceScale,
|
|
53
|
+
avgPrefillTokens,
|
|
54
|
+
avgDecodeTokens,
|
|
55
|
+
cpuStats,
|
|
56
|
+
gpuStats,
|
|
57
|
+
}) {
|
|
58
|
+
const cpuPrefillMs = safeStatsValue(cpuStats?.prefillMs?.median);
|
|
59
|
+
const cpuDenoiseMs = safeStatsValue(cpuStats?.denoiseMs?.median);
|
|
60
|
+
const cpuVaeMs = safeStatsValue(cpuStats?.vaeMs?.median);
|
|
61
|
+
const cpuTotalMs = safeStatsValue(cpuStats?.totalMs?.median);
|
|
62
|
+
const gpuPrefillMs = safeStatsValue(gpuStats?.prefillMs?.median);
|
|
63
|
+
const gpuDenoiseMs = safeStatsValue(gpuStats?.denoiseMs?.median);
|
|
64
|
+
const gpuVaeMs = safeStatsValue(gpuStats?.vaeMs?.median);
|
|
65
|
+
const gpuTotalMs = safeStatsValue(gpuStats?.totalMs?.median);
|
|
66
|
+
const decodeStepsPerSec = calculateRatePerSecond(steps, cpuDenoiseMs);
|
|
67
|
+
const decodeTokensPerSec = calculateRatePerSecond(avgDecodeTokens, cpuDenoiseMs);
|
|
68
|
+
const prefillTokensPerSec = calculateRatePerSecond(avgPrefillTokens, cpuPrefillMs);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
schemaVersion: 1,
|
|
72
|
+
warmupRuns,
|
|
73
|
+
timedRuns,
|
|
74
|
+
shape: {
|
|
75
|
+
width,
|
|
76
|
+
height,
|
|
77
|
+
},
|
|
78
|
+
scheduler: {
|
|
79
|
+
steps,
|
|
80
|
+
guidanceScale,
|
|
81
|
+
},
|
|
82
|
+
cpu: {
|
|
83
|
+
totalMs: cpuTotalMs,
|
|
84
|
+
prefillMs: cpuPrefillMs,
|
|
85
|
+
denoiseMs: cpuDenoiseMs,
|
|
86
|
+
vaeMs: cpuVaeMs,
|
|
87
|
+
},
|
|
88
|
+
gpu: {
|
|
89
|
+
available: gpuStats?.available === true,
|
|
90
|
+
totalMs: gpuStats?.available === true ? gpuTotalMs : null,
|
|
91
|
+
prefillMs: gpuStats?.available === true ? gpuPrefillMs : null,
|
|
92
|
+
denoiseMs: gpuStats?.available === true ? gpuDenoiseMs : null,
|
|
93
|
+
vaeMs: gpuStats?.available === true ? gpuVaeMs : null,
|
|
94
|
+
},
|
|
95
|
+
throughput: {
|
|
96
|
+
prefillTokensPerSec,
|
|
97
|
+
decodeTokensPerSec,
|
|
98
|
+
decodeStepsPerSec,
|
|
99
|
+
},
|
|
100
|
+
tokens: {
|
|
101
|
+
avgPrefillTokens: safeStatsValue(avgPrefillTokens),
|
|
102
|
+
avgDecodeTokens: safeStatsValue(avgDecodeTokens),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function assertDiffusionPerformanceArtifact(metrics, contextLabel = 'diffusion') {
|
|
108
|
+
const artifact = metrics?.performanceArtifact;
|
|
109
|
+
if (!artifact || typeof artifact !== 'object') {
|
|
110
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact is required.`);
|
|
111
|
+
}
|
|
112
|
+
if (artifact.schemaVersion !== 1) {
|
|
113
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.schemaVersion must be 1.`);
|
|
114
|
+
}
|
|
115
|
+
if (!Number.isInteger(artifact.warmupRuns) || artifact.warmupRuns < 0) {
|
|
116
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.warmupRuns must be a non-negative integer.`);
|
|
117
|
+
}
|
|
118
|
+
if (!Number.isInteger(artifact.timedRuns) || artifact.timedRuns < 1) {
|
|
119
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.timedRuns must be a positive integer.`);
|
|
120
|
+
}
|
|
121
|
+
if (!Number.isFinite(artifact?.cpu?.prefillMs)) {
|
|
122
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.cpu.prefillMs must be finite.`);
|
|
123
|
+
}
|
|
124
|
+
if (!Number.isFinite(artifact?.cpu?.denoiseMs)) {
|
|
125
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.cpu.denoiseMs must be finite.`);
|
|
126
|
+
}
|
|
127
|
+
if (!Number.isFinite(artifact?.cpu?.vaeMs)) {
|
|
128
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.cpu.vaeMs must be finite.`);
|
|
129
|
+
}
|
|
130
|
+
if (!Number.isFinite(artifact?.cpu?.totalMs)) {
|
|
131
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.cpu.totalMs must be finite.`);
|
|
132
|
+
}
|
|
133
|
+
if (!Number.isFinite(artifact?.throughput?.decodeStepsPerSec)) {
|
|
134
|
+
throw new Error(`${contextLabel}: metrics.performanceArtifact.throughput.decodeStepsPerSec must be finite.`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function formatMetricNumber(value, fallback = 0, digits = 2) {
|
|
139
|
+
const numericValue = Number(value);
|
|
140
|
+
if (!Number.isFinite(numericValue)) return fallback;
|
|
141
|
+
return Number(numericValue.toFixed(digits));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function toTimingNumber(value, fallback = 0) {
|
|
145
|
+
return formatMetricNumber(value, fallback, 2);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function safeToFixed(value, fallback = 0, digits = 2) {
|
|
149
|
+
return formatMetricNumber(value, fallback, digits);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function sampleTimingNumber(stats, key, fallback = 0) {
|
|
153
|
+
return formatMetricNumber(stats?.[key], fallback, 2);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function buildCanonicalTiming(overrides = {}) {
|
|
157
|
+
const cacheMode = normalizeCacheMode(overrides.cacheMode);
|
|
158
|
+
const modelLoadMs = toTimingNumber(overrides.modelLoadMs, 0);
|
|
159
|
+
const prefillMs = toTimingNumber(overrides.prefillMs, 0);
|
|
160
|
+
const decodeMs = toTimingNumber(overrides.decodeMs, 0);
|
|
161
|
+
const decodeMsPerTokenP50 = Number.isFinite(overrides.decodeMsPerTokenP50)
|
|
162
|
+
? toTimingNumber(overrides.decodeMsPerTokenP50)
|
|
163
|
+
: null;
|
|
164
|
+
const decodeMsPerTokenP95 = Number.isFinite(overrides.decodeMsPerTokenP95)
|
|
165
|
+
? toTimingNumber(overrides.decodeMsPerTokenP95)
|
|
166
|
+
: null;
|
|
167
|
+
const decodeMsPerTokenP99 = Number.isFinite(overrides.decodeMsPerTokenP99)
|
|
168
|
+
? toTimingNumber(overrides.decodeMsPerTokenP99)
|
|
169
|
+
: null;
|
|
170
|
+
const decodeTokensPerSec = Number.isFinite(overrides.decodeTokensPerSec)
|
|
171
|
+
? toTimingNumber(overrides.decodeTokensPerSec)
|
|
172
|
+
: null;
|
|
173
|
+
const prefillTokensPerSec = Number.isFinite(overrides.prefillTokensPerSec)
|
|
174
|
+
? toTimingNumber(overrides.prefillTokensPerSec)
|
|
175
|
+
: null;
|
|
176
|
+
const totalRunMs = toTimingNumber(
|
|
177
|
+
overrides.totalRunMs,
|
|
178
|
+
toTimingNumber(prefillMs + decodeMs)
|
|
179
|
+
);
|
|
180
|
+
const firstTokenMs = Number.isFinite(overrides.firstTokenMs)
|
|
181
|
+
? toTimingNumber(overrides.firstTokenMs)
|
|
182
|
+
: null;
|
|
183
|
+
const firstResponseMs = Number.isFinite(overrides.firstResponseMs)
|
|
184
|
+
? toTimingNumber(overrides.firstResponseMs)
|
|
185
|
+
: toTimingNumber(modelLoadMs + totalRunMs);
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
modelLoadMs,
|
|
189
|
+
firstTokenMs,
|
|
190
|
+
firstResponseMs,
|
|
191
|
+
prefillMs,
|
|
192
|
+
decodeMs,
|
|
193
|
+
decodeMsPerTokenP50,
|
|
194
|
+
decodeMsPerTokenP95,
|
|
195
|
+
decodeMsPerTokenP99,
|
|
196
|
+
decodeTokensPerSec,
|
|
197
|
+
prefillTokensPerSec,
|
|
198
|
+
totalRunMs,
|
|
199
|
+
cacheMode,
|
|
200
|
+
loadMode: overrides.loadMode,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function buildTimingDiagnostics(timing = {}, options = {}) {
|
|
205
|
+
const prefillSemantics = String(options.prefillSemantics || 'internal_prefill_phase');
|
|
206
|
+
const source = String(options.source || 'doppler');
|
|
207
|
+
const modelLoadMs = Number.isFinite(timing.modelLoadMs) ? toTimingNumber(timing.modelLoadMs) : null;
|
|
208
|
+
const firstTokenMs = Number.isFinite(timing.firstTokenMs) ? toTimingNumber(timing.firstTokenMs) : null;
|
|
209
|
+
const firstResponseMs = Number.isFinite(timing.firstResponseMs) ? toTimingNumber(timing.firstResponseMs) : null;
|
|
210
|
+
const prefillMs = Number.isFinite(timing.prefillMs) ? toTimingNumber(timing.prefillMs) : null;
|
|
211
|
+
const decodeMs = Number.isFinite(timing.decodeMs) ? toTimingNumber(timing.decodeMs) : null;
|
|
212
|
+
const totalRunMs = Number.isFinite(timing.totalRunMs) ? toTimingNumber(timing.totalRunMs) : null;
|
|
213
|
+
|
|
214
|
+
const firstResponseFromLoadAndFirstTokenMs = (
|
|
215
|
+
Number.isFinite(modelLoadMs) && Number.isFinite(firstTokenMs)
|
|
216
|
+
)
|
|
217
|
+
? toTimingNumber(modelLoadMs + firstTokenMs)
|
|
218
|
+
: null;
|
|
219
|
+
const runFromPrefillAndDecodeMs = (
|
|
220
|
+
Number.isFinite(prefillMs) && Number.isFinite(decodeMs)
|
|
221
|
+
)
|
|
222
|
+
? toTimingNumber(prefillMs + decodeMs)
|
|
223
|
+
: null;
|
|
224
|
+
|
|
225
|
+
const firstResponseResidualMs = (
|
|
226
|
+
Number.isFinite(firstResponseMs) && Number.isFinite(firstResponseFromLoadAndFirstTokenMs)
|
|
227
|
+
)
|
|
228
|
+
? toTimingNumber(firstResponseMs - firstResponseFromLoadAndFirstTokenMs)
|
|
229
|
+
: null;
|
|
230
|
+
const runResidualMs = (
|
|
231
|
+
Number.isFinite(totalRunMs) && Number.isFinite(runFromPrefillAndDecodeMs)
|
|
232
|
+
)
|
|
233
|
+
? toTimingNumber(totalRunMs - runFromPrefillAndDecodeMs)
|
|
234
|
+
: null;
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
schemaVersion: 1,
|
|
238
|
+
source,
|
|
239
|
+
semantics: {
|
|
240
|
+
modelLoadMs: 'model initialization/load before generation',
|
|
241
|
+
firstTokenMs: 'ttft from generation start',
|
|
242
|
+
firstResponseMs: 'modelLoadMs + firstTokenMs',
|
|
243
|
+
prefillMs: prefillSemantics,
|
|
244
|
+
decodeMs: 'time after first token',
|
|
245
|
+
totalRunMs: 'prefillMs + decodeMs',
|
|
246
|
+
},
|
|
247
|
+
componentsMs: {
|
|
248
|
+
modelLoadMs,
|
|
249
|
+
firstTokenMs,
|
|
250
|
+
firstResponseMs,
|
|
251
|
+
prefillMs,
|
|
252
|
+
decodeMs,
|
|
253
|
+
totalRunMs,
|
|
254
|
+
},
|
|
255
|
+
sumsMs: {
|
|
256
|
+
firstResponseFromLoadAndFirstTokenMs,
|
|
257
|
+
runFromPrefillAndDecodeMs,
|
|
258
|
+
},
|
|
259
|
+
residualsMs: {
|
|
260
|
+
firstResponseResidualMs,
|
|
261
|
+
runResidualMs,
|
|
262
|
+
},
|
|
263
|
+
consistent: {
|
|
264
|
+
firstResponse: Number.isFinite(firstResponseResidualMs) ? Math.abs(firstResponseResidualMs) <= 2 : null,
|
|
265
|
+
totalRun: Number.isFinite(runResidualMs) ? Math.abs(runResidualMs) <= 2 : null,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare function resolvePrompt(runtimeConfig: Record<string, unknown>): string;
|
|
2
|
+
export declare function resolveBenchmarkRunSettings(
|
|
3
|
+
runtimeConfig: Record<string, unknown>,
|
|
4
|
+
source?: Record<string, unknown> | null
|
|
5
|
+
): {
|
|
6
|
+
warmupRuns: number;
|
|
7
|
+
timedRuns: number;
|
|
8
|
+
prompt: string | Record<string, unknown>;
|
|
9
|
+
promptLabel: string;
|
|
10
|
+
maxTokens: number;
|
|
11
|
+
sampling: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export declare function runEmbeddingSemanticChecks(
|
|
14
|
+
pipeline: Record<string, unknown>,
|
|
15
|
+
options?: Record<string, unknown> | null
|
|
16
|
+
): Promise<Record<string, unknown>>;
|
|
17
|
+
export declare function isCoherentOutput(tokens: Array<unknown>, output: unknown): boolean;
|
|
18
|
+
export declare function runGeneration(
|
|
19
|
+
pipeline: Record<string, unknown>,
|
|
20
|
+
runtimeConfig: Record<string, unknown>,
|
|
21
|
+
runOverrides?: Record<string, unknown> | null
|
|
22
|
+
): Promise<Record<string, unknown>>;
|
|
23
|
+
export declare function runEmbedding(
|
|
24
|
+
pipeline: Record<string, unknown>,
|
|
25
|
+
runtimeConfig: Record<string, unknown>,
|
|
26
|
+
runOverrides?: Record<string, unknown> | null
|
|
27
|
+
): Promise<Record<string, unknown>>;
|