@simulatte/doppler 0.1.0
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/BRANDING.md +14 -0
- package/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +85 -0
- package/SECURITY.md +19 -0
- package/package.json +144 -0
- package/src/adapters/adapter-manager.d.ts +200 -0
- package/src/adapters/adapter-manager.js +509 -0
- package/src/adapters/adapter-manifest.d.ts +290 -0
- package/src/adapters/adapter-manifest.js +320 -0
- package/src/adapters/adapter-registry.d.ts +192 -0
- package/src/adapters/adapter-registry.js +466 -0
- package/src/adapters/index.d.ts +89 -0
- package/src/adapters/index.js +42 -0
- package/src/adapters/lora-loader.d.ts +105 -0
- package/src/adapters/lora-loader.js +397 -0
- package/src/bootstrap.d.ts +1 -0
- package/src/bootstrap.js +30 -0
- package/src/bridge/extension/background.d.ts +14 -0
- package/src/bridge/extension/background.js +168 -0
- package/src/bridge/extension/manifest.json +34 -0
- package/src/bridge/extension-client.d.ts +109 -0
- package/src/bridge/extension-client.js +369 -0
- package/src/bridge/index.d.ts +68 -0
- package/src/bridge/index.js +51 -0
- package/src/bridge/protocol.d.ts +96 -0
- package/src/bridge/protocol.js +130 -0
- package/src/browser/browser-converter.d.ts +71 -0
- package/src/browser/browser-converter.js +947 -0
- package/src/browser/file-picker.d.ts +63 -0
- package/src/browser/file-picker.js +275 -0
- package/src/browser/gguf-importer.d.ts +136 -0
- package/src/browser/gguf-importer.js +532 -0
- package/src/browser/gguf-parser-browser.d.ts +14 -0
- package/src/browser/gguf-parser-browser.js +17 -0
- package/src/browser/quantization.d.ts +69 -0
- package/src/browser/quantization.js +328 -0
- package/src/browser/safetensors-parser-browser.d.ts +193 -0
- package/src/browser/safetensors-parser-browser.js +264 -0
- package/src/browser/shard-io-browser.d.ts +57 -0
- package/src/browser/shard-io-browser.js +89 -0
- package/src/browser/tensor-source-download.d.ts +27 -0
- package/src/browser/tensor-source-download.js +239 -0
- package/src/browser/tensor-source-file.d.ts +26 -0
- package/src/browser/tensor-source-file.js +53 -0
- package/src/browser/tensor-source-http.d.ts +28 -0
- package/src/browser/tensor-source-http.js +126 -0
- package/src/client/doppler-provider/generation.d.ts +25 -0
- package/src/client/doppler-provider/generation.js +114 -0
- package/src/client/doppler-provider/index.d.ts +2 -0
- package/src/client/doppler-provider/index.js +3 -0
- package/src/client/doppler-provider/model-manager.d.ts +61 -0
- package/src/client/doppler-provider/model-manager.js +667 -0
- package/src/client/doppler-provider/provider.d.ts +5 -0
- package/src/client/doppler-provider/provider.js +102 -0
- package/src/client/doppler-provider/source-runtime.d.ts +22 -0
- package/src/client/doppler-provider/source-runtime.js +522 -0
- package/src/client/doppler-provider/types.d.ts +127 -0
- package/src/client/doppler-provider/types.js +17 -0
- package/src/client/doppler-provider.d.ts +46 -0
- package/src/client/doppler-provider.js +36 -0
- package/src/config/README.md +69 -0
- package/src/config/backward-registry-loader.d.ts +3 -0
- package/src/config/backward-registry-loader.js +8 -0
- package/src/config/index.d.ts +63 -0
- package/src/config/index.js +31 -0
- package/src/config/kernel-path-loader.d.ts +149 -0
- package/src/config/kernel-path-loader.js +534 -0
- package/src/config/kernels/backward-registry.json +99 -0
- package/src/config/kernels/kernel-ref-digests.d.ts +1 -0
- package/src/config/kernels/kernel-ref-digests.js +214 -0
- package/src/config/kernels/kernel-ref.d.ts +17 -0
- package/src/config/kernels/kernel-ref.js +75 -0
- package/src/config/kernels/moe/gpt-oss.paths.json +49 -0
- package/src/config/kernels/registry.d.ts +86 -0
- package/src/config/kernels/registry.js +103 -0
- package/src/config/kernels/registry.json +6771 -0
- package/src/config/loader.d.ts +57 -0
- package/src/config/loader.js +513 -0
- package/src/config/merge.d.ts +142 -0
- package/src/config/merge.js +389 -0
- package/src/config/param-categories.d.ts +17 -0
- package/src/config/param-categories.js +72 -0
- package/src/config/param-validator.d.ts +26 -0
- package/src/config/param-validator.js +235 -0
- package/src/config/platforms/amd-rdna3.json +16 -0
- package/src/config/platforms/apple-m1.json +16 -0
- package/src/config/platforms/apple-m2.json +16 -0
- package/src/config/platforms/apple-m3.json +16 -0
- package/src/config/platforms/generic.json +14 -0
- package/src/config/platforms/loader.d.ts +65 -0
- package/src/config/platforms/loader.js +153 -0
- package/src/config/platforms/nvidia-rtx30.json +16 -0
- package/src/config/platforms/nvidia-rtx40.json +16 -0
- package/src/config/presets/kernel-paths/embeddinggemma-f16-f32a.json +60 -0
- package/src/config/presets/kernel-paths/embeddinggemma-f32-f32a.json +60 -0
- package/src/config/presets/kernel-paths/embeddinggemma-q4k-dequant-f32a.json +60 -0
- package/src/config/presets/kernel-paths/gemma2-f16-f16a.json +61 -0
- package/src/config/presets/kernel-paths/gemma2-f16-f32a.json +60 -0
- package/src/config/presets/kernel-paths/gemma2-q4k-dequant-f16a.json +61 -0
- package/src/config/presets/kernel-paths/gemma2-q4k-dequant-f32a.json +60 -0
- package/src/config/presets/kernel-paths/gemma2-q4k-fused-f32a.json +57 -0
- package/src/config/presets/kernel-paths/gemma3-f16-fused-f16a-online.json +200 -0
- package/src/config/presets/kernel-paths/gemma3-f16-fused-f32a-online.json +223 -0
- package/src/config/presets/kernel-paths/gemma3-q4k-dequant-f16a-online.json +60 -0
- package/src/config/presets/kernel-paths/gemma3-q4k-dequant-f32a-online.json +61 -0
- package/src/config/presets/kernel-paths/gemma3-q4k-dequant-f32a.json +61 -0
- package/src/config/presets/kernel-paths/lfm2-q4k-dequant-f32a-online.json +61 -0
- package/src/config/presets/kernel-paths/registry.json +103 -0
- package/src/config/presets/models/deepseek.json +20 -0
- package/src/config/presets/models/diffusion.json +10 -0
- package/src/config/presets/models/embeddinggemma.json +74 -0
- package/src/config/presets/models/functiongemma.json +31 -0
- package/src/config/presets/models/gemma2.json +59 -0
- package/src/config/presets/models/gemma3.json +75 -0
- package/src/config/presets/models/gpt-oss.json +68 -0
- package/src/config/presets/models/kimi-k2.json +25 -0
- package/src/config/presets/models/lfm2.json +83 -0
- package/src/config/presets/models/llama3.json +40 -0
- package/src/config/presets/models/mamba.json +34 -0
- package/src/config/presets/models/mixtral.json +37 -0
- package/src/config/presets/models/modernbert.json +32 -0
- package/src/config/presets/models/qwen3.json +41 -0
- package/src/config/presets/models/transformer.json +73 -0
- package/src/config/presets/models/translategemma.json +30 -0
- package/src/config/presets/platforms/nvidia-gb200-8gpu.json +45 -0
- package/src/config/presets/platforms/nvidia-gb200-nvl72.json +45 -0
- package/src/config/presets/platforms/nvidia-gh200-nvl2.json +44 -0
- package/src/config/presets/platforms/nvidia-gh200.json +44 -0
- package/src/config/presets/runtime/compute/f16-activations.json +30 -0
- package/src/config/presets/runtime/compute/f16-batched.json +32 -0
- package/src/config/presets/runtime/default.json +101 -0
- package/src/config/presets/runtime/diagnostics/debug-logits.json +53 -0
- package/src/config/presets/runtime/experiments/bench/gemma3-bench-q4k.json +53 -0
- package/src/config/presets/runtime/experiments/debug/gemma3-debug-q4k.json +210 -0
- package/src/config/presets/runtime/experiments/verify/gemma3-verify.json +39 -0
- package/src/config/presets/runtime/kernels/dequant-f16-q4k.json +20 -0
- package/src/config/presets/runtime/kernels/dequant-f32-q4k.json +20 -0
- package/src/config/presets/runtime/kernels/fused-q4k.json +20 -0
- package/src/config/presets/runtime/kernels/safe-q4k.json +20 -0
- package/src/config/presets/runtime/model/gemma2-debug.json +77 -0
- package/src/config/presets/runtime/model/gemma2-pipeline-debug.json +66 -0
- package/src/config/presets/runtime/model/gemma2-pipeline.json +75 -0
- package/src/config/presets/runtime/model/gemma3-layer-probe.json +85 -0
- package/src/config/presets/runtime/modes/bench.json +37 -0
- package/src/config/presets/runtime/modes/debug.json +39 -0
- package/src/config/presets/runtime/modes/default.json +10 -0
- package/src/config/presets/runtime/modes/embedding-bench.json +28 -0
- package/src/config/presets/runtime/modes/embedding.json +54 -0
- package/src/config/presets/runtime/modes/low-memory.json +40 -0
- package/src/config/presets/runtime/modes/production.json +48 -0
- package/src/config/presets/runtime/modes/simulation.json +30 -0
- package/src/config/presets/runtime/modes/trace-layers.json +126 -0
- package/src/config/presets/runtime/platform/metal-apple-q4k.json +11 -0
- package/src/config/runtime-merge.d.ts +5 -0
- package/src/config/runtime-merge.js +21 -0
- package/src/config/runtime.d.ts +28 -0
- package/src/config/runtime.js +56 -0
- package/src/config/schema/adapter.schema.d.ts +53 -0
- package/src/config/schema/adapter.schema.js +60 -0
- package/src/config/schema/backward-registry.schema.d.ts +14 -0
- package/src/config/schema/backward-registry.schema.js +46 -0
- package/src/config/schema/benchmark.schema.d.ts +54 -0
- package/src/config/schema/benchmark.schema.js +74 -0
- package/src/config/schema/bridge.schema.d.ts +25 -0
- package/src/config/schema/bridge.schema.js +22 -0
- package/src/config/schema/buffer-pool.schema.d.ts +92 -0
- package/src/config/schema/buffer-pool.schema.js +50 -0
- package/src/config/schema/conversion.schema.d.ts +183 -0
- package/src/config/schema/conversion.schema.js +13 -0
- package/src/config/schema/converter.schema.d.ts +123 -0
- package/src/config/schema/converter.schema.js +136 -0
- package/src/config/schema/debug.schema.d.ts +245 -0
- package/src/config/schema/debug.schema.js +106 -0
- package/src/config/schema/diffusion.schema.d.ts +88 -0
- package/src/config/schema/diffusion.schema.js +62 -0
- package/src/config/schema/distill-training.schema.d.ts +48 -0
- package/src/config/schema/distill-training.schema.js +139 -0
- package/src/config/schema/distribution.schema.d.ts +155 -0
- package/src/config/schema/distribution.schema.js +81 -0
- package/src/config/schema/doppler.schema.d.ts +75 -0
- package/src/config/schema/doppler.schema.js +352 -0
- package/src/config/schema/ecosystem.schema.d.ts +255 -0
- package/src/config/schema/ecosystem.schema.js +534 -0
- package/src/config/schema/emulation.schema.d.ts +351 -0
- package/src/config/schema/emulation.schema.js +299 -0
- package/src/config/schema/energy.schema.d.ts +102 -0
- package/src/config/schema/energy.schema.js +72 -0
- package/src/config/schema/execution-v0.schema.d.ts +187 -0
- package/src/config/schema/execution-v0.schema.js +55 -0
- package/src/config/schema/gpu-cache.schema.d.ts +26 -0
- package/src/config/schema/gpu-cache.schema.js +8 -0
- package/src/config/schema/harness.schema.d.ts +32 -0
- package/src/config/schema/harness.schema.js +20 -0
- package/src/config/schema/hotswap.schema.d.ts +55 -0
- package/src/config/schema/hotswap.schema.js +18 -0
- package/src/config/schema/index.d.ts +863 -0
- package/src/config/schema/index.js +471 -0
- package/src/config/schema/inference-defaults.schema.d.ts +276 -0
- package/src/config/schema/inference-defaults.schema.js +185 -0
- package/src/config/schema/inference.schema.d.ts +289 -0
- package/src/config/schema/inference.schema.js +39 -0
- package/src/config/schema/intent-bundle.schema.d.ts +28 -0
- package/src/config/schema/intent-bundle.schema.js +12 -0
- package/src/config/schema/kernel-path.schema.d.ts +173 -0
- package/src/config/schema/kernel-path.schema.js +9 -0
- package/src/config/schema/kernel-registry.schema.d.ts +199 -0
- package/src/config/schema/kernel-registry.schema.js +46 -0
- package/src/config/schema/kernel-thresholds.schema.d.ts +302 -0
- package/src/config/schema/kernel-thresholds.schema.js +187 -0
- package/src/config/schema/kernel-warmup.schema.d.ts +19 -0
- package/src/config/schema/kernel-warmup.schema.js +5 -0
- package/src/config/schema/kvcache.schema.d.ts +131 -0
- package/src/config/schema/kvcache.schema.js +31 -0
- package/src/config/schema/loading.schema.d.ts +153 -0
- package/src/config/schema/loading.schema.js +84 -0
- package/src/config/schema/lora.schema.d.ts +12 -0
- package/src/config/schema/lora.schema.js +12 -0
- package/src/config/schema/manifest.schema.d.ts +500 -0
- package/src/config/schema/manifest.schema.js +130 -0
- package/src/config/schema/memory-limits.schema.d.ts +107 -0
- package/src/config/schema/memory-limits.schema.js +57 -0
- package/src/config/schema/moe.schema.d.ts +78 -0
- package/src/config/schema/moe.schema.js +31 -0
- package/src/config/schema/platform.schema.d.ts +121 -0
- package/src/config/schema/platform.schema.js +1 -0
- package/src/config/schema/preset.schema.d.ts +124 -0
- package/src/config/schema/preset.schema.js +1 -0
- package/src/config/schema/quantization-defaults.schema.d.ts +34 -0
- package/src/config/schema/quantization-defaults.schema.js +5 -0
- package/src/config/schema/quantization.schema.d.ts +10 -0
- package/src/config/schema/quantization.schema.js +33 -0
- package/src/config/schema/shared-runtime.schema.d.ts +75 -0
- package/src/config/schema/shared-runtime.schema.js +45 -0
- package/src/config/schema/speculative.schema.d.ts +21 -0
- package/src/config/schema/speculative.schema.js +11 -0
- package/src/config/schema/storage.schema.d.ts +123 -0
- package/src/config/schema/storage.schema.js +66 -0
- package/src/config/schema/tooling.schema.d.ts +29 -0
- package/src/config/schema/tooling.schema.js +12 -0
- package/src/config/schema/training-metrics.schema.d.ts +89 -0
- package/src/config/schema/training-metrics.schema.js +374 -0
- package/src/config/schema/training.schema.d.ts +88 -0
- package/src/config/schema/training.schema.js +106 -0
- package/src/config/schema/tuner.schema.d.ts +39 -0
- package/src/config/schema/tuner.schema.js +13 -0
- package/src/config/schema/ul-training.schema.d.ts +61 -0
- package/src/config/schema/ul-training.schema.js +140 -0
- package/src/config/schema/units.schema.d.ts +27 -0
- package/src/config/schema/units.schema.js +26 -0
- package/src/config/training-defaults.d.ts +24 -0
- package/src/config/training-defaults.js +91 -0
- package/src/converter/conversion-plan.d.ts +64 -0
- package/src/converter/conversion-plan.js +472 -0
- package/src/converter/core.d.ts +247 -0
- package/src/converter/core.js +1329 -0
- package/src/converter/execution-v0-manifest.d.ts +15 -0
- package/src/converter/execution-v0-manifest.js +146 -0
- package/src/converter/index.d.ts +98 -0
- package/src/converter/index.js +59 -0
- package/src/converter/manifest-inference.d.ts +20 -0
- package/src/converter/manifest-inference.js +492 -0
- package/src/converter/parsers/diffusion.d.ts +50 -0
- package/src/converter/parsers/diffusion.js +270 -0
- package/src/converter/parsers/gguf.d.ts +22 -0
- package/src/converter/parsers/gguf.js +46 -0
- package/src/converter/parsers/index.d.ts +21 -0
- package/src/converter/parsers/index.js +12 -0
- package/src/converter/parsers/transformer.d.ts +16 -0
- package/src/converter/parsers/transformer.js +25 -0
- package/src/converter/quantization-info.d.ts +37 -0
- package/src/converter/quantization-info.js +398 -0
- package/src/converter/quantizer.d.ts +96 -0
- package/src/converter/quantizer.js +422 -0
- package/src/converter/rope-config.d.ts +15 -0
- package/src/converter/rope-config.js +218 -0
- package/src/converter/shard-packer.d.ts +138 -0
- package/src/converter/shard-packer.js +422 -0
- package/src/converter/tokenizer-utils.d.ts +11 -0
- package/src/converter/tokenizer-utils.js +87 -0
- package/src/debug/config.d.ts +78 -0
- package/src/debug/config.js +235 -0
- package/src/debug/history.d.ts +65 -0
- package/src/debug/history.js +71 -0
- package/src/debug/index.d.ts +268 -0
- package/src/debug/index.js +192 -0
- package/src/debug/log.d.ts +46 -0
- package/src/debug/log.js +132 -0
- package/src/debug/perf.d.ts +33 -0
- package/src/debug/perf.js +51 -0
- package/src/debug/reference/README.md +114 -0
- package/src/debug/reference/hf_attn_debug.py +114 -0
- package/src/debug/reference/hf_embed_check.py +89 -0
- package/src/debug/reference/hf_layer_out.py +100 -0
- package/src/debug/reference/hf_rope_check.py +116 -0
- package/src/debug/reference/hf_weights.py +75 -0
- package/src/debug/signals.d.ts +63 -0
- package/src/debug/signals.js +33 -0
- package/src/debug/stats.d.ts +47 -0
- package/src/debug/stats.js +160 -0
- package/src/debug/tensor.d.ts +123 -0
- package/src/debug/tensor.js +257 -0
- package/src/debug/trace.d.ts +17 -0
- package/src/debug/trace.js +167 -0
- package/src/diffusion/image-regression.d.ts +31 -0
- package/src/diffusion/image-regression.js +107 -0
- package/src/diffusion/index.d.ts +8 -0
- package/src/diffusion/index.js +8 -0
- package/src/distribution/p2p-control-plane.d.ts +52 -0
- package/src/distribution/p2p-control-plane.js +232 -0
- package/src/distribution/p2p-observability.d.ts +116 -0
- package/src/distribution/p2p-observability.js +267 -0
- package/src/distribution/p2p-transport-contract.d.ts +57 -0
- package/src/distribution/p2p-transport-contract.js +310 -0
- package/src/distribution/p2p-webrtc-browser.d.ts +37 -0
- package/src/distribution/p2p-webrtc-browser.js +434 -0
- package/src/distribution/shard-delivery.d.ts +251 -0
- package/src/distribution/shard-delivery.js +2096 -0
- package/src/energy/index.d.ts +2 -0
- package/src/energy/index.js +2 -0
- package/src/errors/doppler-error.d.ts +21 -0
- package/src/errors/doppler-error.js +25 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +1 -0
- package/src/formats/gguf/index.d.ts +8 -0
- package/src/formats/gguf/index.js +4 -0
- package/src/formats/gguf/types.d.ts +137 -0
- package/src/formats/gguf/types.js +443 -0
- package/src/formats/index.d.ts +51 -0
- package/src/formats/index.js +13 -0
- package/src/formats/rdrr/classification.d.ts +39 -0
- package/src/formats/rdrr/classification.js +275 -0
- package/src/formats/rdrr/groups.d.ts +27 -0
- package/src/formats/rdrr/groups.js +76 -0
- package/src/formats/rdrr/index.d.ts +25 -0
- package/src/formats/rdrr/index.js +19 -0
- package/src/formats/rdrr/manifest.d.ts +32 -0
- package/src/formats/rdrr/manifest.js +108 -0
- package/src/formats/rdrr/parsing.d.ts +23 -0
- package/src/formats/rdrr/parsing.js +101 -0
- package/src/formats/rdrr/tensor-config-validator.d.ts +42 -0
- package/src/formats/rdrr/tensor-config-validator.js +156 -0
- package/src/formats/rdrr/types.d.ts +200 -0
- package/src/formats/rdrr/types.js +16 -0
- package/src/formats/rdrr/validation.d.ts +9 -0
- package/src/formats/rdrr/validation.js +200 -0
- package/src/formats/safetensors/index.d.ts +8 -0
- package/src/formats/safetensors/index.js +4 -0
- package/src/formats/safetensors/types.d.ts +67 -0
- package/src/formats/safetensors/types.js +102 -0
- package/src/formats/tokenizer/index.d.ts +5 -0
- package/src/formats/tokenizer/index.js +3 -0
- package/src/formats/tokenizer/types.d.ts +9 -0
- package/src/formats/tokenizer/types.js +22 -0
- package/src/generation/index.d.ts +18 -0
- package/src/generation/index.js +12 -0
- package/src/gpu/command-recorder.d.ts +175 -0
- package/src/gpu/command-recorder.js +473 -0
- package/src/gpu/device.d.ts +141 -0
- package/src/gpu/device.js +350 -0
- package/src/gpu/kernel-runtime.d.ts +20 -0
- package/src/gpu/kernel-runtime.js +37 -0
- package/src/gpu/kernel-selection-cache.d.ts +13 -0
- package/src/gpu/kernel-selection-cache.js +13 -0
- package/src/gpu/kernel-selection-log.d.ts +12 -0
- package/src/gpu/kernel-selection-log.js +28 -0
- package/src/gpu/kernel-selector.d.ts +11 -0
- package/src/gpu/kernel-selector.js +10 -0
- package/src/gpu/kernel-tuner/benchmarks.d.ts +144 -0
- package/src/gpu/kernel-tuner/benchmarks.js +892 -0
- package/src/gpu/kernel-tuner/cache.d.ts +55 -0
- package/src/gpu/kernel-tuner/cache.js +66 -0
- package/src/gpu/kernel-tuner/index.d.ts +59 -0
- package/src/gpu/kernel-tuner/index.js +38 -0
- package/src/gpu/kernel-tuner/tuner.d.ts +82 -0
- package/src/gpu/kernel-tuner/tuner.js +229 -0
- package/src/gpu/kernel-tuner/types.d.ts +101 -0
- package/src/gpu/kernel-tuner/types.js +4 -0
- package/src/gpu/kernel-tuner.d.ts +33 -0
- package/src/gpu/kernel-tuner.js +12 -0
- package/src/gpu/kernels/README.md +127 -0
- package/src/gpu/kernels/attention.d.ts +236 -0
- package/src/gpu/kernels/attention.js +1359 -0
- package/src/gpu/kernels/attention.wgsl +249 -0
- package/src/gpu/kernels/attention_bdpa_decode_f16.wgsl +246 -0
- package/src/gpu/kernels/attention_decode.wgsl +233 -0
- package/src/gpu/kernels/attention_decode_chunked_f16.wgsl +183 -0
- package/src/gpu/kernels/attention_decode_chunked_f16kv.wgsl +208 -0
- package/src/gpu/kernels/attention_decode_f16.wgsl +202 -0
- package/src/gpu/kernels/attention_decode_f16kv.wgsl +224 -0
- package/src/gpu/kernels/attention_decode_online_f16.wgsl +223 -0
- package/src/gpu/kernels/attention_decode_online_f16kv.wgsl +225 -0
- package/src/gpu/kernels/attention_decode_optimized.wgsl +445 -0
- package/src/gpu/kernels/attention_decode_paged_f16.wgsl +172 -0
- package/src/gpu/kernels/attention_decode_paged_f16kv.wgsl +174 -0
- package/src/gpu/kernels/attention_decode_subgroup.wgsl +233 -0
- package/src/gpu/kernels/attention_decode_tiered_f16.wgsl +218 -0
- package/src/gpu/kernels/attention_decode_tiered_f16kv.wgsl +220 -0
- package/src/gpu/kernels/attention_decode_tiered_int4_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_decode_tiered_int8_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_f16.wgsl +214 -0
- package/src/gpu/kernels/attention_f16kv.wgsl +242 -0
- package/src/gpu/kernels/attention_small.wgsl +260 -0
- package/src/gpu/kernels/attention_small_f16.wgsl +240 -0
- package/src/gpu/kernels/attention_small_f16kv.wgsl +266 -0
- package/src/gpu/kernels/attention_streaming.wgsl +149 -0
- package/src/gpu/kernels/attention_streaming_f16.wgsl +147 -0
- package/src/gpu/kernels/attention_streaming_f16kv.wgsl +151 -0
- package/src/gpu/kernels/backward/adam.d.ts +28 -0
- package/src/gpu/kernels/backward/adam.js +199 -0
- package/src/gpu/kernels/backward/adam.wgsl +50 -0
- package/src/gpu/kernels/backward/attention_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/attention_backward.js +276 -0
- package/src/gpu/kernels/backward/attention_backward.wgsl +49 -0
- package/src/gpu/kernels/backward/bias_add_backward.d.ts +17 -0
- package/src/gpu/kernels/backward/bias_add_backward.js +24 -0
- package/src/gpu/kernels/backward/bias_add_backward.wgsl +33 -0
- package/src/gpu/kernels/backward/conv2d_backward.d.ts +31 -0
- package/src/gpu/kernels/backward/conv2d_backward.js +135 -0
- package/src/gpu/kernels/backward/conv2d_backward_input.wgsl +83 -0
- package/src/gpu/kernels/backward/conv2d_backward_weight.wgsl +70 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.d.ts +23 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.js +29 -0
- package/src/gpu/kernels/backward/cross_entropy_backward.wgsl +39 -0
- package/src/gpu/kernels/backward/embed_backward.d.ts +29 -0
- package/src/gpu/kernels/backward/embed_backward.js +118 -0
- package/src/gpu/kernels/backward/embed_backward.wgsl +73 -0
- package/src/gpu/kernels/backward/gelu_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/gelu_backward.js +39 -0
- package/src/gpu/kernels/backward/gelu_backward.wgsl +38 -0
- package/src/gpu/kernels/backward/groupnorm_backward.d.ts +24 -0
- package/src/gpu/kernels/backward/groupnorm_backward.js +29 -0
- package/src/gpu/kernels/backward/groupnorm_backward.wgsl +143 -0
- package/src/gpu/kernels/backward/index.d.ts +17 -0
- package/src/gpu/kernels/backward/index.js +23 -0
- package/src/gpu/kernels/backward/layernorm_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/layernorm_backward.js +135 -0
- package/src/gpu/kernels/backward/layernorm_backward.wgsl +194 -0
- package/src/gpu/kernels/backward/matmul_backward.d.ts +32 -0
- package/src/gpu/kernels/backward/matmul_backward.js +124 -0
- package/src/gpu/kernels/backward/matmul_backward.wgsl +90 -0
- package/src/gpu/kernels/backward/matmul_transpose_a.wgsl +84 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.d.ts +22 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.js +30 -0
- package/src/gpu/kernels/backward/pixel_shuffle_backward.wgsl +54 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.d.ts +24 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.js +101 -0
- package/src/gpu/kernels/backward/rmsnorm_backward.wgsl +78 -0
- package/src/gpu/kernels/backward/rope_backward.d.ts +25 -0
- package/src/gpu/kernels/backward/rope_backward.js +109 -0
- package/src/gpu/kernels/backward/rope_backward.wgsl +59 -0
- package/src/gpu/kernels/backward/scale_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/scale_backward.js +84 -0
- package/src/gpu/kernels/backward/scale_backward.wgsl +27 -0
- package/src/gpu/kernels/backward/silu_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/silu_backward.js +39 -0
- package/src/gpu/kernels/backward/silu_backward.wgsl +31 -0
- package/src/gpu/kernels/backward/softmax_backward.d.ts +16 -0
- package/src/gpu/kernels/backward/softmax_backward.js +43 -0
- package/src/gpu/kernels/backward/softmax_backward.wgsl +44 -0
- package/src/gpu/kernels/backward/upsample2d_backward.d.ts +21 -0
- package/src/gpu/kernels/backward/upsample2d_backward.js +30 -0
- package/src/gpu/kernels/backward/upsample2d_backward.wgsl +59 -0
- package/src/gpu/kernels/backward/utils.d.ts +45 -0
- package/src/gpu/kernels/backward/utils.js +371 -0
- package/src/gpu/kernels/bf16_to_f16.wgsl +54 -0
- package/src/gpu/kernels/bf16_to_f32.wgsl +70 -0
- package/src/gpu/kernels/bias_add.wgsl +40 -0
- package/src/gpu/kernels/bias_add_f16.wgsl +44 -0
- package/src/gpu/kernels/cast.d.ts +67 -0
- package/src/gpu/kernels/cast.js +422 -0
- package/src/gpu/kernels/cast_f16_to_f32.wgsl +31 -0
- package/src/gpu/kernels/cast_f32_to_f16.wgsl +36 -0
- package/src/gpu/kernels/check-finiteness.d.ts +15 -0
- package/src/gpu/kernels/check-finiteness.js +149 -0
- package/src/gpu/kernels/check-stop.d.ts +31 -0
- package/src/gpu/kernels/check-stop.js +181 -0
- package/src/gpu/kernels/clamp.d.ts +22 -0
- package/src/gpu/kernels/clamp.js +42 -0
- package/src/gpu/kernels/clamp.wgsl +24 -0
- package/src/gpu/kernels/constants.d.ts +168 -0
- package/src/gpu/kernels/constants.js +129 -0
- package/src/gpu/kernels/conv2d.d.ts +34 -0
- package/src/gpu/kernels/conv2d.js +81 -0
- package/src/gpu/kernels/conv2d.wgsl +71 -0
- package/src/gpu/kernels/conv2d_f16.wgsl +73 -0
- package/src/gpu/kernels/cross_entropy_loss.d.ts +21 -0
- package/src/gpu/kernels/cross_entropy_loss.js +54 -0
- package/src/gpu/kernels/cross_entropy_loss.wgsl +39 -0
- package/src/gpu/kernels/dequant.d.ts +108 -0
- package/src/gpu/kernels/dequant.js +524 -0
- package/src/gpu/kernels/dequant_f16_out.wgsl +151 -0
- package/src/gpu/kernels/dequant_f16_out_vec4.wgsl +149 -0
- package/src/gpu/kernels/dequant_f16_rowwise.wgsl +139 -0
- package/src/gpu/kernels/dequant_f32_rowwise.wgsl +133 -0
- package/src/gpu/kernels/dequant_mxfp4.wgsl +120 -0
- package/src/gpu/kernels/dequant_mxfp4_expert.wgsl +129 -0
- package/src/gpu/kernels/dequant_mxfp4_expert_f16.wgsl +105 -0
- package/src/gpu/kernels/dequant_mxfp4_vec4.wgsl +116 -0
- package/src/gpu/kernels/dequant_q6k.wgsl +140 -0
- package/src/gpu/kernels/dequant_q8_0.wgsl +98 -0
- package/src/gpu/kernels/dequant_shared.wgsl +202 -0
- package/src/gpu/kernels/dequant_shared_vec4.wgsl +153 -0
- package/src/gpu/kernels/dequant_subgroup.wgsl +202 -0
- package/src/gpu/kernels/dispatch.d.ts +157 -0
- package/src/gpu/kernels/dispatch.js +235 -0
- package/src/gpu/kernels/energy.d.ts +131 -0
- package/src/gpu/kernels/energy.js +425 -0
- package/src/gpu/kernels/energy_eval.wgsl +26 -0
- package/src/gpu/kernels/energy_eval_f16.wgsl +30 -0
- package/src/gpu/kernels/energy_quintel_grad.wgsl +92 -0
- package/src/gpu/kernels/energy_quintel_grad_f16.wgsl +96 -0
- package/src/gpu/kernels/energy_quintel_reduce.wgsl +112 -0
- package/src/gpu/kernels/energy_quintel_reduce_f16.wgsl +116 -0
- package/src/gpu/kernels/energy_quintel_update.wgsl +92 -0
- package/src/gpu/kernels/energy_quintel_update_f16.wgsl +96 -0
- package/src/gpu/kernels/energy_update.wgsl +25 -0
- package/src/gpu/kernels/energy_update_f16.wgsl +30 -0
- package/src/gpu/kernels/feature-check.d.ts +42 -0
- package/src/gpu/kernels/feature-check.js +70 -0
- package/src/gpu/kernels/fused_ffn.d.ts +65 -0
- package/src/gpu/kernels/fused_ffn.js +318 -0
- package/src/gpu/kernels/fused_ffn.wgsl +420 -0
- package/src/gpu/kernels/fused_ffn_f16.wgsl +213 -0
- package/src/gpu/kernels/fused_ffn_q4k.wgsl +375 -0
- package/src/gpu/kernels/fused_matmul_q4.wgsl +404 -0
- package/src/gpu/kernels/fused_matmul_q4_batched.wgsl +194 -0
- package/src/gpu/kernels/fused_matmul_q4_batched_f16.wgsl +170 -0
- package/src/gpu/kernels/fused_matmul_q4_batched_f16a.wgsl +154 -0
- package/src/gpu/kernels/fused_matmul_q4_f16a.wgsl +219 -0
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16.wgsl +216 -0
- package/src/gpu/kernels/fused_matmul_q4_multicol_f16a.wgsl +204 -0
- package/src/gpu/kernels/fused_matmul_residual.d.ts +46 -0
- package/src/gpu/kernels/fused_matmul_residual.js +152 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.d.ts +64 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.js +273 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm.wgsl +324 -0
- package/src/gpu/kernels/fused_matmul_rmsnorm_f16.wgsl +303 -0
- package/src/gpu/kernels/fused_swiglu.wgsl +63 -0
- package/src/gpu/kernels/fused_swiglu_f16.wgsl +57 -0
- package/src/gpu/kernels/gather.d.ts +64 -0
- package/src/gpu/kernels/gather.js +119 -0
- package/src/gpu/kernels/gather.wgsl +61 -0
- package/src/gpu/kernels/gather_f16.wgsl +65 -0
- package/src/gpu/kernels/gather_f16_f16_out.wgsl +55 -0
- package/src/gpu/kernels/gather_f16_out.wgsl +55 -0
- package/src/gpu/kernels/gather_f16_vec4.wgsl +76 -0
- package/src/gpu/kernels/gather_f16_vec4_f16_out.wgsl +68 -0
- package/src/gpu/kernels/gather_vec4.wgsl +74 -0
- package/src/gpu/kernels/gather_vec4_f16_out.wgsl +68 -0
- package/src/gpu/kernels/gelu.d.ts +33 -0
- package/src/gpu/kernels/gelu.js +47 -0
- package/src/gpu/kernels/gelu.wgsl +64 -0
- package/src/gpu/kernels/gelu_f16.wgsl +66 -0
- package/src/gpu/kernels/gptoss_mxfp4_expert_fused.wgsl +127 -0
- package/src/gpu/kernels/gptoss_router_topk.wgsl +119 -0
- package/src/gpu/kernels/groupnorm.d.ts +31 -0
- package/src/gpu/kernels/groupnorm.js +91 -0
- package/src/gpu/kernels/groupnorm_apply.wgsl +41 -0
- package/src/gpu/kernels/groupnorm_apply_f16.wgsl +46 -0
- package/src/gpu/kernels/groupnorm_stats.wgsl +76 -0
- package/src/gpu/kernels/groupnorm_stats_f16.wgsl +79 -0
- package/src/gpu/kernels/index.d.ts +336 -0
- package/src/gpu/kernels/index.js +284 -0
- package/src/gpu/kernels/kernel-base.d.ts +33 -0
- package/src/gpu/kernels/kernel-base.js +46 -0
- package/src/gpu/kernels/kernel-configs.d.ts +65 -0
- package/src/gpu/kernels/kernel-configs.js +50 -0
- package/src/gpu/kernels/kernel-tuning.d.ts +42 -0
- package/src/gpu/kernels/kernel-tuning.js +149 -0
- package/src/gpu/kernels/kv-quantize.d.ts +37 -0
- package/src/gpu/kernels/kv-quantize.js +138 -0
- package/src/gpu/kernels/kv_quantize_int4.wgsl +119 -0
- package/src/gpu/kernels/kv_quantize_int8.wgsl +119 -0
- package/src/gpu/kernels/layernorm.d.ts +37 -0
- package/src/gpu/kernels/layernorm.js +80 -0
- package/src/gpu/kernels/layernorm.wgsl +121 -0
- package/src/gpu/kernels/layernorm_f16.wgsl +103 -0
- package/src/gpu/kernels/linear-attention-core.d.ts +39 -0
- package/src/gpu/kernels/linear-attention-core.js +535 -0
- package/src/gpu/kernels/logit-merge.d.ts +110 -0
- package/src/gpu/kernels/logit-merge.js +392 -0
- package/src/gpu/kernels/matmul-dispatch.d.ts +38 -0
- package/src/gpu/kernels/matmul-dispatch.js +155 -0
- package/src/gpu/kernels/matmul-selection.d.ts +87 -0
- package/src/gpu/kernels/matmul-selection.js +474 -0
- package/src/gpu/kernels/matmul.d.ts +109 -0
- package/src/gpu/kernels/matmul.js +271 -0
- package/src/gpu/kernels/matmul_f16.wgsl +170 -0
- package/src/gpu/kernels/matmul_f16_tiled.wgsl +165 -0
- package/src/gpu/kernels/matmul_f16w_f32a.wgsl +89 -0
- package/src/gpu/kernels/matmul_f16w_f32a_tiled.wgsl +154 -0
- package/src/gpu/kernels/matmul_f32.wgsl +100 -0
- package/src/gpu/kernels/matmul_gemv.wgsl +80 -0
- package/src/gpu/kernels/matmul_gemv_f16a.wgsl +81 -0
- package/src/gpu/kernels/matmul_gemv_residual.wgsl +119 -0
- package/src/gpu/kernels/matmul_gemv_residual_f16.wgsl +78 -0
- package/src/gpu/kernels/matmul_gemv_subgroup.wgsl +345 -0
- package/src/gpu/kernels/matmul_gemv_subgroup_f16a.wgsl +514 -0
- package/src/gpu/kernels/modulate.d.ts +29 -0
- package/src/gpu/kernels/modulate.js +49 -0
- package/src/gpu/kernels/modulate.wgsl +40 -0
- package/src/gpu/kernels/modulate_f16.wgsl +43 -0
- package/src/gpu/kernels/moe.d.ts +164 -0
- package/src/gpu/kernels/moe.js +496 -0
- package/src/gpu/kernels/moe_gather.wgsl +170 -0
- package/src/gpu/kernels/moe_gather_f16.wgsl +82 -0
- package/src/gpu/kernels/moe_gather_vec4.wgsl +74 -0
- package/src/gpu/kernels/moe_offsets.wgsl +48 -0
- package/src/gpu/kernels/pipeline-cache.d.ts +88 -0
- package/src/gpu/kernels/pipeline-cache.js +305 -0
- package/src/gpu/kernels/pixel_shuffle.d.ts +27 -0
- package/src/gpu/kernels/pixel_shuffle.js +49 -0
- package/src/gpu/kernels/pixel_shuffle.wgsl +44 -0
- package/src/gpu/kernels/pixel_shuffle_f16.wgsl +47 -0
- package/src/gpu/kernels/residual.d.ts +74 -0
- package/src/gpu/kernels/residual.js +127 -0
- package/src/gpu/kernels/residual.wgsl +53 -0
- package/src/gpu/kernels/residual_f16.wgsl +35 -0
- package/src/gpu/kernels/residual_f16_vec4.wgsl +47 -0
- package/src/gpu/kernels/residual_vec4.wgsl +46 -0
- package/src/gpu/kernels/rmsnorm.d.ts +53 -0
- package/src/gpu/kernels/rmsnorm.js +140 -0
- package/src/gpu/kernels/rmsnorm.wgsl +417 -0
- package/src/gpu/kernels/rmsnorm_f16.wgsl +164 -0
- package/src/gpu/kernels/rope.d.ts +48 -0
- package/src/gpu/kernels/rope.js +53 -0
- package/src/gpu/kernels/rope.wgsl +328 -0
- package/src/gpu/kernels/rope_f16.wgsl +271 -0
- package/src/gpu/kernels/rule-matcher.d.ts +30 -0
- package/src/gpu/kernels/rule-matcher.js +42 -0
- package/src/gpu/kernels/rule-registry.d.ts +7 -0
- package/src/gpu/kernels/rule-registry.js +41 -0
- package/src/gpu/kernels/sample.d.ts +75 -0
- package/src/gpu/kernels/sample.js +578 -0
- package/src/gpu/kernels/sample.wgsl +377 -0
- package/src/gpu/kernels/sample_f16.wgsl +331 -0
- package/src/gpu/kernels/scale.d.ts +35 -0
- package/src/gpu/kernels/scale.js +37 -0
- package/src/gpu/kernels/scale.wgsl +38 -0
- package/src/gpu/kernels/scatter_add.wgsl +88 -0
- package/src/gpu/kernels/scatter_add_dynamic.wgsl +59 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16.wgsl +52 -0
- package/src/gpu/kernels/scatter_add_dynamic_f16_weights.wgsl +50 -0
- package/src/gpu/kernels/scatter_add_vec4.wgsl +70 -0
- package/src/gpu/kernels/shader-cache.d.ts +56 -0
- package/src/gpu/kernels/shader-cache.js +206 -0
- package/src/gpu/kernels/silu.d.ts +75 -0
- package/src/gpu/kernels/silu.js +340 -0
- package/src/gpu/kernels/silu.wgsl +99 -0
- package/src/gpu/kernels/silu_f16.wgsl +98 -0
- package/src/gpu/kernels/softmax.d.ts +57 -0
- package/src/gpu/kernels/softmax.js +106 -0
- package/src/gpu/kernels/softmax.wgsl +388 -0
- package/src/gpu/kernels/softmax_subgroup.wgsl +175 -0
- package/src/gpu/kernels/split_qkv.d.ts +51 -0
- package/src/gpu/kernels/split_qkv.js +41 -0
- package/src/gpu/kernels/split_qkv.wgsl +71 -0
- package/src/gpu/kernels/split_qkv_f16.wgsl +75 -0
- package/src/gpu/kernels/topk.wgsl +243 -0
- package/src/gpu/kernels/topk_f16.wgsl +108 -0
- package/src/gpu/kernels/topk_f16_weights.wgsl +101 -0
- package/src/gpu/kernels/transpose.d.ts +21 -0
- package/src/gpu/kernels/transpose.js +30 -0
- package/src/gpu/kernels/transpose.wgsl +32 -0
- package/src/gpu/kernels/types.d.ts +21 -0
- package/src/gpu/kernels/types.js +4 -0
- package/src/gpu/kernels/uniform-utils.d.ts +48 -0
- package/src/gpu/kernels/uniform-utils.js +94 -0
- package/src/gpu/kernels/upsample2d.d.ts +25 -0
- package/src/gpu/kernels/upsample2d.js +58 -0
- package/src/gpu/kernels/upsample2d.wgsl +37 -0
- package/src/gpu/kernels/upsample2d_f16.wgsl +41 -0
- package/src/gpu/kernels/utils.d.ts +106 -0
- package/src/gpu/kernels/utils.js +224 -0
- package/src/gpu/multi-model-recorder.d.ts +21 -0
- package/src/gpu/multi-model-recorder.js +31 -0
- package/src/gpu/partitioned-buffer-pool.d.ts +28 -0
- package/src/gpu/partitioned-buffer-pool.js +49 -0
- package/src/gpu/perf-guards.d.ts +25 -0
- package/src/gpu/perf-guards.js +140 -0
- package/src/gpu/profiler.d.ts +114 -0
- package/src/gpu/profiler.js +391 -0
- package/src/gpu/submit-tracker.d.ts +111 -0
- package/src/gpu/submit-tracker.js +229 -0
- package/src/gpu/tensor.d.ts +69 -0
- package/src/gpu/tensor.js +75 -0
- package/src/gpu/uniform-cache.d.ts +108 -0
- package/src/gpu/uniform-cache.js +242 -0
- package/src/gpu/weight-buffer.d.ts +115 -0
- package/src/gpu/weight-buffer.js +118 -0
- package/src/hotswap/intent-bundle.d.ts +37 -0
- package/src/hotswap/intent-bundle.js +123 -0
- package/src/hotswap/manifest.d.ts +33 -0
- package/src/hotswap/manifest.js +114 -0
- package/src/hotswap/runtime.d.ts +31 -0
- package/src/hotswap/runtime.js +128 -0
- package/src/index-browser.d.ts +47 -0
- package/src/index-browser.js +53 -0
- package/src/index-internal.d.ts +2 -0
- package/src/index-internal.js +2 -0
- package/src/index.d.ts +102 -0
- package/src/index.js +75 -0
- package/src/inference/README.md +593 -0
- package/src/inference/browser-harness.d.ts +234 -0
- package/src/inference/browser-harness.js +2665 -0
- package/src/inference/decode-buffers.d.ts +108 -0
- package/src/inference/decode-buffers.js +181 -0
- package/src/inference/decode-ring.d.ts +52 -0
- package/src/inference/decode-ring.js +273 -0
- package/src/inference/expert-router.d.ts +27 -0
- package/src/inference/expert-router.js +55 -0
- package/src/inference/functiongemma.d.ts +15 -0
- package/src/inference/functiongemma.js +1 -0
- package/src/inference/kv-cache/base.d.ts +150 -0
- package/src/inference/kv-cache/base.js +1037 -0
- package/src/inference/kv-cache/basis-decomposed-paged.d.ts +50 -0
- package/src/inference/kv-cache/basis-decomposed-paged.js +276 -0
- package/src/inference/kv-cache/index.d.ts +35 -0
- package/src/inference/kv-cache/index.js +20 -0
- package/src/inference/kv-cache/sliding-window.d.ts +72 -0
- package/src/inference/kv-cache/sliding-window.js +243 -0
- package/src/inference/kv-cache/tiered.d.ts +89 -0
- package/src/inference/kv-cache/tiered.js +574 -0
- package/src/inference/kv-cache/types.d.ts +188 -0
- package/src/inference/kv-cache/types.js +80 -0
- package/src/inference/kv-cache.d.ts +36 -0
- package/src/inference/kv-cache.js +18 -0
- package/src/inference/moe-router.d.ts +212 -0
- package/src/inference/moe-router.js +553 -0
- package/src/inference/multi-model-network.d.ts +139 -0
- package/src/inference/multi-model-network.js +769 -0
- package/src/inference/multi-pipeline-pool.d.ts +62 -0
- package/src/inference/multi-pipeline-pool.js +161 -0
- package/src/inference/network-evolution.d.ts +46 -0
- package/src/inference/network-evolution.js +80 -0
- package/src/inference/pipelines/context.d.ts +18 -0
- package/src/inference/pipelines/context.js +44 -0
- package/src/inference/pipelines/diffusion/helpers.d.ts +29 -0
- package/src/inference/pipelines/diffusion/helpers.js +112 -0
- package/src/inference/pipelines/diffusion/index.d.ts +3 -0
- package/src/inference/pipelines/diffusion/index.js +3 -0
- package/src/inference/pipelines/diffusion/init.d.ts +24 -0
- package/src/inference/pipelines/diffusion/init.js +124 -0
- package/src/inference/pipelines/diffusion/pipeline.d.ts +38 -0
- package/src/inference/pipelines/diffusion/pipeline.js +632 -0
- package/src/inference/pipelines/diffusion/scheduler.d.ts +19 -0
- package/src/inference/pipelines/diffusion/scheduler.js +65 -0
- package/src/inference/pipelines/diffusion/sd3-transformer.d.ts +20 -0
- package/src/inference/pipelines/diffusion/sd3-transformer.js +1194 -0
- package/src/inference/pipelines/diffusion/sd3-weights.d.ts +21 -0
- package/src/inference/pipelines/diffusion/sd3-weights.js +287 -0
- package/src/inference/pipelines/diffusion/text-encoder-gpu.d.ts +80 -0
- package/src/inference/pipelines/diffusion/text-encoder-gpu.js +935 -0
- package/src/inference/pipelines/diffusion/text-encoder.d.ts +29 -0
- package/src/inference/pipelines/diffusion/text-encoder.js +178 -0
- package/src/inference/pipelines/diffusion/types.d.ts +112 -0
- package/src/inference/pipelines/diffusion/types.js +1 -0
- package/src/inference/pipelines/diffusion/vae.d.ts +20 -0
- package/src/inference/pipelines/diffusion/vae.js +675 -0
- package/src/inference/pipelines/diffusion/weights.d.ts +40 -0
- package/src/inference/pipelines/diffusion/weights.js +150 -0
- package/src/inference/pipelines/dream/energy-head-pipeline.d.ts +29 -0
- package/src/inference/pipelines/dream/energy-head-pipeline.js +6 -0
- package/src/inference/pipelines/dream/pipeline.d.ts +17 -0
- package/src/inference/pipelines/dream/pipeline.js +8 -0
- package/src/inference/pipelines/energy/index.d.ts +1 -0
- package/src/inference/pipelines/energy/index.js +1 -0
- package/src/inference/pipelines/energy/pipeline.d.ts +27 -0
- package/src/inference/pipelines/energy/pipeline.js +680 -0
- package/src/inference/pipelines/energy/quintel.d.ts +87 -0
- package/src/inference/pipelines/energy/quintel.js +207 -0
- package/src/inference/pipelines/energy/types.d.ts +63 -0
- package/src/inference/pipelines/energy/types.js +1 -0
- package/src/inference/pipelines/energy-head/index.d.ts +6 -0
- package/src/inference/pipelines/energy-head/index.js +6 -0
- package/src/inference/pipelines/energy-head/row-head-pipeline.d.ts +103 -0
- package/src/inference/pipelines/energy-head/row-head-pipeline.js +487 -0
- package/src/inference/pipelines/factory.d.ts +10 -0
- package/src/inference/pipelines/factory.js +6 -0
- package/src/inference/pipelines/index.d.ts +22 -0
- package/src/inference/pipelines/index.js +19 -0
- package/src/inference/pipelines/registry.d.ts +15 -0
- package/src/inference/pipelines/registry.js +23 -0
- package/src/inference/pipelines/rng.d.ts +2 -0
- package/src/inference/pipelines/rng.js +17 -0
- package/src/inference/pipelines/structured/index.d.ts +8 -0
- package/src/inference/pipelines/structured/index.js +8 -0
- package/src/inference/pipelines/structured/json-head-pipeline.d.ts +58 -0
- package/src/inference/pipelines/structured/json-head-pipeline.js +181 -0
- package/src/inference/pipelines/text/attention/index.d.ts +24 -0
- package/src/inference/pipelines/text/attention/index.js +17 -0
- package/src/inference/pipelines/text/attention/projections.d.ts +101 -0
- package/src/inference/pipelines/text/attention/projections.js +435 -0
- package/src/inference/pipelines/text/attention/record.d.ts +36 -0
- package/src/inference/pipelines/text/attention/record.js +613 -0
- package/src/inference/pipelines/text/attention/run.d.ts +38 -0
- package/src/inference/pipelines/text/attention/run.js +826 -0
- package/src/inference/pipelines/text/attention/types.d.ts +98 -0
- package/src/inference/pipelines/text/attention/types.js +67 -0
- package/src/inference/pipelines/text/attention.d.ts +23 -0
- package/src/inference/pipelines/text/attention.js +12 -0
- package/src/inference/pipelines/text/bdpa-steamroller.d.ts +22 -0
- package/src/inference/pipelines/text/bdpa-steamroller.js +158 -0
- package/src/inference/pipelines/text/buffer-types.d.ts +7 -0
- package/src/inference/pipelines/text/buffer-types.js +4 -0
- package/src/inference/pipelines/text/chat-format.d.ts +46 -0
- package/src/inference/pipelines/text/chat-format.js +366 -0
- package/src/inference/pipelines/text/config.d.ts +235 -0
- package/src/inference/pipelines/text/config.js +623 -0
- package/src/inference/pipelines/text/debug-utils/config.d.ts +144 -0
- package/src/inference/pipelines/text/debug-utils/config.js +156 -0
- package/src/inference/pipelines/text/debug-utils/index.d.ts +53 -0
- package/src/inference/pipelines/text/debug-utils/index.js +44 -0
- package/src/inference/pipelines/text/debug-utils/logging.d.ts +106 -0
- package/src/inference/pipelines/text/debug-utils/logging.js +152 -0
- package/src/inference/pipelines/text/debug-utils/tensor.d.ts +119 -0
- package/src/inference/pipelines/text/debug-utils/tensor.js +268 -0
- package/src/inference/pipelines/text/debug-utils/utils.d.ts +77 -0
- package/src/inference/pipelines/text/debug-utils/utils.js +139 -0
- package/src/inference/pipelines/text/debug-utils.d.ts +42 -0
- package/src/inference/pipelines/text/debug-utils.js +34 -0
- package/src/inference/pipelines/text/embed.d.ts +67 -0
- package/src/inference/pipelines/text/embed.js +461 -0
- package/src/inference/pipelines/text/execution-plan.d.ts +116 -0
- package/src/inference/pipelines/text/execution-plan.js +314 -0
- package/src/inference/pipelines/text/execution-v0.d.ts +66 -0
- package/src/inference/pipelines/text/execution-v0.js +1139 -0
- package/src/inference/pipelines/text/ffn/dense.d.ts +40 -0
- package/src/inference/pipelines/text/ffn/dense.js +759 -0
- package/src/inference/pipelines/text/ffn/index.d.ts +23 -0
- package/src/inference/pipelines/text/ffn/index.js +16 -0
- package/src/inference/pipelines/text/ffn/moe.d.ts +21 -0
- package/src/inference/pipelines/text/ffn/moe.js +49 -0
- package/src/inference/pipelines/text/ffn/sandwich.d.ts +25 -0
- package/src/inference/pipelines/text/ffn/sandwich.js +196 -0
- package/src/inference/pipelines/text/ffn/standard.d.ts +23 -0
- package/src/inference/pipelines/text/ffn/standard.js +84 -0
- package/src/inference/pipelines/text/ffn/types.d.ts +30 -0
- package/src/inference/pipelines/text/ffn/types.js +25 -0
- package/src/inference/pipelines/text/ffn.d.ts +31 -0
- package/src/inference/pipelines/text/ffn.js +18 -0
- package/src/inference/pipelines/text/finiteness-guard-status.d.ts +11 -0
- package/src/inference/pipelines/text/finiteness-guard-status.js +21 -0
- package/src/inference/pipelines/text/finiteness-policy.d.ts +35 -0
- package/src/inference/pipelines/text/finiteness-policy.js +45 -0
- package/src/inference/pipelines/text/generator-helpers.d.ts +34 -0
- package/src/inference/pipelines/text/generator-helpers.js +175 -0
- package/src/inference/pipelines/text/generator-runtime.d.ts +93 -0
- package/src/inference/pipelines/text/generator-runtime.js +373 -0
- package/src/inference/pipelines/text/generator-steps.d.ts +75 -0
- package/src/inference/pipelines/text/generator-steps.js +1078 -0
- package/src/inference/pipelines/text/generator.d.ts +41 -0
- package/src/inference/pipelines/text/generator.js +1345 -0
- package/src/inference/pipelines/text/index.d.ts +5 -0
- package/src/inference/pipelines/text/index.js +6 -0
- package/src/inference/pipelines/text/init.d.ts +295 -0
- package/src/inference/pipelines/text/init.js +965 -0
- package/src/inference/pipelines/text/kernel-path-auto-select.d.ts +12 -0
- package/src/inference/pipelines/text/kernel-path-auto-select.js +90 -0
- package/src/inference/pipelines/text/kernel-trace.d.ts +150 -0
- package/src/inference/pipelines/text/kernel-trace.js +324 -0
- package/src/inference/pipelines/text/layer-plan.d.ts +65 -0
- package/src/inference/pipelines/text/layer-plan.js +249 -0
- package/src/inference/pipelines/text/layer.d.ts +56 -0
- package/src/inference/pipelines/text/layer.js +916 -0
- package/src/inference/pipelines/text/linear-attention.d.ts +94 -0
- package/src/inference/pipelines/text/linear-attention.js +803 -0
- package/src/inference/pipelines/text/logits/cpu.d.ts +81 -0
- package/src/inference/pipelines/text/logits/cpu.js +91 -0
- package/src/inference/pipelines/text/logits/gpu.d.ts +113 -0
- package/src/inference/pipelines/text/logits/gpu.js +406 -0
- package/src/inference/pipelines/text/logits/index.d.ts +57 -0
- package/src/inference/pipelines/text/logits/index.js +305 -0
- package/src/inference/pipelines/text/logits/types.d.ts +46 -0
- package/src/inference/pipelines/text/logits/types.js +4 -0
- package/src/inference/pipelines/text/logits/utils.d.ts +49 -0
- package/src/inference/pipelines/text/logits/utils.js +59 -0
- package/src/inference/pipelines/text/logits.d.ts +27 -0
- package/src/inference/pipelines/text/logits.js +16 -0
- package/src/inference/pipelines/text/lora-apply.d.ts +28 -0
- package/src/inference/pipelines/text/lora-apply.js +58 -0
- package/src/inference/pipelines/text/lora-types.d.ts +39 -0
- package/src/inference/pipelines/text/lora-types.js +18 -0
- package/src/inference/pipelines/text/lora.d.ts +18 -0
- package/src/inference/pipelines/text/lora.js +12 -0
- package/src/inference/pipelines/text/model-load.d.ts +58 -0
- package/src/inference/pipelines/text/model-load.js +561 -0
- package/src/inference/pipelines/text/moe-cache.d.ts +32 -0
- package/src/inference/pipelines/text/moe-cache.js +107 -0
- package/src/inference/pipelines/text/moe-cpu-gptoss.d.ts +9 -0
- package/src/inference/pipelines/text/moe-cpu-gptoss.js +110 -0
- package/src/inference/pipelines/text/moe-cpu.d.ts +13 -0
- package/src/inference/pipelines/text/moe-cpu.js +116 -0
- package/src/inference/pipelines/text/moe-gpu.d.ts +13 -0
- package/src/inference/pipelines/text/moe-gpu.js +611 -0
- package/src/inference/pipelines/text/moe-helpers.d.ts +12 -0
- package/src/inference/pipelines/text/moe-helpers.js +21 -0
- package/src/inference/pipelines/text/moe-impl.d.ts +117 -0
- package/src/inference/pipelines/text/moe-impl.js +9 -0
- package/src/inference/pipelines/text/moe-shape-validator.d.ts +31 -0
- package/src/inference/pipelines/text/moe-shape-validator.js +78 -0
- package/src/inference/pipelines/text/ops.d.ts +167 -0
- package/src/inference/pipelines/text/ops.js +367 -0
- package/src/inference/pipelines/text/probes.d.ts +31 -0
- package/src/inference/pipelines/text/probes.js +170 -0
- package/src/inference/pipelines/text/sampling.d.ts +54 -0
- package/src/inference/pipelines/text/sampling.js +203 -0
- package/src/inference/pipelines/text/state.d.ts +112 -0
- package/src/inference/pipelines/text/state.js +152 -0
- package/src/inference/pipelines/text/types.d.ts +627 -0
- package/src/inference/pipelines/text/types.js +4 -0
- package/src/inference/pipelines/text/weights.d.ts +110 -0
- package/src/inference/pipelines/text/weights.js +163 -0
- package/src/inference/pipelines/text.d.ts +157 -0
- package/src/inference/pipelines/text.js +586 -0
- package/src/inference/speculative.d.ts +239 -0
- package/src/inference/speculative.js +416 -0
- package/src/inference/test-harness.d.ts +178 -0
- package/src/inference/test-harness.js +349 -0
- package/src/inference/tokenizer.d.ts +77 -0
- package/src/inference/tokenizer.js +258 -0
- package/src/inference/tokenizers/base.d.ts +39 -0
- package/src/inference/tokenizers/base.js +69 -0
- package/src/inference/tokenizers/bpe.d.ts +27 -0
- package/src/inference/tokenizers/bpe.js +171 -0
- package/src/inference/tokenizers/bundled.d.ts +63 -0
- package/src/inference/tokenizers/bundled.js +866 -0
- package/src/inference/tokenizers/sentencepiece.d.ts +28 -0
- package/src/inference/tokenizers/sentencepiece.js +389 -0
- package/src/inference/tokenizers/types.d.ts +166 -0
- package/src/inference/tokenizers/types.js +7 -0
- package/src/loader/doppler-loader.d.ts +134 -0
- package/src/loader/doppler-loader.js +1036 -0
- package/src/loader/dtype-utils.d.ts +40 -0
- package/src/loader/dtype-utils.js +102 -0
- package/src/loader/embedding-loader.d.ts +56 -0
- package/src/loader/embedding-loader.js +207 -0
- package/src/loader/experts/expert-cache.d.ts +156 -0
- package/src/loader/experts/expert-cache.js +375 -0
- package/src/loader/experts/expert-loader.d.ts +108 -0
- package/src/loader/experts/expert-loader.js +384 -0
- package/src/loader/final-weights-loader.d.ts +68 -0
- package/src/loader/final-weights-loader.js +262 -0
- package/src/loader/index.d.ts +150 -0
- package/src/loader/index.js +124 -0
- package/src/loader/layer-loader.d.ts +63 -0
- package/src/loader/layer-loader.js +417 -0
- package/src/loader/loader-state.d.ts +51 -0
- package/src/loader/loader-state.js +142 -0
- package/src/loader/loader-types.d.ts +236 -0
- package/src/loader/loader-types.js +4 -0
- package/src/loader/manifest-config.d.ts +97 -0
- package/src/loader/manifest-config.js +132 -0
- package/src/loader/memory-monitor.d.ts +112 -0
- package/src/loader/memory-monitor.js +276 -0
- package/src/loader/multi-model-loader.d.ts +37 -0
- package/src/loader/multi-model-loader.js +87 -0
- package/src/loader/quantization-constants.d.ts +23 -0
- package/src/loader/quantization-constants.js +14 -0
- package/src/loader/shard-cache.d.ts +60 -0
- package/src/loader/shard-cache.js +568 -0
- package/src/loader/shard-resolver.d.ts +12 -0
- package/src/loader/shard-resolver.js +83 -0
- package/src/loader/tensors/tensor-loader.d.ts +154 -0
- package/src/loader/tensors/tensor-loader.js +427 -0
- package/src/loader/tensors/tensor-reader.d.ts +22 -0
- package/src/loader/tensors/tensor-reader.js +56 -0
- package/src/loader/tensors/tensor-role.d.ts +7 -0
- package/src/loader/tensors/tensor-role.js +12 -0
- package/src/loader/weight-downcast.d.ts +62 -0
- package/src/loader/weight-downcast.js +213 -0
- package/src/loader/weights.d.ts +22 -0
- package/src/loader/weights.js +4 -0
- package/src/memory/address-table.d.ts +104 -0
- package/src/memory/address-table.js +114 -0
- package/src/memory/buffer-pool.d.ts +196 -0
- package/src/memory/buffer-pool.js +756 -0
- package/src/memory/capability.d.ts +49 -0
- package/src/memory/capability.js +95 -0
- package/src/memory/heap-manager.d.ts +104 -0
- package/src/memory/heap-manager.js +264 -0
- package/src/memory/unified-detect.d.ts +59 -0
- package/src/memory/unified-detect.js +192 -0
- package/src/rules/converter/execution.rules.json +20 -0
- package/src/rules/converter/tensor-roles.rules.json +13 -0
- package/src/rules/converter/tokenizer.rules.json +7 -0
- package/src/rules/inference/attention.rules.json +54 -0
- package/src/rules/inference/config.rules.json +58 -0
- package/src/rules/inference/dtype.rules.json +94 -0
- package/src/rules/inference/execution.rules.json +45 -0
- package/src/rules/inference/ffn.rules.json +35 -0
- package/src/rules/inference/kernel-path.rules.json +76 -0
- package/src/rules/inference/layer-pattern.rules.json +16 -0
- package/src/rules/inference/layer.rules.json +7 -0
- package/src/rules/inference/moe.rules.json +48 -0
- package/src/rules/kernels/attention.rules.json +61 -0
- package/src/rules/kernels/conv2d.rules.json +6 -0
- package/src/rules/kernels/dequant.rules.json +58 -0
- package/src/rules/kernels/energy.rules.json +22 -0
- package/src/rules/kernels/fused-ffn.rules.json +13 -0
- package/src/rules/kernels/fused-matmul-residual.rules.json +6 -0
- package/src/rules/kernels/fused-matmul-rmsnorm.rules.json +8 -0
- package/src/rules/kernels/gather.rules.json +12 -0
- package/src/rules/kernels/gelu.rules.json +11 -0
- package/src/rules/kernels/groupnorm.rules.json +10 -0
- package/src/rules/kernels/kernel-validator.d.ts +24 -0
- package/src/rules/kernels/kernel-validator.js +160 -0
- package/src/rules/kernels/kv_quantize.rules.json +7 -0
- package/src/rules/kernels/layernorm.rules.json +6 -0
- package/src/rules/kernels/matmul.rules.json +60 -0
- package/src/rules/kernels/modulate.rules.json +6 -0
- package/src/rules/kernels/moe.rules.gptoss.json +105 -0
- package/src/rules/kernels/moe.rules.json +11 -0
- package/src/rules/kernels/pixel_shuffle.rules.json +6 -0
- package/src/rules/kernels/residual.rules.json +12 -0
- package/src/rules/kernels/rmsnorm.rules.json +11 -0
- package/src/rules/kernels/rope.rules.json +6 -0
- package/src/rules/kernels/sample.rules.json +6 -0
- package/src/rules/kernels/scale.rules.json +6 -0
- package/src/rules/kernels/silu.rules.json +21 -0
- package/src/rules/kernels/softmax.rules.json +23 -0
- package/src/rules/kernels/split-qkv.rules.json +6 -0
- package/src/rules/kernels/upsample2d.rules.json +6 -0
- package/src/rules/loader/tensor-loader.rules.json +15 -0
- package/src/rules/loader/weights.rules.json +41 -0
- package/src/rules/rule-registry.d.ts +48 -0
- package/src/rules/rule-registry.js +177 -0
- package/src/rules/tooling/command-runtime.rules.json +38 -0
- package/src/storage/backends/idb-store.d.ts +52 -0
- package/src/storage/backends/idb-store.js +590 -0
- package/src/storage/backends/memory-store.d.ts +36 -0
- package/src/storage/backends/memory-store.js +242 -0
- package/src/storage/backends/opfs-store.d.ts +41 -0
- package/src/storage/backends/opfs-store.js +429 -0
- package/src/storage/blake3.d.ts +17 -0
- package/src/storage/blake3.js +269 -0
- package/src/storage/download-types.d.ts +157 -0
- package/src/storage/download-types.js +48 -0
- package/src/storage/downloader.d.ts +103 -0
- package/src/storage/downloader.js +839 -0
- package/src/storage/emulated-vram.d.ts +264 -0
- package/src/storage/emulated-vram.js +576 -0
- package/src/storage/export.d.ts +20 -0
- package/src/storage/export.js +159 -0
- package/src/storage/index.d.ts +253 -0
- package/src/storage/index.js +185 -0
- package/src/storage/inventory.d.ts +26 -0
- package/src/storage/inventory.js +218 -0
- package/src/storage/preflight.d.ts +144 -0
- package/src/storage/preflight.js +294 -0
- package/src/storage/quickstart-downloader.d.ts +154 -0
- package/src/storage/quickstart-downloader.js +265 -0
- package/src/storage/quota.d.ts +150 -0
- package/src/storage/quota.js +304 -0
- package/src/storage/registry.d.ts +28 -0
- package/src/storage/registry.js +125 -0
- package/src/storage/reports.d.ts +20 -0
- package/src/storage/reports.js +94 -0
- package/src/storage/shard-manager.d.ts +137 -0
- package/src/storage/shard-manager.js +801 -0
- package/src/sw.d.ts +1 -0
- package/src/sw.js +187 -0
- package/src/tooling/browser-command-runner.d.ts +28 -0
- package/src/tooling/browser-command-runner.js +82 -0
- package/src/tooling/command-api.d.ts +147 -0
- package/src/tooling/command-api.js +523 -0
- package/src/tooling/command-envelope.d.ts +81 -0
- package/src/tooling/command-envelope.js +195 -0
- package/src/tooling/command-runner-shared.d.ts +73 -0
- package/src/tooling/command-runner-shared.js +146 -0
- package/src/tooling/command-runner.html +45 -0
- package/src/tooling/node-browser-command-runner.d.ts +30 -0
- package/src/tooling/node-browser-command-runner.js +868 -0
- package/src/tooling/node-command-runner.d.ts +36 -0
- package/src/tooling/node-command-runner.js +127 -0
- package/src/tooling/node-convert-worker-pool.d.ts +16 -0
- package/src/tooling/node-convert-worker-pool.js +186 -0
- package/src/tooling/node-convert-worker.d.ts +1 -0
- package/src/tooling/node-convert-worker.js +60 -0
- package/src/tooling/node-convert.d.ts +44 -0
- package/src/tooling/node-converter.d.ts +1 -0
- package/src/tooling/node-converter.js +1227 -0
- package/src/tooling/node-file-fetch.d.ts +1 -0
- package/src/tooling/node-file-fetch.js +38 -0
- package/src/tooling/node-source-runtime.d.ts +19 -0
- package/src/tooling/node-source-runtime.js +469 -0
- package/src/tooling/node-webgpu.d.ts +6 -0
- package/src/tooling/node-webgpu.js +321 -0
- package/src/tooling/opfs-cache.d.ts +11 -0
- package/src/tooling/opfs-cache.js +174 -0
- package/src/tooling/source-runtime-bundle.d.ts +102 -0
- package/src/tooling/source-runtime-bundle.js +484 -0
- package/src/tooling-exports.browser.d.ts +7 -0
- package/src/tooling-exports.browser.js +2 -0
- package/src/tooling-exports.d.ts +22 -0
- package/src/tooling-exports.js +7 -0
- package/src/tooling-exports.shared.d.ts +105 -0
- package/src/tooling-exports.shared.js +92 -0
- package/src/training/README.md +153 -0
- package/src/training/artifacts.d.ts +160 -0
- package/src/training/artifacts.js +896 -0
- package/src/training/attention-backward.d.ts +30 -0
- package/src/training/attention-backward.js +217 -0
- package/src/training/attention-forward.d.ts +22 -0
- package/src/training/attention-forward.js +82 -0
- package/src/training/autograd.d.ts +51 -0
- package/src/training/autograd.js +380 -0
- package/src/training/checkpoint.d.ts +31 -0
- package/src/training/checkpoint.js +238 -0
- package/src/training/clip.d.ts +9 -0
- package/src/training/clip.js +54 -0
- package/src/training/dataloader.d.ts +8 -0
- package/src/training/dataloader.js +44 -0
- package/src/training/datasets/index.d.ts +12 -0
- package/src/training/datasets/index.js +6 -0
- package/src/training/datasets/jsonl.d.ts +11 -0
- package/src/training/datasets/jsonl.js +50 -0
- package/src/training/datasets/reploid.d.ts +3 -0
- package/src/training/datasets/reploid.js +36 -0
- package/src/training/datasets/text-pairs.d.ts +21 -0
- package/src/training/datasets/text-pairs.js +42 -0
- package/src/training/datasets/token-batch.d.ts +21 -0
- package/src/training/datasets/token-batch.js +40 -0
- package/src/training/datasets/translation-pairs.d.ts +34 -0
- package/src/training/datasets/translation-pairs.js +49 -0
- package/src/training/export.d.ts +32 -0
- package/src/training/export.js +112 -0
- package/src/training/index.d.ts +52 -0
- package/src/training/index.js +41 -0
- package/src/training/lora.d.ts +19 -0
- package/src/training/lora.js +57 -0
- package/src/training/loss-scaling.d.ts +21 -0
- package/src/training/loss-scaling.js +80 -0
- package/src/training/loss.d.ts +10 -0
- package/src/training/loss.js +41 -0
- package/src/training/objectives/base.d.ts +58 -0
- package/src/training/objectives/base.js +38 -0
- package/src/training/objectives/cross_entropy.d.ts +18 -0
- package/src/training/objectives/cross_entropy.js +37 -0
- package/src/training/objectives/distill_kd.d.ts +16 -0
- package/src/training/objectives/distill_kd.js +369 -0
- package/src/training/objectives/distill_triplet.d.ts +16 -0
- package/src/training/objectives/distill_triplet.js +412 -0
- package/src/training/objectives/index.d.ts +12 -0
- package/src/training/objectives/index.js +6 -0
- package/src/training/objectives/ul_stage1_joint.d.ts +16 -0
- package/src/training/objectives/ul_stage1_joint.js +188 -0
- package/src/training/objectives/ul_stage2_base.d.ts +16 -0
- package/src/training/objectives/ul_stage2_base.js +222 -0
- package/src/training/optimizer.d.ts +22 -0
- package/src/training/optimizer.js +115 -0
- package/src/training/runner.d.ts +196 -0
- package/src/training/runner.js +1194 -0
- package/src/training/suite.d.ts +187 -0
- package/src/training/suite.js +3156 -0
- package/src/training/trainer.d.ts +89 -0
- package/src/training/trainer.js +301 -0
- package/src/training/ul_dataset.d.ts +47 -0
- package/src/training/ul_dataset.js +153 -0
- package/src/training/ul_schedule.d.ts +6 -0
- package/src/training/ul_schedule.js +29 -0
- package/src/types/chrome.d.ts +36 -0
- package/src/types/chrome.js +1 -0
- package/src/types/gpu.d.ts +185 -0
- package/src/types/gpu.js +5 -0
- package/src/types/index.d.ts +3 -0
- package/src/types/index.js +3 -0
- package/src/types/inference.d.ts +197 -0
- package/src/types/inference.js +5 -0
- package/src/types/model.d.ts +125 -0
- package/src/types/model.js +5 -0
- package/src/utils/index.d.ts +7 -0
- package/src/utils/index.js +7 -0
- package/src/utils/load-json.d.ts +5 -0
- package/src/utils/load-json.js +23 -0
- package/src/utils/plain-object.d.ts +1 -0
- package/src/utils/plain-object.js +3 -0
- package/src/utils/sha256.d.ts +4 -0
- package/src/utils/sha256.js +135 -0
- package/tools/convert-safetensors-node.js +180 -0
- package/tools/doppler-cli.js +1170 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Compare embeddings and layer outputs between HuggingFace and DOPPLER.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python hf_embed_check.py <config.json>
|
|
7
|
+
|
|
8
|
+
Config (JSON):
|
|
9
|
+
{
|
|
10
|
+
"model": "google/gemma-2-2b-it",
|
|
11
|
+
"prompt": "The color of the sky is"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
Requires: pip install torch transformers
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import sys
|
|
19
|
+
import torch
|
|
20
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_config():
|
|
24
|
+
if len(sys.argv) != 2:
|
|
25
|
+
raise SystemExit("Usage: python hf_embed_check.py <config.json>")
|
|
26
|
+
path = sys.argv[1]
|
|
27
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
28
|
+
config = json.load(handle)
|
|
29
|
+
if not isinstance(config, dict):
|
|
30
|
+
raise SystemExit("Config must be a JSON object")
|
|
31
|
+
return config
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def require_string(config, key):
|
|
35
|
+
value = config.get(key)
|
|
36
|
+
if not isinstance(value, str) or not value.strip():
|
|
37
|
+
raise SystemExit(f'Config "{key}" must be a non-empty string')
|
|
38
|
+
return value
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def main():
|
|
42
|
+
config = load_config()
|
|
43
|
+
model_id = require_string(config, "model")
|
|
44
|
+
prompt = require_string(config, "prompt")
|
|
45
|
+
|
|
46
|
+
print(f"Loading model: {model_id}")
|
|
47
|
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="cpu")
|
|
48
|
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
49
|
+
|
|
50
|
+
inputs = tokenizer(prompt, return_tensors="pt")
|
|
51
|
+
input_ids = inputs['input_ids']
|
|
52
|
+
|
|
53
|
+
print(f"\nPrompt: {prompt}")
|
|
54
|
+
print(f"Token IDs: {input_ids[0].tolist()}")
|
|
55
|
+
|
|
56
|
+
# Get embeddings (raw, not scaled)
|
|
57
|
+
raw_embeddings = model.model.embed_tokens(input_ids)
|
|
58
|
+
print(f"\nRaw embeddings shape: {raw_embeddings.shape}")
|
|
59
|
+
print(f"Raw embeddings (last token first 5): {raw_embeddings[0, -1, :5].tolist()}")
|
|
60
|
+
|
|
61
|
+
# Gemma scales embeddings by sqrt(hidden_size)
|
|
62
|
+
hidden_size = model.config.hidden_size
|
|
63
|
+
scaled_embeddings = raw_embeddings * (hidden_size ** 0.5)
|
|
64
|
+
print(f"Scaled embeddings (last token first 5): {scaled_embeddings[0, -1, :5].tolist()}")
|
|
65
|
+
|
|
66
|
+
# Get layer 0 output via hooks
|
|
67
|
+
layer0_outputs = {}
|
|
68
|
+
|
|
69
|
+
def hook_layer0_output(module, input, output):
|
|
70
|
+
layer0_outputs['output'] = output[0].detach()
|
|
71
|
+
|
|
72
|
+
model.model.layers[0].register_forward_hook(hook_layer0_output)
|
|
73
|
+
|
|
74
|
+
# Run forward pass
|
|
75
|
+
with torch.no_grad():
|
|
76
|
+
outputs = model(input_ids, output_hidden_states=True)
|
|
77
|
+
|
|
78
|
+
print(f"\nLayer 0 output (last token first 5): {layer0_outputs['output'][0, -1, :5].tolist()}")
|
|
79
|
+
|
|
80
|
+
# Per-token comparison
|
|
81
|
+
print(f"\nPer-token maxAbs comparison:")
|
|
82
|
+
for t in range(inputs['input_ids'].shape[1]):
|
|
83
|
+
emb_max = scaled_embeddings[0, t].abs().max().item()
|
|
84
|
+
l0_max = layer0_outputs['output'][0, t].abs().max().item()
|
|
85
|
+
print(f" Token {t}: emb_maxAbs={emb_max:.2f}, L0_maxAbs={l0_max:.2f}")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
main()
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Compare layer outputs at each layer between HuggingFace and DOPPLER.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python hf_layer_out.py <config.json>
|
|
7
|
+
|
|
8
|
+
Config (JSON):
|
|
9
|
+
{
|
|
10
|
+
"model": "google/gemma-2-2b-it",
|
|
11
|
+
"prompt": "The color of the sky is",
|
|
12
|
+
"layers": [0, 12, 25],
|
|
13
|
+
"token": -1
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Requires: pip install torch transformers
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import sys
|
|
21
|
+
import torch
|
|
22
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
if len(sys.argv) != 2:
|
|
27
|
+
raise SystemExit("Usage: python hf_layer_out.py <config.json>")
|
|
28
|
+
path = sys.argv[1]
|
|
29
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
30
|
+
config = json.load(handle)
|
|
31
|
+
if not isinstance(config, dict):
|
|
32
|
+
raise SystemExit("Config must be a JSON object")
|
|
33
|
+
|
|
34
|
+
model_id = config.get("model")
|
|
35
|
+
prompt = config.get("prompt")
|
|
36
|
+
layers = config.get("layers")
|
|
37
|
+
token = config.get("token")
|
|
38
|
+
|
|
39
|
+
if not isinstance(model_id, str) or not model_id.strip():
|
|
40
|
+
raise SystemExit('Config "model" must be a non-empty string')
|
|
41
|
+
if not isinstance(prompt, str) or not prompt.strip():
|
|
42
|
+
raise SystemExit('Config "prompt" must be a non-empty string')
|
|
43
|
+
if not isinstance(layers, list) or not layers:
|
|
44
|
+
raise SystemExit('Config "layers" must be a non-empty array')
|
|
45
|
+
if not all(isinstance(x, int) for x in layers):
|
|
46
|
+
raise SystemExit('Config "layers" entries must be integers')
|
|
47
|
+
if not isinstance(token, int):
|
|
48
|
+
raise SystemExit('Config "token" must be an integer')
|
|
49
|
+
|
|
50
|
+
layer_indices = layers
|
|
51
|
+
|
|
52
|
+
print(f"Loading model: {model_id}")
|
|
53
|
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="cpu")
|
|
54
|
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
55
|
+
|
|
56
|
+
inputs = tokenizer(prompt, return_tensors="pt")
|
|
57
|
+
input_ids = inputs['input_ids']
|
|
58
|
+
num_tokens = input_ids.shape[1]
|
|
59
|
+
token_idx = token if token >= 0 else num_tokens + token
|
|
60
|
+
|
|
61
|
+
print(f"\nPrompt: {prompt}")
|
|
62
|
+
print(f"Token IDs: {input_ids[0].tolist()}")
|
|
63
|
+
print(f"Checking token index: {token_idx}")
|
|
64
|
+
|
|
65
|
+
# Run forward pass with hidden states
|
|
66
|
+
with torch.no_grad():
|
|
67
|
+
outputs = model(input_ids, output_hidden_states=True)
|
|
68
|
+
|
|
69
|
+
hidden_states = outputs.hidden_states # Tuple of [batch, seq, hidden]
|
|
70
|
+
print(f"\nNum hidden states: {len(hidden_states)} (embed + {len(hidden_states)-1} layers)")
|
|
71
|
+
|
|
72
|
+
for layer_idx in layer_indices:
|
|
73
|
+
if layer_idx >= len(hidden_states) - 1:
|
|
74
|
+
print(f"\nLayer {layer_idx}: OUT OF RANGE")
|
|
75
|
+
continue
|
|
76
|
+
|
|
77
|
+
# hidden_states[0] = embeddings, hidden_states[1] = layer 0 output, etc.
|
|
78
|
+
hs = hidden_states[layer_idx + 1] # +1 because index 0 is embeddings
|
|
79
|
+
|
|
80
|
+
vals = hs[0, token_idx, :8].tolist()
|
|
81
|
+
max_abs = hs[0, token_idx].abs().max().item()
|
|
82
|
+
mean_abs = hs[0, token_idx].abs().mean().item()
|
|
83
|
+
|
|
84
|
+
print(f"\nLayer {layer_idx} output (token {token_idx}):")
|
|
85
|
+
print(f" First 8: {[f'{v:.4f}' for v in vals]}")
|
|
86
|
+
print(f" maxAbs: {max_abs:.4f}, meanAbs: {mean_abs:.4f}")
|
|
87
|
+
|
|
88
|
+
# Also show BOS (token 0) for comparison
|
|
89
|
+
print(f"\n--- BOS Token (position 0) for reference ---")
|
|
90
|
+
for layer_idx in layer_indices:
|
|
91
|
+
if layer_idx >= len(hidden_states) - 1:
|
|
92
|
+
continue
|
|
93
|
+
hs = hidden_states[layer_idx + 1]
|
|
94
|
+
vals = hs[0, 0, :8].tolist()
|
|
95
|
+
max_abs = hs[0, 0].abs().max().item()
|
|
96
|
+
print(f"Layer {layer_idx} (BOS): first8={[f'{v:.4f}' for v in vals]}, maxAbs={max_abs:.4f}")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == "__main__":
|
|
100
|
+
main()
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Verify RoPE (Rotary Position Embedding) values match between HF and DOPPLER.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python hf_rope_check.py <config.json>
|
|
7
|
+
|
|
8
|
+
Config (JSON):
|
|
9
|
+
{
|
|
10
|
+
"model": "google/gemma-2-2b-it",
|
|
11
|
+
"pos": 6,
|
|
12
|
+
"dim": 256,
|
|
13
|
+
"theta": 10000.0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Requires: pip install torch transformers
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import json
|
|
20
|
+
import math
|
|
21
|
+
import sys
|
|
22
|
+
import torch
|
|
23
|
+
from transformers import AutoModelForCausalLM
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def compute_rope_freqs(head_dim: int, theta: float = 10000.0):
|
|
27
|
+
"""Compute RoPE frequencies for a given head dimension."""
|
|
28
|
+
freqs = 1.0 / (theta ** (torch.arange(0, head_dim, 2).float() / head_dim))
|
|
29
|
+
return freqs
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def apply_rope_to_vector(x: torch.Tensor, pos: int, freqs: torch.Tensor):
|
|
33
|
+
"""Apply RoPE to a single vector at a given position."""
|
|
34
|
+
# x shape: [head_dim]
|
|
35
|
+
angles = pos * freqs
|
|
36
|
+
cos = torch.cos(angles)
|
|
37
|
+
sin = torch.sin(angles)
|
|
38
|
+
|
|
39
|
+
# Split into pairs
|
|
40
|
+
x_even = x[0::2]
|
|
41
|
+
x_odd = x[1::2]
|
|
42
|
+
|
|
43
|
+
# Apply rotation
|
|
44
|
+
out_even = x_even * cos - x_odd * sin
|
|
45
|
+
out_odd = x_even * sin + x_odd * cos
|
|
46
|
+
|
|
47
|
+
# Interleave back
|
|
48
|
+
out = torch.zeros_like(x)
|
|
49
|
+
out[0::2] = out_even
|
|
50
|
+
out[1::2] = out_odd
|
|
51
|
+
|
|
52
|
+
return out
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main():
|
|
56
|
+
if len(sys.argv) != 2:
|
|
57
|
+
raise SystemExit("Usage: python hf_rope_check.py <config.json>")
|
|
58
|
+
path = sys.argv[1]
|
|
59
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
60
|
+
config = json.load(handle)
|
|
61
|
+
if not isinstance(config, dict):
|
|
62
|
+
raise SystemExit("Config must be a JSON object")
|
|
63
|
+
|
|
64
|
+
model_id = config.get("model")
|
|
65
|
+
pos = config.get("pos")
|
|
66
|
+
dim = config.get("dim")
|
|
67
|
+
theta = config.get("theta")
|
|
68
|
+
|
|
69
|
+
if not isinstance(model_id, str) or not model_id.strip():
|
|
70
|
+
raise SystemExit('Config "model" must be a non-empty string')
|
|
71
|
+
if not isinstance(pos, int):
|
|
72
|
+
raise SystemExit('Config "pos" must be an integer')
|
|
73
|
+
if not isinstance(dim, int):
|
|
74
|
+
raise SystemExit('Config "dim" must be an integer')
|
|
75
|
+
if not isinstance(theta, (int, float)):
|
|
76
|
+
raise SystemExit('Config "theta" must be a number')
|
|
77
|
+
|
|
78
|
+
print(f"RoPE Check for position {pos}, head_dim={dim}, theta={theta}")
|
|
79
|
+
|
|
80
|
+
# Compute frequencies
|
|
81
|
+
freqs = compute_rope_freqs(dim, theta)
|
|
82
|
+
print(f"\nFrequencies (first 8): {freqs[:8].tolist()}")
|
|
83
|
+
|
|
84
|
+
# Compute angles at position
|
|
85
|
+
angles = pos * freqs
|
|
86
|
+
print(f"Angles at pos {pos} (first 8): {angles[:8].tolist()}")
|
|
87
|
+
|
|
88
|
+
# Compute cos/sin
|
|
89
|
+
cos = torch.cos(angles)
|
|
90
|
+
sin = torch.sin(angles)
|
|
91
|
+
print(f"Cos at pos {pos} (first 8): {cos[:8].tolist()}")
|
|
92
|
+
print(f"Sin at pos {pos} (first 8): {sin[:8].tolist()}")
|
|
93
|
+
|
|
94
|
+
# Test with a sample vector
|
|
95
|
+
test_vec = torch.randn(dim)
|
|
96
|
+
test_vec[0] = 1.0
|
|
97
|
+
test_vec[1] = 0.0
|
|
98
|
+
print(f"\nTest vector (first 8): {test_vec[:8].tolist()}")
|
|
99
|
+
|
|
100
|
+
rotated = apply_rope_to_vector(test_vec, pos, freqs)
|
|
101
|
+
print(f"After RoPE (first 8): {rotated[:8].tolist()}")
|
|
102
|
+
|
|
103
|
+
# Also load model and check actual RoPE config
|
|
104
|
+
print(f"\nLoading model to verify config: {model_id}")
|
|
105
|
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="cpu")
|
|
106
|
+
config = model.config
|
|
107
|
+
|
|
108
|
+
print(f"\nModel RoPE config:")
|
|
109
|
+
print(f" rope_theta: {getattr(config, 'rope_theta', 'not set')}")
|
|
110
|
+
print(f" head_dim: {config.head_dim}")
|
|
111
|
+
if hasattr(config, 'rope_scaling'):
|
|
112
|
+
print(f" rope_scaling: {config.rope_scaling}")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
main()
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Dump weight values for Q/K/V/O projections from HuggingFace model.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python hf_weights.py <config.json>
|
|
7
|
+
|
|
8
|
+
Config (JSON):
|
|
9
|
+
{
|
|
10
|
+
"model": "google/gemma-2-2b-it",
|
|
11
|
+
"layer": 0,
|
|
12
|
+
"proj": "all"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Requires: pip install torch transformers
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import sys
|
|
20
|
+
import torch
|
|
21
|
+
from transformers import AutoModelForCausalLM
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main():
|
|
25
|
+
if len(sys.argv) != 2:
|
|
26
|
+
raise SystemExit("Usage: python hf_weights.py <config.json>")
|
|
27
|
+
path = sys.argv[1]
|
|
28
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
29
|
+
config = json.load(handle)
|
|
30
|
+
if not isinstance(config, dict):
|
|
31
|
+
raise SystemExit("Config must be a JSON object")
|
|
32
|
+
|
|
33
|
+
model_id = config.get("model")
|
|
34
|
+
layer_index = config.get("layer")
|
|
35
|
+
proj = config.get("proj")
|
|
36
|
+
|
|
37
|
+
if not isinstance(model_id, str) or not model_id.strip():
|
|
38
|
+
raise SystemExit('Config "model" must be a non-empty string')
|
|
39
|
+
if not isinstance(layer_index, int):
|
|
40
|
+
raise SystemExit('Config "layer" must be an integer')
|
|
41
|
+
if proj not in ["q", "k", "v", "o", "all"]:
|
|
42
|
+
raise SystemExit('Config "proj" must be one of: q, k, v, o, all')
|
|
43
|
+
|
|
44
|
+
print(f"Loading model: {model_id}")
|
|
45
|
+
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float32, device_map="cpu")
|
|
46
|
+
|
|
47
|
+
layer = model.model.layers[layer_index]
|
|
48
|
+
attn = layer.self_attn
|
|
49
|
+
|
|
50
|
+
projections = {
|
|
51
|
+
"q": attn.q_proj,
|
|
52
|
+
"k": attn.k_proj,
|
|
53
|
+
"v": attn.v_proj,
|
|
54
|
+
"o": attn.o_proj,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
projs_to_show = list(projections.keys()) if proj == "all" else [proj]
|
|
58
|
+
|
|
59
|
+
for name in projs_to_show:
|
|
60
|
+
proj = projections[name]
|
|
61
|
+
weight = proj.weight.data # [out_features, in_features]
|
|
62
|
+
|
|
63
|
+
print(f"\n{name.upper()}_proj weight shape: {weight.shape}")
|
|
64
|
+
print(f"{name.upper()}_proj weight[0, :8] (first row, first 8 cols):")
|
|
65
|
+
print(f" {weight[0, :8].tolist()}")
|
|
66
|
+
print(f"{name.upper()}_proj weight[:8, 0] (first 8 rows, first col):")
|
|
67
|
+
print(f" {weight[:8, 0].tolist()}")
|
|
68
|
+
|
|
69
|
+
# Some specific indices for comparison
|
|
70
|
+
if weight.shape[1] > 100:
|
|
71
|
+
print(f"{name.upper()}_proj weight[0, 100]: {weight[0, 100].item():.6f}")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if __name__ == "__main__":
|
|
75
|
+
main()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOPPLER Debug Module - Completion Signals
|
|
3
|
+
*
|
|
4
|
+
* Standard completion signal prefixes for CLI/automation detection.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* console.log(`${SIGNALS.DONE} ${JSON.stringify({status: 'success', elapsed: 1234})}`);
|
|
8
|
+
* console.log(`${SIGNALS.RESULT} ${JSON.stringify(benchmarkData)}`);
|
|
9
|
+
* console.log(`${SIGNALS.ERROR} ${JSON.stringify({error: 'message'})}`);
|
|
10
|
+
*
|
|
11
|
+
* Detection (CLI/Puppeteer):
|
|
12
|
+
* if (text.startsWith('[DOPPLER:DONE]')) { ... }
|
|
13
|
+
*
|
|
14
|
+
* @module debug/signals
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Standard completion signal prefixes for CLI/automation detection.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SIGNALS: {
|
|
21
|
+
/** Task completed (success or error) - always emitted at end */
|
|
22
|
+
readonly DONE: '[DOPPLER:DONE]';
|
|
23
|
+
/** Full result payload (JSON) - emitted before DONE for data extraction */
|
|
24
|
+
readonly RESULT: '[DOPPLER:RESULT]';
|
|
25
|
+
/** Error occurred - can be emitted before DONE */
|
|
26
|
+
readonly ERROR: '[DOPPLER:ERROR]';
|
|
27
|
+
/** Progress update (optional) */
|
|
28
|
+
readonly PROGRESS: '[DOPPLER:PROGRESS]';
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type SignalType = keyof typeof SIGNALS;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Completion payload for DONE signal.
|
|
35
|
+
*/
|
|
36
|
+
export interface DonePayload {
|
|
37
|
+
status: 'success' | 'error';
|
|
38
|
+
elapsed: number;
|
|
39
|
+
tokens?: number;
|
|
40
|
+
tokensPerSecond?: number;
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Emit a completion signal to console.
|
|
46
|
+
* This is the standard way to signal task completion for CLI detection.
|
|
47
|
+
*/
|
|
48
|
+
export declare function signalDone(payload: DonePayload): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Emit a result signal with full data payload.
|
|
52
|
+
*/
|
|
53
|
+
export declare function signalResult(data: Record<string, unknown>): void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Emit an error signal.
|
|
57
|
+
*/
|
|
58
|
+
export declare function signalError(error: string, details?: Record<string, unknown>): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Emit a progress signal.
|
|
62
|
+
*/
|
|
63
|
+
export declare function signalProgress(percent: number, message?: string): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const SIGNALS = {
|
|
5
|
+
|
|
6
|
+
DONE: '[DOPPLER:DONE]',
|
|
7
|
+
|
|
8
|
+
RESULT: '[DOPPLER:RESULT]',
|
|
9
|
+
|
|
10
|
+
ERROR: '[DOPPLER:ERROR]',
|
|
11
|
+
|
|
12
|
+
PROGRESS: '[DOPPLER:PROGRESS]',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export function signalDone(payload) {
|
|
17
|
+
console.log(`${SIGNALS.DONE} ${JSON.stringify(payload)}`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export function signalResult(data) {
|
|
22
|
+
console.log(`${SIGNALS.RESULT} ${JSON.stringify(data)}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export function signalError(error, details) {
|
|
27
|
+
console.log(`${SIGNALS.ERROR} ${JSON.stringify({ error, ...details })}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export function signalProgress(percent, message) {
|
|
32
|
+
console.log(`${SIGNALS.PROGRESS} ${JSON.stringify({ percent, message })}`);
|
|
33
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface SampleStats {
|
|
2
|
+
mean: number;
|
|
3
|
+
median: number;
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
p95: number;
|
|
7
|
+
p99: number;
|
|
8
|
+
stdDev: number;
|
|
9
|
+
ci95: number;
|
|
10
|
+
samples: number;
|
|
11
|
+
samplesAfterOutlierRemoval: number;
|
|
12
|
+
outliersRemoved: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ArrayStats {
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
mean: number;
|
|
19
|
+
std: number;
|
|
20
|
+
maxAbs: number;
|
|
21
|
+
nanCount: number;
|
|
22
|
+
infCount: number;
|
|
23
|
+
zeroCount: number;
|
|
24
|
+
validCount: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BasicStats {
|
|
28
|
+
mean: number;
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
total: number;
|
|
32
|
+
count: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export declare function percentile(sorted: number[], p: number): number;
|
|
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
|
+
export declare function computeSampleStats(values: number[], options?: { outlierIqrMultiplier?: number }): SampleStats;
|
|
46
|
+
export declare function computeArrayStats(values: ArrayLike<number>, limit?: number): ArrayStats;
|
|
47
|
+
export declare function computeBasicStats(values: number[]): BasicStats;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export function percentile(sorted, p) {
|
|
2
|
+
if (!sorted.length) return 0;
|
|
3
|
+
if (sorted.length === 1) return sorted[0];
|
|
4
|
+
const idx = (p / 100) * (sorted.length - 1);
|
|
5
|
+
const lo = Math.floor(idx);
|
|
6
|
+
const hi = Math.ceil(idx);
|
|
7
|
+
if (lo === hi) return sorted[lo];
|
|
8
|
+
return sorted[lo] + (sorted[hi] - sorted[lo]) * (idx - lo);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function median(sorted) {
|
|
12
|
+
if (!sorted.length) return 0;
|
|
13
|
+
const mid = Math.floor(sorted.length / 2);
|
|
14
|
+
return sorted.length % 2 === 0
|
|
15
|
+
? (sorted[mid - 1] + sorted[mid]) / 2
|
|
16
|
+
: sorted[mid];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function removeOutliersIQR(values, multiplier = 1.5) {
|
|
20
|
+
if (values.length < 4) return { filtered: values, removed: 0, lower: -Infinity, upper: Infinity };
|
|
21
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
22
|
+
const q1 = percentile(sorted, 25);
|
|
23
|
+
const q3 = percentile(sorted, 75);
|
|
24
|
+
const iqr = q3 - q1;
|
|
25
|
+
const lower = q1 - multiplier * iqr;
|
|
26
|
+
const upper = q3 + multiplier * iqr;
|
|
27
|
+
const filtered = values.filter((v) => v >= lower && v <= upper);
|
|
28
|
+
return { filtered, removed: values.length - filtered.length, lower, upper };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function sampleStdDev(values, meanValue) {
|
|
32
|
+
const n = values.length;
|
|
33
|
+
if (n < 2) return 0;
|
|
34
|
+
const variance = values.reduce((sum, v) => sum + (v - meanValue) ** 2, 0) / (n - 1);
|
|
35
|
+
return Math.sqrt(variance);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function confidenceInterval95(stdDev, n) {
|
|
39
|
+
if (n < 2) return 0;
|
|
40
|
+
const tValue = n >= 30 ? 1.96 : 2.0 + 3.0 / n;
|
|
41
|
+
return tValue * (stdDev / Math.sqrt(n));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function computeSampleStats(values, options = {}) {
|
|
45
|
+
const { outlierIqrMultiplier = 1.5 } = options;
|
|
46
|
+
const rawValues = Array.isArray(values) ? values : [];
|
|
47
|
+
const finiteValues = rawValues.filter((value) => Number.isFinite(value));
|
|
48
|
+
const { filtered, removed } = removeOutliersIQR(finiteValues, outlierIqrMultiplier);
|
|
49
|
+
const nonFiniteRemoved = rawValues.length - finiteValues.length;
|
|
50
|
+
const sorted = [...filtered].sort((a, b) => a - b);
|
|
51
|
+
const n = sorted.length;
|
|
52
|
+
const totalRemoved = removed + nonFiniteRemoved;
|
|
53
|
+
|
|
54
|
+
if (n === 0) {
|
|
55
|
+
return {
|
|
56
|
+
mean: 0,
|
|
57
|
+
median: 0,
|
|
58
|
+
min: 0,
|
|
59
|
+
max: 0,
|
|
60
|
+
p95: 0,
|
|
61
|
+
p99: 0,
|
|
62
|
+
stdDev: 0,
|
|
63
|
+
ci95: 0,
|
|
64
|
+
samples: rawValues.length,
|
|
65
|
+
samplesAfterOutlierRemoval: 0,
|
|
66
|
+
outliersRemoved: totalRemoved,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const meanValue = filtered.reduce((a, b) => a + b, 0) / n;
|
|
71
|
+
const stdDev = sampleStdDev(filtered, meanValue);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
mean: meanValue,
|
|
75
|
+
median: median(sorted),
|
|
76
|
+
min: sorted[0],
|
|
77
|
+
max: sorted[n - 1],
|
|
78
|
+
p95: percentile(sorted, 95),
|
|
79
|
+
p99: percentile(sorted, 99),
|
|
80
|
+
stdDev,
|
|
81
|
+
ci95: confidenceInterval95(stdDev, n),
|
|
82
|
+
samples: rawValues.length,
|
|
83
|
+
samplesAfterOutlierRemoval: n,
|
|
84
|
+
outliersRemoved: totalRemoved,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function computeArrayStats(values, limit = values.length) {
|
|
89
|
+
const stats = {
|
|
90
|
+
min: Infinity,
|
|
91
|
+
max: -Infinity,
|
|
92
|
+
mean: 0,
|
|
93
|
+
std: 0,
|
|
94
|
+
maxAbs: 0,
|
|
95
|
+
nanCount: 0,
|
|
96
|
+
infCount: 0,
|
|
97
|
+
zeroCount: 0,
|
|
98
|
+
validCount: 0,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
let sum = 0;
|
|
102
|
+
let sumSq = 0;
|
|
103
|
+
const count = Math.min(values.length, limit);
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < count; i++) {
|
|
106
|
+
const v = values[i];
|
|
107
|
+
if (Number.isNaN(v)) {
|
|
108
|
+
stats.nanCount++;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (!Number.isFinite(v)) {
|
|
112
|
+
stats.infCount++;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (v === 0) stats.zeroCount++;
|
|
116
|
+
stats.min = Math.min(stats.min, v);
|
|
117
|
+
stats.max = Math.max(stats.max, v);
|
|
118
|
+
sum += v;
|
|
119
|
+
sumSq += v * v;
|
|
120
|
+
stats.validCount++;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (stats.validCount > 0) {
|
|
124
|
+
stats.mean = sum / stats.validCount;
|
|
125
|
+
const variance = sumSq / stats.validCount - stats.mean * stats.mean;
|
|
126
|
+
stats.std = Math.sqrt(Math.max(0, variance));
|
|
127
|
+
stats.maxAbs = Math.max(Math.abs(stats.min), Math.abs(stats.max));
|
|
128
|
+
} else {
|
|
129
|
+
stats.min = 0;
|
|
130
|
+
stats.max = 0;
|
|
131
|
+
stats.maxAbs = 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return stats;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function computeBasicStats(values) {
|
|
138
|
+
const count = values.length;
|
|
139
|
+
if (!count) {
|
|
140
|
+
return { mean: 0, min: 0, max: 0, total: 0, count: 0 };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let min = Infinity;
|
|
144
|
+
let max = -Infinity;
|
|
145
|
+
let total = 0;
|
|
146
|
+
|
|
147
|
+
for (const v of values) {
|
|
148
|
+
min = Math.min(min, v);
|
|
149
|
+
max = Math.max(max, v);
|
|
150
|
+
total += v;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
mean: total / count,
|
|
155
|
+
min,
|
|
156
|
+
max,
|
|
157
|
+
total,
|
|
158
|
+
count,
|
|
159
|
+
};
|
|
160
|
+
}
|