@hackbuild/ai-views 0.1.11 → 0.1.13

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/README.md CHANGED
@@ -254,9 +254,9 @@ Changes are in the repository [CHANGELOG](../../CHANGELOG.md). Code is MIT ([LIC
254
254
 
255
255
  | file | gzip (measured) | ceiling |
256
256
  |---|---|---|
257
- | `dist/index.js` (main entry, imports external) | 21,606 bytes | 22,686 bytes |
258
- | `dist/single/elements.iife.js` (single file build) | 100,083 bytes | 105,087 bytes |
257
+ | `dist/index.js` (main entry, imports external) | 21,601 bytes | 22,681 bytes |
258
+ | `dist/single/elements.iife.js` (single file build) | 100,338 bytes | 105,354 bytes |
259
259
 
260
- Measured 2026-11-26 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
260
+ Measured 2026-11-30 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
261
261
  tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
262
262
  5 percent from its row.
@@ -6553,6 +6553,11 @@ ${n}` : n;
6553
6553
  { path: "unet/model.onnx" },
6554
6554
  { path: "vae_decoder/model.onnx" }
6555
6555
  ];
6556
+ const SD15 = [
6557
+ "Stable-Diffusion-v1.5-text-encoder-float16",
6558
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
6559
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
6560
+ ];
6556
6561
  const free512 = { freeDimensionOverrides: {
6557
6562
  batch_size: 1,
6558
6563
  num_channels: 4,
@@ -6590,7 +6595,7 @@ ${n}` : n;
6590
6595
  notes: [
6591
6596
  "webgpu only, no wasm floor",
6592
6597
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
6593
- "graph file paths inferred, not checked against the repo"
6598
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
6594
6599
  ],
6595
6600
  form: {
6596
6601
  steps: {
@@ -6604,6 +6609,7 @@ ${n}` : n;
6604
6609
  spacing: "trailing",
6605
6610
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
6606
6611
  tokenizer: "Xenova/clip-vit-base-patch16",
6612
+ pad: 0,
6607
6613
  graphs
6608
6614
  }
6609
6615
  }, {
@@ -6614,9 +6620,10 @@ ${n}` : n;
6614
6620
  group: "good",
6615
6621
  provides: ["imagegen"],
6616
6622
  provider: "ort",
6623
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
6617
6624
  source: {
6618
6625
  repo: "microsoft/stable-diffusion-v1.5-webnn",
6619
- files
6626
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
6620
6627
  },
6621
6628
  sizeMB: 1969,
6622
6629
  sizeSource: "vendor",
@@ -6630,7 +6637,7 @@ ${n}` : n;
6630
6637
  place: "gpu",
6631
6638
  runtime: "onnxruntime-web@1.27.0",
6632
6639
  notes: [
6633
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
6640
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
6634
6641
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
6635
6642
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
6636
6643
  ],
@@ -6651,23 +6658,25 @@ ${n}` : n;
6651
6658
  spacing: "leading",
6652
6659
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
6653
6660
  tokenizer: "Xenova/clip-vit-base-patch16",
6654
- graphs
6661
+ graphs: {
6662
+ textEncoder: SD15[0],
6663
+ unet: SD15[1],
6664
+ vaeDecoder: SD15[2]
6665
+ }
6655
6666
  }
6656
6667
  }];
6657
6668
  /**
6658
6669
  * Listed for pickers, not registered by attachImagegen, so routing by
6659
- * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. The
6660
- * export's input and output names and dtypes were read from the end of
6661
- * each onnx file (2026-11-29, measured); the pipeline has not run on the
6662
- * real weights. `loadImagegen(hub, { id:
6663
- * "sdxl-turbo" })` adds it and loads it.
6670
+ * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. Its graph
6671
+ * names and dtypes were read from the export (2026-11-29) and it made a
6672
+ * picture on the real weights (2026-11-30, measured). `loadImagegen(hub,
6673
+ * { id: "sdxl-turbo" })` adds it and loads it.
6664
6674
  */
6665
6675
  const IMAGEGEN_PICKER_RECORDS = [{
6666
6676
  id: "sdxl-turbo",
6667
6677
  label: "sdxl-turbo 512",
6668
6678
  speed: "steady",
6669
- verdict: "not run yet",
6670
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
6679
+ verdict: "best looking, run once",
6671
6680
  group: "good",
6672
6681
  provides: ["imagegen"],
6673
6682
  provider: "ort",
@@ -6694,7 +6703,8 @@ ${n}` : n;
6694
6703
  notes: [
6695
6704
  "two text encoders, pooled embeddings and time ids, on generateXl",
6696
6705
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
6697
- "the highest quality of the three image models"
6706
+ "the highest quality of the three image models",
6707
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
6698
6708
  ],
6699
6709
  form: {
6700
6710
  steps: {
@@ -6551,6 +6551,11 @@ const files = [
6551
6551
  { path: "unet/model.onnx" },
6552
6552
  { path: "vae_decoder/model.onnx" }
6553
6553
  ];
6554
+ const SD15 = [
6555
+ "Stable-Diffusion-v1.5-text-encoder-float16",
6556
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
6557
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
6558
+ ];
6554
6559
  const free512 = { freeDimensionOverrides: {
6555
6560
  batch_size: 1,
6556
6561
  num_channels: 4,
@@ -6588,7 +6593,7 @@ const IMAGEGEN_RECORDS = [{
6588
6593
  notes: [
6589
6594
  "webgpu only, no wasm floor",
6590
6595
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
6591
- "graph file paths inferred, not checked against the repo"
6596
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
6592
6597
  ],
6593
6598
  form: {
6594
6599
  steps: {
@@ -6602,6 +6607,7 @@ const IMAGEGEN_RECORDS = [{
6602
6607
  spacing: "trailing",
6603
6608
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
6604
6609
  tokenizer: "Xenova/clip-vit-base-patch16",
6610
+ pad: 0,
6605
6611
  graphs
6606
6612
  }
6607
6613
  }, {
@@ -6612,9 +6618,10 @@ const IMAGEGEN_RECORDS = [{
6612
6618
  group: "good",
6613
6619
  provides: ["imagegen"],
6614
6620
  provider: "ort",
6621
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
6615
6622
  source: {
6616
6623
  repo: "microsoft/stable-diffusion-v1.5-webnn",
6617
- files
6624
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
6618
6625
  },
6619
6626
  sizeMB: 1969,
6620
6627
  sizeSource: "vendor",
@@ -6628,7 +6635,7 @@ const IMAGEGEN_RECORDS = [{
6628
6635
  place: "gpu",
6629
6636
  runtime: "onnxruntime-web@1.27.0",
6630
6637
  notes: [
6631
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
6638
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
6632
6639
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
6633
6640
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
6634
6641
  ],
@@ -6649,23 +6656,25 @@ const IMAGEGEN_RECORDS = [{
6649
6656
  spacing: "leading",
6650
6657
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
6651
6658
  tokenizer: "Xenova/clip-vit-base-patch16",
6652
- graphs
6659
+ graphs: {
6660
+ textEncoder: SD15[0],
6661
+ unet: SD15[1],
6662
+ vaeDecoder: SD15[2]
6663
+ }
6653
6664
  }
6654
6665
  }];
6655
6666
  /**
6656
6667
  * Listed for pickers, not registered by attachImagegen, so routing by
6657
- * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. The
6658
- * export's input and output names and dtypes were read from the end of
6659
- * each onnx file (2026-11-29, measured); the pipeline has not run on the
6660
- * real weights. `loadImagegen(hub, { id:
6661
- * "sdxl-turbo" })` adds it and loads it.
6668
+ * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. Its graph
6669
+ * names and dtypes were read from the export (2026-11-29) and it made a
6670
+ * picture on the real weights (2026-11-30, measured). `loadImagegen(hub,
6671
+ * { id: "sdxl-turbo" })` adds it and loads it.
6662
6672
  */
6663
6673
  const IMAGEGEN_PICKER_RECORDS = [{
6664
6674
  id: "sdxl-turbo",
6665
6675
  label: "sdxl-turbo 512",
6666
6676
  speed: "steady",
6667
- verdict: "not run yet",
6668
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
6677
+ verdict: "best looking, run once",
6669
6678
  group: "good",
6670
6679
  provides: ["imagegen"],
6671
6680
  provider: "ort",
@@ -6692,7 +6701,8 @@ const IMAGEGEN_PICKER_RECORDS = [{
6692
6701
  notes: [
6693
6702
  "two text encoders, pooled embeddings and time ids, on generateXl",
6694
6703
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
6695
- "the highest quality of the three image models"
6704
+ "the highest quality of the three image models",
6705
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
6696
6706
  ],
6697
6707
  form: {
6698
6708
  steps: {
@@ -7727,6 +7727,73 @@ var HackbuildAiViews = (function(exports) {
7727
7727
  return x;
7728
7728
  }
7729
7729
  var init_schedule = __esmMin((() => {}));
7730
+ // packages/imagegen/src/half.ts
7731
+ /** Half float conversion at the graph edge, for exports with fp16 inputs and outputs. */
7732
+ /** Float32 to IEEE 754 half bits, round to nearest even. */
7733
+ function toHalf(f) {
7734
+ const out = new Uint16Array(f.length);
7735
+ const b = /* @__PURE__ */ new Float32Array(1);
7736
+ const u = new Uint32Array(b.buffer);
7737
+ for (let i = 0; i < f.length; i++) {
7738
+ b[0] = f[i];
7739
+ const x = u[0];
7740
+ const sign = x >>> 16 & 32768;
7741
+ const exp = x >>> 23 & 255;
7742
+ let mant = x & 8388607;
7743
+ if (exp === 255) {
7744
+ out[i] = sign | 31744 | (mant ? 512 : 0);
7745
+ continue;
7746
+ }
7747
+ const e = exp - 127 + 15;
7748
+ if (e >= 31) {
7749
+ out[i] = sign | 31744;
7750
+ continue;
7751
+ }
7752
+ if (e <= 0) {
7753
+ if (e < -10) {
7754
+ out[i] = sign;
7755
+ continue;
7756
+ }
7757
+ mant |= 8388608;
7758
+ const shift = 14 - e;
7759
+ let h = mant >>> shift;
7760
+ const rem = mant & (1 << shift) - 1;
7761
+ const half = 1 << shift - 1;
7762
+ if (rem > half || rem === half && h & 1) h++;
7763
+ out[i] = sign | h;
7764
+ continue;
7765
+ }
7766
+ let h = e << 10 | mant >>> 13;
7767
+ const rem = mant & 8191;
7768
+ if (rem > 4096 || rem === 4096 && h & 1) h++;
7769
+ out[i] = sign | h;
7770
+ }
7771
+ return out;
7772
+ }
7773
+ /** IEEE 754 half bits to float32. */
7774
+ function fromHalf(h) {
7775
+ const out = new Float32Array(h.length);
7776
+ for (let i = 0; i < h.length; i++) {
7777
+ const v = h[i];
7778
+ const s = v & 32768 ? -1 : 1;
7779
+ const e = v >>> 10 & 31;
7780
+ const m = v & 1023;
7781
+ out[i] = e === 0 ? s * m * 2 ** -24 : e === 31 ? m ? NaN : s * Infinity : s * (1 + m / 1024) * 2 ** (e - 15);
7782
+ }
7783
+ return out;
7784
+ }
7785
+ /**
7786
+ * An output's floats. onnxruntime-web gives a float16 output as a
7787
+ * Float16Array of real values where the browser has one, and as Uint16Array
7788
+ * half bits where it does not; only the bits are decoded.
7789
+ */
7790
+ function floatsOf(t) {
7791
+ const F16 = globalThis.Float16Array;
7792
+ if (F16 && t.data instanceof F16) return Float32Array.from(t.data);
7793
+ if (t.data instanceof Uint16Array) return fromHalf(t.data);
7794
+ return Float32Array.from(t.data);
7795
+ }
7796
+ var init_half = __esmMin((() => {}));
7730
7797
  // packages/imagegen/src/pipeline.ts
7731
7798
  /** NCHW floats in [-1, 1] to RGBA bytes. */
7732
7799
  function toRgba(nchw, w, h) {
@@ -7765,10 +7832,10 @@ var HackbuildAiViews = (function(exports) {
7765
7832
  };
7766
7833
  let t = now();
7767
7834
  const encode = async (text) => {
7768
- const ids = padIds(await tokenize(text.length ? text : " "));
7835
+ const ids = padIds(await tokenize(text.length ? text : " "), 77, o.pad);
7769
7836
  const te = await run(() => s.textEncoder.run({ input_ids: new ort.Tensor("int32", ids, [1, 77]) }));
7770
7837
  const hidden = te.last_hidden_state ?? Object.values(te)[0];
7771
- return new ort.Tensor("float32", Float32Array.from(hidden.data), [...hidden.dims ?? [
7838
+ return new ort.Tensor("float32", floatsOf(hidden), [...hidden.dims ?? [
7772
7839
  1,
7773
7840
  77,
7774
7841
  hidden.data.length / 77
@@ -7802,7 +7869,7 @@ var HackbuildAiViews = (function(exports) {
7802
7869
  timestep: new ort.Tensor("int64", BigInt64Array.from([BigInt(timestep)]), [1]),
7803
7870
  encoder_hidden_states: h
7804
7871
  }));
7805
- return (u.out_sample ?? Object.values(u)[0]).data;
7872
+ return floatsOf(u.out_sample ?? Object.values(u)[0]);
7806
7873
  };
7807
7874
  const c = await unet(hiddenTensor);
7808
7875
  let e = c;
@@ -7841,13 +7908,14 @@ var HackbuildAiViews = (function(exports) {
7841
7908
  return {
7842
7909
  width: size,
7843
7910
  height: size,
7844
- rgba: toRgba((v.sample ?? Object.values(v)[0]).data, size, size),
7911
+ rgba: toRgba(floatsOf(v.sample ?? Object.values(v)[0]), size, size),
7845
7912
  seed,
7846
7913
  ms
7847
7914
  };
7848
7915
  }
7849
7916
  var VAE_SCALE;
7850
7917
  var init_pipeline = __esmMin((() => {
7918
+ init_half();
7851
7919
  init_schedule();
7852
7920
  VAE_SCALE = .18215;
7853
7921
  }));
@@ -7863,7 +7931,7 @@ var HackbuildAiViews = (function(exports) {
7863
7931
  if (rec.sizeMB === 0) return `load ${name}, no download`;
7864
7932
  return `load ${name}, about ${rec.sizeMB >= 1e3 ? `${(rec.sizeMB / 1e3).toFixed(1)} gb` : `${rec.sizeMB} mb`} (${rec.sizeSource})`;
7865
7933
  }
7866
- var graphs, files, free512, IMAGEGEN_RECORDS, IMAGEGEN_PICKER_RECORDS;
7934
+ var graphs, files, SD15, free512, IMAGEGEN_RECORDS, IMAGEGEN_PICKER_RECORDS;
7867
7935
  var init_records$3 = __esmMin((() => {
7868
7936
  graphs = {
7869
7937
  textEncoder: "text_encoder",
@@ -7875,6 +7943,11 @@ var HackbuildAiViews = (function(exports) {
7875
7943
  { path: "unet/model.onnx" },
7876
7944
  { path: "vae_decoder/model.onnx" }
7877
7945
  ];
7946
+ SD15 = [
7947
+ "Stable-Diffusion-v1.5-text-encoder-float16",
7948
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
7949
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
7950
+ ];
7878
7951
  free512 = { freeDimensionOverrides: {
7879
7952
  batch_size: 1,
7880
7953
  num_channels: 4,
@@ -7911,7 +7984,7 @@ var HackbuildAiViews = (function(exports) {
7911
7984
  notes: [
7912
7985
  "webgpu only, no wasm floor",
7913
7986
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
7914
- "graph file paths inferred, not checked against the repo"
7987
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
7915
7988
  ],
7916
7989
  form: {
7917
7990
  steps: {
@@ -7925,6 +7998,7 @@ var HackbuildAiViews = (function(exports) {
7925
7998
  spacing: "trailing",
7926
7999
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
7927
8000
  tokenizer: "Xenova/clip-vit-base-patch16",
8001
+ pad: 0,
7928
8002
  graphs
7929
8003
  }
7930
8004
  }, {
@@ -7935,9 +8009,10 @@ var HackbuildAiViews = (function(exports) {
7935
8009
  group: "good",
7936
8010
  provides: ["imagegen"],
7937
8011
  provider: "ort",
8012
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
7938
8013
  source: {
7939
8014
  repo: "microsoft/stable-diffusion-v1.5-webnn",
7940
- files
8015
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
7941
8016
  },
7942
8017
  sizeMB: 1969,
7943
8018
  sizeSource: "vendor",
@@ -7951,7 +8026,7 @@ var HackbuildAiViews = (function(exports) {
7951
8026
  place: "gpu",
7952
8027
  runtime: "onnxruntime-web@1.27.0",
7953
8028
  notes: [
7954
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
8029
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
7955
8030
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
7956
8031
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
7957
8032
  ],
@@ -7972,15 +8047,18 @@ var HackbuildAiViews = (function(exports) {
7972
8047
  spacing: "leading",
7973
8048
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
7974
8049
  tokenizer: "Xenova/clip-vit-base-patch16",
7975
- graphs
8050
+ graphs: {
8051
+ textEncoder: SD15[0],
8052
+ unet: SD15[1],
8053
+ vaeDecoder: SD15[2]
8054
+ }
7976
8055
  }
7977
8056
  }];
7978
8057
  IMAGEGEN_PICKER_RECORDS = [{
7979
8058
  id: "sdxl-turbo",
7980
8059
  label: "sdxl-turbo 512",
7981
8060
  speed: "steady",
7982
- verdict: "not run yet",
7983
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
8061
+ verdict: "best looking, run once",
7984
8062
  group: "good",
7985
8063
  provides: ["imagegen"],
7986
8064
  provider: "ort",
@@ -8007,7 +8085,8 @@ var HackbuildAiViews = (function(exports) {
8007
8085
  notes: [
8008
8086
  "two text encoders, pooled embeddings and time ids, on generateXl",
8009
8087
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
8010
- "the highest quality of the three image models"
8088
+ "the highest quality of the three image models",
8089
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
8011
8090
  ],
8012
8091
  form: {
8013
8092
  steps: {
@@ -8037,64 +8116,6 @@ var HackbuildAiViews = (function(exports) {
8037
8116
  }];
8038
8117
  }));
8039
8118
  // packages/imagegen/src/xl.ts
8040
- /** Float32 to IEEE 754 half bits, round to nearest even. */
8041
- function toHalf(f) {
8042
- const out = new Uint16Array(f.length);
8043
- const b = /* @__PURE__ */ new Float32Array(1);
8044
- const u = new Uint32Array(b.buffer);
8045
- for (let i = 0; i < f.length; i++) {
8046
- b[0] = f[i];
8047
- const x = u[0];
8048
- const sign = x >>> 16 & 32768;
8049
- const exp = x >>> 23 & 255;
8050
- let mant = x & 8388607;
8051
- if (exp === 255) {
8052
- out[i] = sign | 31744 | (mant ? 512 : 0);
8053
- continue;
8054
- }
8055
- const e = exp - 127 + 15;
8056
- if (e >= 31) {
8057
- out[i] = sign | 31744;
8058
- continue;
8059
- }
8060
- if (e <= 0) {
8061
- if (e < -10) {
8062
- out[i] = sign;
8063
- continue;
8064
- }
8065
- mant |= 8388608;
8066
- const shift = 14 - e;
8067
- let h = mant >>> shift;
8068
- const rem = mant & (1 << shift) - 1;
8069
- const half = 1 << shift - 1;
8070
- if (rem > half || rem === half && h & 1) h++;
8071
- out[i] = sign | h;
8072
- continue;
8073
- }
8074
- let h = e << 10 | mant >>> 13;
8075
- const rem = mant & 8191;
8076
- if (rem > 4096 || rem === 4096 && h & 1) h++;
8077
- out[i] = sign | h;
8078
- }
8079
- return out;
8080
- }
8081
- /** IEEE 754 half bits to float32. */
8082
- function fromHalf(h) {
8083
- const out = new Float32Array(h.length);
8084
- for (let i = 0; i < h.length; i++) {
8085
- const v = h[i];
8086
- const s = v & 32768 ? -1 : 1;
8087
- const e = v >>> 10 & 31;
8088
- const m = v & 1023;
8089
- out[i] = e === 0 ? s * m * 2 ** -24 : e === 31 ? m ? NaN : s * Infinity : s * (1 + m / 1024) * 2 ** (e - 15);
8090
- }
8091
- return out;
8092
- }
8093
- /** An output's floats; fp16 outputs (type "float16" or Uint16Array data) are decoded. */
8094
- function floatsOf(t) {
8095
- if (t.type === "float16" || t.data instanceof Uint16Array) return fromHalf(t.data);
8096
- return Float32Array.from(t.data);
8097
- }
8098
8119
  /** CLIP ids for the second encoder: up to the first end token, then `pad` to 77. */
8099
8120
  function padIds2(ids, pad = 0) {
8100
8121
  const list = Array.from(ids);
@@ -8243,6 +8264,7 @@ var HackbuildAiViews = (function(exports) {
8243
8264
  var init_xl = __esmMin((() => {
8244
8265
  init_pipeline();
8245
8266
  init_schedule();
8267
+ init_half();
8246
8268
  XL_IO = {
8247
8269
  io: "float32",
8248
8270
  timestep: "int64",
@@ -8290,6 +8312,7 @@ var HackbuildAiViews = (function(exports) {
8290
8312
  if (form.guidance) out.guidance = Math.min(form.guidance.max, Math.max(form.guidance.min, o.guidance ?? form.guidance.default));
8291
8313
  else delete out.guidance;
8292
8314
  if (!form.negative) delete out.negative;
8315
+ if (form.pad !== void 0) out.pad = form.pad;
8293
8316
  return out;
8294
8317
  }
8295
8318
  /**
@@ -7725,6 +7725,73 @@ async function euler(latent, plan, eps, signal) {
7725
7725
  return x;
7726
7726
  }
7727
7727
  var init_schedule = __esmMin((() => {}));
7728
+ // packages/imagegen/src/half.ts
7729
+ /** Half float conversion at the graph edge, for exports with fp16 inputs and outputs. */
7730
+ /** Float32 to IEEE 754 half bits, round to nearest even. */
7731
+ function toHalf(f) {
7732
+ const out = new Uint16Array(f.length);
7733
+ const b = /* @__PURE__ */ new Float32Array(1);
7734
+ const u = new Uint32Array(b.buffer);
7735
+ for (let i = 0; i < f.length; i++) {
7736
+ b[0] = f[i];
7737
+ const x = u[0];
7738
+ const sign = x >>> 16 & 32768;
7739
+ const exp = x >>> 23 & 255;
7740
+ let mant = x & 8388607;
7741
+ if (exp === 255) {
7742
+ out[i] = sign | 31744 | (mant ? 512 : 0);
7743
+ continue;
7744
+ }
7745
+ const e = exp - 127 + 15;
7746
+ if (e >= 31) {
7747
+ out[i] = sign | 31744;
7748
+ continue;
7749
+ }
7750
+ if (e <= 0) {
7751
+ if (e < -10) {
7752
+ out[i] = sign;
7753
+ continue;
7754
+ }
7755
+ mant |= 8388608;
7756
+ const shift = 14 - e;
7757
+ let h = mant >>> shift;
7758
+ const rem = mant & (1 << shift) - 1;
7759
+ const half = 1 << shift - 1;
7760
+ if (rem > half || rem === half && h & 1) h++;
7761
+ out[i] = sign | h;
7762
+ continue;
7763
+ }
7764
+ let h = e << 10 | mant >>> 13;
7765
+ const rem = mant & 8191;
7766
+ if (rem > 4096 || rem === 4096 && h & 1) h++;
7767
+ out[i] = sign | h;
7768
+ }
7769
+ return out;
7770
+ }
7771
+ /** IEEE 754 half bits to float32. */
7772
+ function fromHalf(h) {
7773
+ const out = new Float32Array(h.length);
7774
+ for (let i = 0; i < h.length; i++) {
7775
+ const v = h[i];
7776
+ const s = v & 32768 ? -1 : 1;
7777
+ const e = v >>> 10 & 31;
7778
+ const m = v & 1023;
7779
+ out[i] = e === 0 ? s * m * 2 ** -24 : e === 31 ? m ? NaN : s * Infinity : s * (1 + m / 1024) * 2 ** (e - 15);
7780
+ }
7781
+ return out;
7782
+ }
7783
+ /**
7784
+ * An output's floats. onnxruntime-web gives a float16 output as a
7785
+ * Float16Array of real values where the browser has one, and as Uint16Array
7786
+ * half bits where it does not; only the bits are decoded.
7787
+ */
7788
+ function floatsOf(t) {
7789
+ const F16 = globalThis.Float16Array;
7790
+ if (F16 && t.data instanceof F16) return Float32Array.from(t.data);
7791
+ if (t.data instanceof Uint16Array) return fromHalf(t.data);
7792
+ return Float32Array.from(t.data);
7793
+ }
7794
+ var init_half = __esmMin((() => {}));
7728
7795
  // packages/imagegen/src/pipeline.ts
7729
7796
  /** NCHW floats in [-1, 1] to RGBA bytes. */
7730
7797
  function toRgba(nchw, w, h) {
@@ -7763,10 +7830,10 @@ async function generate(ort, s, tokenize, o) {
7763
7830
  };
7764
7831
  let t = now();
7765
7832
  const encode = async (text) => {
7766
- const ids = padIds(await tokenize(text.length ? text : " "));
7833
+ const ids = padIds(await tokenize(text.length ? text : " "), 77, o.pad);
7767
7834
  const te = await run(() => s.textEncoder.run({ input_ids: new ort.Tensor("int32", ids, [1, 77]) }));
7768
7835
  const hidden = te.last_hidden_state ?? Object.values(te)[0];
7769
- return new ort.Tensor("float32", Float32Array.from(hidden.data), [...hidden.dims ?? [
7836
+ return new ort.Tensor("float32", floatsOf(hidden), [...hidden.dims ?? [
7770
7837
  1,
7771
7838
  77,
7772
7839
  hidden.data.length / 77
@@ -7800,7 +7867,7 @@ async function generate(ort, s, tokenize, o) {
7800
7867
  timestep: new ort.Tensor("int64", BigInt64Array.from([BigInt(timestep)]), [1]),
7801
7868
  encoder_hidden_states: h
7802
7869
  }));
7803
- return (u.out_sample ?? Object.values(u)[0]).data;
7870
+ return floatsOf(u.out_sample ?? Object.values(u)[0]);
7804
7871
  };
7805
7872
  const c = await unet(hiddenTensor);
7806
7873
  let e = c;
@@ -7839,13 +7906,14 @@ async function generate(ort, s, tokenize, o) {
7839
7906
  return {
7840
7907
  width: size,
7841
7908
  height: size,
7842
- rgba: toRgba((v.sample ?? Object.values(v)[0]).data, size, size),
7909
+ rgba: toRgba(floatsOf(v.sample ?? Object.values(v)[0]), size, size),
7843
7910
  seed,
7844
7911
  ms
7845
7912
  };
7846
7913
  }
7847
7914
  var VAE_SCALE;
7848
7915
  var init_pipeline = __esmMin((() => {
7916
+ init_half();
7849
7917
  init_schedule();
7850
7918
  VAE_SCALE = .18215;
7851
7919
  }));
@@ -7861,7 +7929,7 @@ function loadLabel(rec) {
7861
7929
  if (rec.sizeMB === 0) return `load ${name}, no download`;
7862
7930
  return `load ${name}, about ${rec.sizeMB >= 1e3 ? `${(rec.sizeMB / 1e3).toFixed(1)} gb` : `${rec.sizeMB} mb`} (${rec.sizeSource})`;
7863
7931
  }
7864
- var graphs, files, free512, IMAGEGEN_RECORDS, IMAGEGEN_PICKER_RECORDS;
7932
+ var graphs, files, SD15, free512, IMAGEGEN_RECORDS, IMAGEGEN_PICKER_RECORDS;
7865
7933
  var init_records$3 = __esmMin((() => {
7866
7934
  graphs = {
7867
7935
  textEncoder: "text_encoder",
@@ -7873,6 +7941,11 @@ var init_records$3 = __esmMin((() => {
7873
7941
  { path: "unet/model.onnx" },
7874
7942
  { path: "vae_decoder/model.onnx" }
7875
7943
  ];
7944
+ SD15 = [
7945
+ "Stable-Diffusion-v1.5-text-encoder-float16",
7946
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
7947
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
7948
+ ];
7876
7949
  free512 = { freeDimensionOverrides: {
7877
7950
  batch_size: 1,
7878
7951
  num_channels: 4,
@@ -7909,7 +7982,7 @@ var init_records$3 = __esmMin((() => {
7909
7982
  notes: [
7910
7983
  "webgpu only, no wasm floor",
7911
7984
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
7912
- "graph file paths inferred, not checked against the repo"
7985
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
7913
7986
  ],
7914
7987
  form: {
7915
7988
  steps: {
@@ -7923,6 +7996,7 @@ var init_records$3 = __esmMin((() => {
7923
7996
  spacing: "trailing",
7924
7997
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
7925
7998
  tokenizer: "Xenova/clip-vit-base-patch16",
7999
+ pad: 0,
7926
8000
  graphs
7927
8001
  }
7928
8002
  }, {
@@ -7933,9 +8007,10 @@ var init_records$3 = __esmMin((() => {
7933
8007
  group: "good",
7934
8008
  provides: ["imagegen"],
7935
8009
  provider: "ort",
8010
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
7936
8011
  source: {
7937
8012
  repo: "microsoft/stable-diffusion-v1.5-webnn",
7938
- files
8013
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
7939
8014
  },
7940
8015
  sizeMB: 1969,
7941
8016
  sizeSource: "vendor",
@@ -7949,7 +8024,7 @@ var init_records$3 = __esmMin((() => {
7949
8024
  place: "gpu",
7950
8025
  runtime: "onnxruntime-web@1.27.0",
7951
8026
  notes: [
7952
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
8027
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
7953
8028
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
7954
8029
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
7955
8030
  ],
@@ -7970,15 +8045,18 @@ var init_records$3 = __esmMin((() => {
7970
8045
  spacing: "leading",
7971
8046
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
7972
8047
  tokenizer: "Xenova/clip-vit-base-patch16",
7973
- graphs
8048
+ graphs: {
8049
+ textEncoder: SD15[0],
8050
+ unet: SD15[1],
8051
+ vaeDecoder: SD15[2]
8052
+ }
7974
8053
  }
7975
8054
  }];
7976
8055
  IMAGEGEN_PICKER_RECORDS = [{
7977
8056
  id: "sdxl-turbo",
7978
8057
  label: "sdxl-turbo 512",
7979
8058
  speed: "steady",
7980
- verdict: "not run yet",
7981
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
8059
+ verdict: "best looking, run once",
7982
8060
  group: "good",
7983
8061
  provides: ["imagegen"],
7984
8062
  provider: "ort",
@@ -8005,7 +8083,8 @@ var init_records$3 = __esmMin((() => {
8005
8083
  notes: [
8006
8084
  "two text encoders, pooled embeddings and time ids, on generateXl",
8007
8085
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
8008
- "the highest quality of the three image models"
8086
+ "the highest quality of the three image models",
8087
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
8009
8088
  ],
8010
8089
  form: {
8011
8090
  steps: {
@@ -8035,64 +8114,6 @@ var init_records$3 = __esmMin((() => {
8035
8114
  }];
8036
8115
  }));
8037
8116
  // packages/imagegen/src/xl.ts
8038
- /** Float32 to IEEE 754 half bits, round to nearest even. */
8039
- function toHalf(f) {
8040
- const out = new Uint16Array(f.length);
8041
- const b = /* @__PURE__ */ new Float32Array(1);
8042
- const u = new Uint32Array(b.buffer);
8043
- for (let i = 0; i < f.length; i++) {
8044
- b[0] = f[i];
8045
- const x = u[0];
8046
- const sign = x >>> 16 & 32768;
8047
- const exp = x >>> 23 & 255;
8048
- let mant = x & 8388607;
8049
- if (exp === 255) {
8050
- out[i] = sign | 31744 | (mant ? 512 : 0);
8051
- continue;
8052
- }
8053
- const e = exp - 127 + 15;
8054
- if (e >= 31) {
8055
- out[i] = sign | 31744;
8056
- continue;
8057
- }
8058
- if (e <= 0) {
8059
- if (e < -10) {
8060
- out[i] = sign;
8061
- continue;
8062
- }
8063
- mant |= 8388608;
8064
- const shift = 14 - e;
8065
- let h = mant >>> shift;
8066
- const rem = mant & (1 << shift) - 1;
8067
- const half = 1 << shift - 1;
8068
- if (rem > half || rem === half && h & 1) h++;
8069
- out[i] = sign | h;
8070
- continue;
8071
- }
8072
- let h = e << 10 | mant >>> 13;
8073
- const rem = mant & 8191;
8074
- if (rem > 4096 || rem === 4096 && h & 1) h++;
8075
- out[i] = sign | h;
8076
- }
8077
- return out;
8078
- }
8079
- /** IEEE 754 half bits to float32. */
8080
- function fromHalf(h) {
8081
- const out = new Float32Array(h.length);
8082
- for (let i = 0; i < h.length; i++) {
8083
- const v = h[i];
8084
- const s = v & 32768 ? -1 : 1;
8085
- const e = v >>> 10 & 31;
8086
- const m = v & 1023;
8087
- out[i] = e === 0 ? s * m * 2 ** -24 : e === 31 ? m ? NaN : s * Infinity : s * (1 + m / 1024) * 2 ** (e - 15);
8088
- }
8089
- return out;
8090
- }
8091
- /** An output's floats; fp16 outputs (type "float16" or Uint16Array data) are decoded. */
8092
- function floatsOf(t) {
8093
- if (t.type === "float16" || t.data instanceof Uint16Array) return fromHalf(t.data);
8094
- return Float32Array.from(t.data);
8095
- }
8096
8117
  /** CLIP ids for the second encoder: up to the first end token, then `pad` to 77. */
8097
8118
  function padIds2(ids, pad = 0) {
8098
8119
  const list = Array.from(ids);
@@ -8241,6 +8262,7 @@ var XL_IO, EOT;
8241
8262
  var init_xl = __esmMin((() => {
8242
8263
  init_pipeline();
8243
8264
  init_schedule();
8265
+ init_half();
8244
8266
  XL_IO = {
8245
8267
  io: "float32",
8246
8268
  timestep: "int64",
@@ -8288,6 +8310,7 @@ function applyForm(form, o) {
8288
8310
  if (form.guidance) out.guidance = Math.min(form.guidance.max, Math.max(form.guidance.min, o.guidance ?? form.guidance.default));
8289
8311
  else delete out.guidance;
8290
8312
  if (!form.negative) delete out.negative;
8313
+ if (form.pad !== void 0) out.pad = form.pad;
8291
8314
  return out;
8292
8315
  }
8293
8316
  /**
@@ -8633,6 +8633,11 @@ ${n}` : n;
8633
8633
  { path: "unet/model.onnx" },
8634
8634
  { path: "vae_decoder/model.onnx" }
8635
8635
  ];
8636
+ const SD15 = [
8637
+ "Stable-Diffusion-v1.5-text-encoder-float16",
8638
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
8639
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
8640
+ ];
8636
8641
  const free512 = { freeDimensionOverrides: {
8637
8642
  batch_size: 1,
8638
8643
  num_channels: 4,
@@ -8670,7 +8675,7 @@ ${n}` : n;
8670
8675
  notes: [
8671
8676
  "webgpu only, no wasm floor",
8672
8677
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
8673
- "graph file paths inferred, not checked against the repo"
8678
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
8674
8679
  ],
8675
8680
  form: {
8676
8681
  steps: {
@@ -8684,6 +8689,7 @@ ${n}` : n;
8684
8689
  spacing: "trailing",
8685
8690
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
8686
8691
  tokenizer: "Xenova/clip-vit-base-patch16",
8692
+ pad: 0,
8687
8693
  graphs
8688
8694
  }
8689
8695
  }, {
@@ -8694,9 +8700,10 @@ ${n}` : n;
8694
8700
  group: "good",
8695
8701
  provides: ["imagegen"],
8696
8702
  provider: "ort",
8703
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
8697
8704
  source: {
8698
8705
  repo: "microsoft/stable-diffusion-v1.5-webnn",
8699
- files
8706
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
8700
8707
  },
8701
8708
  sizeMB: 1969,
8702
8709
  sizeSource: "vendor",
@@ -8710,7 +8717,7 @@ ${n}` : n;
8710
8717
  place: "gpu",
8711
8718
  runtime: "onnxruntime-web@1.27.0",
8712
8719
  notes: [
8713
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
8720
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
8714
8721
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
8715
8722
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
8716
8723
  ],
@@ -8731,23 +8738,25 @@ ${n}` : n;
8731
8738
  spacing: "leading",
8732
8739
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
8733
8740
  tokenizer: "Xenova/clip-vit-base-patch16",
8734
- graphs
8741
+ graphs: {
8742
+ textEncoder: SD15[0],
8743
+ unet: SD15[1],
8744
+ vaeDecoder: SD15[2]
8745
+ }
8735
8746
  }
8736
8747
  }];
8737
8748
  /**
8738
8749
  * Listed for pickers, not registered by attachImagegen, so routing by
8739
- * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. The
8740
- * export's input and output names and dtypes were read from the end of
8741
- * each onnx file (2026-11-29, measured); the pipeline has not run on the
8742
- * real weights. `loadImagegen(hub, { id:
8743
- * "sdxl-turbo" })` adds it and loads it.
8750
+ * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. Its graph
8751
+ * names and dtypes were read from the export (2026-11-29) and it made a
8752
+ * picture on the real weights (2026-11-30, measured). `loadImagegen(hub,
8753
+ * { id: "sdxl-turbo" })` adds it and loads it.
8744
8754
  */
8745
8755
  const IMAGEGEN_PICKER_RECORDS = [{
8746
8756
  id: "sdxl-turbo",
8747
8757
  label: "sdxl-turbo 512",
8748
8758
  speed: "steady",
8749
- verdict: "not run yet",
8750
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
8759
+ verdict: "best looking, run once",
8751
8760
  group: "good",
8752
8761
  provides: ["imagegen"],
8753
8762
  provider: "ort",
@@ -8774,7 +8783,8 @@ ${n}` : n;
8774
8783
  notes: [
8775
8784
  "two text encoders, pooled embeddings and time ids, on generateXl",
8776
8785
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
8777
- "the highest quality of the three image models"
8786
+ "the highest quality of the three image models",
8787
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
8778
8788
  ],
8779
8789
  form: {
8780
8790
  steps: {
@@ -8631,6 +8631,11 @@ const files = [
8631
8631
  { path: "unet/model.onnx" },
8632
8632
  { path: "vae_decoder/model.onnx" }
8633
8633
  ];
8634
+ const SD15 = [
8635
+ "Stable-Diffusion-v1.5-text-encoder-float16",
8636
+ "sd-unet-v1.5-model-b2c4h64w64s77-float16-compute-and-inputs-layernorm",
8637
+ "Stable-Diffusion-v1.5-vae-decoder-float16-fp32-instancenorm"
8638
+ ];
8634
8639
  const free512 = { freeDimensionOverrides: {
8635
8640
  batch_size: 1,
8636
8641
  num_channels: 4,
@@ -8668,7 +8673,7 @@ const IMAGEGEN_RECORDS = [{
8668
8673
  notes: [
8669
8674
  "webgpu only, no wasm floor",
8670
8675
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)",
8671
- "graph file paths inferred, not checked against the repo"
8676
+ "graph files, names and dtypes read from the export (measured): fp32 edges, int32 input_ids, int64 timestep; pads with token 0"
8672
8677
  ],
8673
8678
  form: {
8674
8679
  steps: {
@@ -8682,6 +8687,7 @@ const IMAGEGEN_RECORDS = [{
8682
8687
  spacing: "trailing",
8683
8688
  note: "distilled from sd 2.1. 1 to 4 steps, no negative prompt. the fastest path.",
8684
8689
  tokenizer: "Xenova/clip-vit-base-patch16",
8690
+ pad: 0,
8685
8691
  graphs
8686
8692
  }
8687
8693
  }, {
@@ -8692,9 +8698,10 @@ const IMAGEGEN_RECORDS = [{
8692
8698
  group: "good",
8693
8699
  provides: ["imagegen"],
8694
8700
  provider: "ort",
8701
+ unrunnable: "its unet takes a fixed batch of 2 at 64 by 64 latents with fp16 inputs (measured from the graph); the pipeline sends batch 1 in fp32.",
8695
8702
  source: {
8696
8703
  repo: "microsoft/stable-diffusion-v1.5-webnn",
8697
- files
8704
+ files: SD15.map((g) => ({ path: `${g}.onnx` }))
8698
8705
  },
8699
8706
  sizeMB: 1969,
8700
8707
  sizeSource: "vendor",
@@ -8708,7 +8715,7 @@ const IMAGEGEN_RECORDS = [{
8708
8715
  place: "gpu",
8709
8716
  runtime: "onnxruntime-web@1.27.0",
8710
8717
  notes: [
8711
- "about 2 GB (vendor); the repo, its file paths and its input dtypes are inferred and not checked",
8718
+ "about 2 GB (vendor). the export's three graphs were read (measured): int32 input_ids, fp16 hidden states, a unet fixed at batch 2 with fp16 sample and int64 timestep, an fp16 vae",
8712
8719
  "runs the unet twice a step for guidance, so a step costs about twice an sd-turbo step (inferred)",
8713
8720
  "tokenizer: Xenova/clip-vit-base-patch16 through transformers.js (CLIP weights MIT)"
8714
8721
  ],
@@ -8729,23 +8736,25 @@ const IMAGEGEN_RECORDS = [{
8729
8736
  spacing: "leading",
8730
8737
  note: "classic sd, openrail-m licence. 20 to 30 steps with guidance, takes a negative prompt. slower per image.",
8731
8738
  tokenizer: "Xenova/clip-vit-base-patch16",
8732
- graphs
8739
+ graphs: {
8740
+ textEncoder: SD15[0],
8741
+ unet: SD15[1],
8742
+ vaeDecoder: SD15[2]
8743
+ }
8733
8744
  }
8734
8745
  }];
8735
8746
  /**
8736
8747
  * Listed for pickers, not registered by attachImagegen, so routing by
8737
- * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. The
8738
- * export's input and output names and dtypes were read from the end of
8739
- * each onnx file (2026-11-29, measured); the pipeline has not run on the
8740
- * real weights. `loadImagegen(hub, { id:
8741
- * "sdxl-turbo" })` adds it and loads it.
8748
+ * capability keeps SD-Turbo: SDXL-Turbo runs on `generateXl`. Its graph
8749
+ * names and dtypes were read from the export (2026-11-29) and it made a
8750
+ * picture on the real weights (2026-11-30, measured). `loadImagegen(hub,
8751
+ * { id: "sdxl-turbo" })` adds it and loads it.
8742
8752
  */
8743
8753
  const IMAGEGEN_PICKER_RECORDS = [{
8744
8754
  id: "sdxl-turbo",
8745
8755
  label: "sdxl-turbo 512",
8746
8756
  speed: "steady",
8747
- verdict: "not run yet",
8748
- unrunnable: "not run yet. the graph names and dtypes are read from the export's files (measured); the pipeline has not run on them.",
8757
+ verdict: "best looking, run once",
8749
8758
  group: "good",
8750
8759
  provides: ["imagegen"],
8751
8760
  provider: "ort",
@@ -8772,7 +8781,8 @@ const IMAGEGEN_PICKER_RECORDS = [{
8772
8781
  notes: [
8773
8782
  "two text encoders, pooled embeddings and time ids, on generateXl",
8774
8783
  "fp16 edges and a float16 timestep; input_ids int32 for the first encoder and int64 for the second (measured from the graphs)",
8775
- "the highest quality of the three image models"
8784
+ "the highest quality of the three image models",
8785
+ "run on real weights 2026-11-30, headless chrome on an apple m1: one step at 512 px in 9,966 ms, text 4,291, unet 2,315, vae 3,346 ms (measured); a faint fine grid shows on some surfaces"
8776
8786
  ],
8777
8787
  form: {
8778
8788
  steps: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackbuild/ai-views",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Views that bind the browser AI packages to hackbuild-ui: a model picker per job, a chat pane and composer, a drop first transcriber, a mask studio, a frame view and a camera feed. Each ships as a Vue component and a custom element.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "@hackbuild/chat": "0.1.3",
47
47
  "@hackbuild/devices": "0.1.4",
48
48
  "@hackbuild/embed": "0.1.5",
49
- "@hackbuild/imagegen": "0.2.2",
49
+ "@hackbuild/imagegen": "0.2.4",
50
50
  "@hackbuild/memory": "0.1.4",
51
51
  "@hackbuild/models": "0.2.3",
52
52
  "@hackbuild/speak": "0.1.4",