@graphty/webgpu-graph-algorithms 0.6.15 → 0.6.16

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.
Files changed (134) hide show
  1. package/README.md +5 -5
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{context-oXphO3yj.js → context-VIvatQOo.js} +61 -34
  4. package/dist/chunks/context-VIvatQOo.js.map +1 -0
  5. package/dist/node.js +1 -1
  6. package/dist/src/accelerator.d.ts +2 -1
  7. package/dist/src/accelerator.d.ts.map +1 -1
  8. package/dist/src/accelerator.js +53 -1
  9. package/dist/src/accelerator.js.map +1 -1
  10. package/dist/src/algorithms/all-pairs.d.ts +41 -0
  11. package/dist/src/algorithms/all-pairs.d.ts.map +1 -0
  12. package/dist/src/algorithms/all-pairs.js +181 -0
  13. package/dist/src/algorithms/all-pairs.js.map +1 -0
  14. package/dist/src/algorithms/components.d.ts +9 -1
  15. package/dist/src/algorithms/components.d.ts.map +1 -1
  16. package/dist/src/algorithms/components.js +2 -2
  17. package/dist/src/algorithms/components.js.map +1 -1
  18. package/dist/src/algorithms/label-propagation.d.ts +31 -0
  19. package/dist/src/algorithms/label-propagation.d.ts.map +1 -0
  20. package/dist/src/algorithms/label-propagation.js +254 -0
  21. package/dist/src/algorithms/label-propagation.js.map +1 -0
  22. package/dist/src/algorithms/simple-symmetric.d.ts +88 -0
  23. package/dist/src/algorithms/simple-symmetric.d.ts.map +1 -0
  24. package/dist/src/algorithms/simple-symmetric.js +347 -0
  25. package/dist/src/algorithms/simple-symmetric.js.map +1 -0
  26. package/dist/src/algorithms/triangles.d.ts +34 -0
  27. package/dist/src/algorithms/triangles.d.ts.map +1 -0
  28. package/dist/src/algorithms/triangles.js +203 -0
  29. package/dist/src/algorithms/triangles.js.map +1 -0
  30. package/dist/src/constants.d.ts +45 -0
  31. package/dist/src/constants.d.ts.map +1 -1
  32. package/dist/src/constants.js +45 -0
  33. package/dist/src/constants.js.map +1 -1
  34. package/dist/src/index.d.ts +8 -1
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js +7 -1
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/kernel/prelude.d.ts.map +1 -1
  39. package/dist/src/kernel/prelude.js +4 -1
  40. package/dist/src/kernel/prelude.js.map +1 -1
  41. package/dist/src/kernels.d.ts +16 -4
  42. package/dist/src/kernels.d.ts.map +1 -1
  43. package/dist/src/kernels.js +223 -3
  44. package/dist/src/kernels.js.map +1 -1
  45. package/dist/src/memory/residency.js +15 -4
  46. package/dist/src/memory/residency.js.map +1 -1
  47. package/dist/src/primitives/coo-to-csr.d.ts +73 -0
  48. package/dist/src/primitives/coo-to-csr.d.ts.map +1 -0
  49. package/dist/src/primitives/coo-to-csr.js +183 -0
  50. package/dist/src/primitives/coo-to-csr.js.map +1 -0
  51. package/dist/src/primitives/group-by-key.d.ts +82 -0
  52. package/dist/src/primitives/group-by-key.d.ts.map +1 -0
  53. package/dist/src/primitives/group-by-key.js +147 -0
  54. package/dist/src/primitives/group-by-key.js.map +1 -0
  55. package/dist/src/types/accelerator.d.ts +10 -2
  56. package/dist/src/types/accelerator.d.ts.map +1 -1
  57. package/dist/src/types/all-pairs.d.ts +35 -0
  58. package/dist/src/types/all-pairs.d.ts.map +1 -0
  59. package/dist/src/types/all-pairs.js +8 -0
  60. package/dist/src/types/all-pairs.js.map +1 -0
  61. package/dist/src/types/community.d.ts +18 -0
  62. package/dist/src/types/community.d.ts.map +1 -0
  63. package/dist/src/types/community.js +5 -0
  64. package/dist/src/types/community.js.map +1 -0
  65. package/dist/src/types/structure.d.ts +27 -0
  66. package/dist/src/types/structure.d.ts.map +1 -0
  67. package/dist/src/types/structure.js +8 -0
  68. package/dist/src/types/structure.js.map +1 -0
  69. package/dist/src/wgsl/apsp-fw.wgsl.d.ts +25 -0
  70. package/dist/src/wgsl/apsp-fw.wgsl.d.ts.map +1 -0
  71. package/dist/src/wgsl/apsp-fw.wgsl.js +113 -0
  72. package/dist/src/wgsl/apsp-fw.wgsl.js.map +1 -0
  73. package/dist/src/wgsl/apsp-init.wgsl.d.ts +12 -0
  74. package/dist/src/wgsl/apsp-init.wgsl.d.ts.map +1 -0
  75. package/dist/src/wgsl/apsp-init.wgsl.js +26 -0
  76. package/dist/src/wgsl/apsp-init.wgsl.js.map +1 -0
  77. package/dist/src/wgsl/coo-emit.wgsl.d.ts +10 -0
  78. package/dist/src/wgsl/coo-emit.wgsl.d.ts.map +1 -0
  79. package/dist/src/wgsl/coo-emit.wgsl.js +33 -0
  80. package/dist/src/wgsl/coo-emit.wgsl.js.map +1 -0
  81. package/dist/src/wgsl/coo-scatter.wgsl.d.ts +15 -0
  82. package/dist/src/wgsl/coo-scatter.wgsl.d.ts.map +1 -0
  83. package/dist/src/wgsl/coo-scatter.wgsl.js +32 -0
  84. package/dist/src/wgsl/coo-scatter.wgsl.js.map +1 -0
  85. package/dist/src/wgsl/group-by-key-row.wgsl.d.ts +26 -0
  86. package/dist/src/wgsl/group-by-key-row.wgsl.d.ts.map +1 -0
  87. package/dist/src/wgsl/group-by-key-row.wgsl.js +146 -0
  88. package/dist/src/wgsl/group-by-key-row.wgsl.js.map +1 -0
  89. package/dist/src/wgsl/lpa-step.wgsl.d.ts +10 -0
  90. package/dist/src/wgsl/lpa-step.wgsl.d.ts.map +1 -0
  91. package/dist/src/wgsl/lpa-step.wgsl.js +35 -0
  92. package/dist/src/wgsl/lpa-step.wgsl.js.map +1 -0
  93. package/dist/src/wgsl/orient-flags.wgsl.d.ts +9 -0
  94. package/dist/src/wgsl/orient-flags.wgsl.d.ts.map +1 -0
  95. package/dist/src/wgsl/orient-flags.wgsl.js +21 -0
  96. package/dist/src/wgsl/orient-flags.wgsl.js.map +1 -0
  97. package/dist/src/wgsl/run-flags.wgsl.d.ts +8 -0
  98. package/dist/src/wgsl/run-flags.wgsl.d.ts.map +1 -0
  99. package/dist/src/wgsl/run-flags.wgsl.js +18 -0
  100. package/dist/src/wgsl/run-flags.wgsl.js.map +1 -0
  101. package/dist/src/wgsl/tri-intersect.wgsl.d.ts +11 -0
  102. package/dist/src/wgsl/tri-intersect.wgsl.d.ts.map +1 -0
  103. package/dist/src/wgsl/tri-intersect.wgsl.js +64 -0
  104. package/dist/src/wgsl/tri-intersect.wgsl.js.map +1 -0
  105. package/dist/webgpu-graph-algorithms.js +1819 -181
  106. package/dist/webgpu-graph-algorithms.js.map +1 -1
  107. package/package.json +2 -2
  108. package/src/accelerator.ts +56 -1
  109. package/src/algorithms/all-pairs.ts +228 -0
  110. package/src/algorithms/components.ts +2 -2
  111. package/src/algorithms/label-propagation.ts +280 -0
  112. package/src/algorithms/simple-symmetric.ts +409 -0
  113. package/src/algorithms/triangles.ts +240 -0
  114. package/src/constants.ts +45 -0
  115. package/src/index.ts +12 -1
  116. package/src/kernel/prelude.ts +6 -0
  117. package/src/kernels.ts +248 -6
  118. package/src/memory/residency.ts +15 -4
  119. package/src/primitives/coo-to-csr.ts +251 -0
  120. package/src/primitives/group-by-key.ts +209 -0
  121. package/src/types/accelerator.ts +10 -2
  122. package/src/types/all-pairs.ts +37 -0
  123. package/src/types/community.ts +18 -0
  124. package/src/types/structure.ts +28 -0
  125. package/src/wgsl/apsp-fw.wgsl.ts +112 -0
  126. package/src/wgsl/apsp-init.wgsl.ts +25 -0
  127. package/src/wgsl/coo-emit.wgsl.ts +32 -0
  128. package/src/wgsl/coo-scatter.wgsl.ts +31 -0
  129. package/src/wgsl/group-by-key-row.wgsl.ts +145 -0
  130. package/src/wgsl/lpa-step.wgsl.ts +34 -0
  131. package/src/wgsl/orient-flags.wgsl.ts +20 -0
  132. package/src/wgsl/run-flags.wgsl.ts +17 -0
  133. package/src/wgsl/tri-intersect.wgsl.ts +63 -0
  134. package/dist/chunks/context-oXphO3yj.js.map +0 -1
package/README.md CHANGED
@@ -695,7 +695,7 @@ never relaxed silently.
695
695
 
696
696
  <!-- targets-table:nvidia-lovelace-driver580 -->
697
697
 
698
- Generated by `pnpm run bench:readme` from `benchmarks/results/targets.json`. Each figure is the best median the row has recorded, the baseline `bench:compare` pins: Node rows across the 8 session(s) of `benchmarks/results/nvidia-lovelace-driver580.json`, Chromium rows across the 3 of `benchmarks/results/nvidia-lovelace-driver0.json`.
698
+ Generated by `pnpm run bench:readme` from `benchmarks/results/targets.json`. Each figure is the best median the row has recorded, the baseline `bench:compare` pins: Node rows across the 10 session(s) of `benchmarks/results/nvidia-lovelace-driver580.json`, Chromium rows across the 3 of `benchmarks/results/nvidia-lovelace-driver0.json`.
699
699
 
700
700
  | Id | What | Target | Measured | Status |
701
701
  | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------- | -------- |
@@ -722,11 +722,11 @@ Generated by `pnpm run bench:readme` from `benchmarks/results/targets.json`. Eac
722
722
  | T-14 | Fruchterman-Reingold exact tier, GPU time per iteration (profiler) at 100k (`repulsion: "exact"`) | recorded | 16.322 ms | recorded |
723
723
  | T-14 | Spring-electrical preset, GPU time per iteration (profiler) at 10k | recorded | 0.648 ms | recorded |
724
724
  | T-14 | Spring-electrical preset, GPU time per iteration (profiler) at 100k (`repulsion: "exact"`) | recorded | 18.154 ms | recorded |
725
- | T-10 | BFS direction-optimizing (`breadthFirstSearch`), wall end to end including the upload, from node 0 of the undirected RMAT at 1M / 10M (a contract on the dev box only) | <= 100 ms | 89.706 ms | met |
726
- | T-10 | BFS top-down, the same traversal at 1M / 10M | recorded | 97.061 ms | recorded |
725
+ | T-10 | BFS direction-optimizing (`breadthFirstSearch`), wall end to end including the upload, from node 0 of the undirected RMAT at 1M / 10M (a contract on the dev box only) | <= 100 ms | 84.989 ms | met |
726
+ | T-10 | BFS top-down, the same traversal at 1M / 10M | recorded | 81.261 ms | recorded |
727
727
  | T-10 | BFS direction-optimizing, the same traversal at 100k / 1M | recorded | 12.837 ms | recorded |
728
- | T-10 | BFS on the 1000 x 1000 grid from a corner (1,999 levels), wall including the upload (a contract on the dev box only) | <= 1500 ms | 425.858 ms | met |
729
- | T-10 | `sssp` (the near-far queue), wall end to end including the upload, random f32 weights in [0.1, 10), at 1M / 10M | recorded | 266.241 ms | recorded |
728
+ | T-10 | BFS on the 1000 x 1000 grid from a corner (1,999 levels), wall including the upload (a contract on the dev box only) | <= 1500 ms | 369.673 ms | met |
729
+ | T-10 | `sssp` (the near-far queue), wall end to end including the upload, random f32 weights in [0.1, 10), at 1M / 10M | recorded | 256.320 ms | recorded |
730
730
  | T-10 | `sssp`, the same run at 100k / 1M | recorded | 47.421 ms | recorded |
731
731
 
732
732
  <!-- /targets-table:nvidia-lovelace-driver580 -->
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G as GpuContext, W as WebGpuGraphError } from "./chunks/context-oXphO3yj.js";
1
+ import { G as GpuContext, W as WebGpuGraphError } from "./chunks/context-VIvatQOo.js";
2
2
  function navigatorGpu() {
3
3
  if (typeof navigator === "undefined") {
4
4
  return void 0;
@@ -106,6 +106,14 @@ const BC_BATCH_BUDGET_FRACTION = 0.25;
106
106
  const BC_MAX_BATCH = 64;
107
107
  const BC_EDGE_PARALLEL_GAMMA = 2;
108
108
  const BC_BACKWARD_LEVELS_PER_SUBMIT = 64;
109
+ const APSP_TILE = 32;
110
+ const APSP_MAX_DISPATCHES_PER_SUBMIT = 4096;
111
+ const LABEL_PROP_PASSES_PER_SUBMIT = 8;
112
+ const GROUP_ROW_THREAD_MAX = 32;
113
+ const GROUP_ROW_THREAD_LIMIT = 128;
114
+ const PARALLEL_MERGE_LIMIT = 65e3;
115
+ const GROUP_HASH_LOAD_FACTOR = 2;
116
+ const TRIANGLE_BINARY_SEARCH_RATIO = 32;
109
117
  const PASSTHROUGH_FORMAT_CODES = Object.freeze(["E_GPU_INELIGIBLE", "E_UNKNOWN_NODE", "E_UNKNOWN_COLUMN", "E_COLUMN_LENGTH"]);
110
118
  const EMPTY_DETAILS = Object.freeze({});
111
119
  class WebGpuGraphError extends Error {
@@ -926,6 +934,9 @@ const GRID_EXTENT_FLOOR: f32 = ${wgslF32Literal(GRID_EXTENT_FLOOR)};
926
934
  const GRID_BBOX_MARGIN: f32 = ${wgslF32Literal(GRID_BBOX_MARGIN)};
927
935
  const RADIX_BINS: u32 = ${RADIX_BINS}u;
928
936
  const RADIX_DIGIT_MASK: u32 = ${RADIX_BINS - 1}u;
937
+ const APSP_TILE: u32 = ${APSP_TILE}u;
938
+ const GROUP_HASH_LOAD_FACTOR: u32 = ${GROUP_HASH_LOAD_FACTOR}u;
939
+ const TRIANGLE_BINARY_SEARCH_RATIO: u32 = ${TRIANGLE_BINARY_SEARCH_RATIO}u;
929
940
  const F32_MAX: f32 = 0x1.fffffep+127;
930
941
  override WG: u32 = ${WORKGROUP_SIZE}u;
931
942
  override USE_PERM: bool = false;
@@ -2637,7 +2648,8 @@ class GraphResidency {
2637
2648
  /**
2638
2649
  * Uploads (or finds) a view: outDegree / inDegree / degreeOrder / reverseDegreeOrder upload one array each;
2639
2650
  * reverse and edgeList (P7) upload their arrays perArray, never into the arena, and are memoised per record so
2640
- * a second call uploads nothing (spec 4.3). coo and mate -> E_UNSUPPORTED until P11. packViews concatenates a
2651
+ * a second call uploads nothing (spec 4.3). coo uploads its per-arc `src` (P11; the rest aliases the core); mate ->
2652
+ * E_UNSUPPORTED. packViews concatenates a
2641
2653
  * reverse or edgeList view into ONE buffer at STORAGE_ALIGN offsets; on any other view `true` is E_UNSUPPORTED
2642
2654
  * { option: "packViews" }.
2643
2655
  * @param s - the snapshot
@@ -2704,10 +2716,18 @@ class GraphResidency {
2704
2716
  break;
2705
2717
  }
2706
2718
  case "coo":
2719
+ this.assertNotReleased(s);
2720
+ this.assertNonEmpty(s);
2721
+ if (s.arcCount === 0) {
2722
+ return Object.freeze({ view: name, bindings: Object.freeze({}), scalars: Object.freeze({}) });
2723
+ }
2724
+ array = s.coo().src;
2725
+ bindingName = "src";
2726
+ break;
2707
2727
  case "mate":
2708
- throw new WebGpuGraphError("E_UNSUPPORTED", `the ${name} view is not uploaded before P11`, {
2709
- feature: `view:${name}`,
2710
- hint: "outDegree, inDegree, degreeOrder, reverseDegreeOrder, reverse and edgeList are uploaded"
2728
+ throw new WebGpuGraphError("E_UNSUPPORTED", "the mate view is not uploaded: no kernel reads it", {
2729
+ feature: "view:mate",
2730
+ hint: "outDegree, inDegree, degreeOrder, reverseDegreeOrder, coo, reverse and edgeList are uploaded"
2711
2731
  });
2712
2732
  default:
2713
2733
  throw invalid("name", name, "a view name");
@@ -3517,33 +3537,40 @@ class GpuContext {
3517
3537
  }
3518
3538
  }
3519
3539
  export {
3520
- FR_START_TEMPERATURE as A,
3540
+ SE_SCALE_REFERENCE_NODES as $,
3541
+ APSP_MAX_DISPATCHES_PER_SUBMIT as A,
3521
3542
  BufferUsage as B,
3522
- FA2_FLAG_ADAPTIVE as C,
3523
- SETTLE_FLOOR_FRACTION as D,
3543
+ LAYOUT_TUNING_DEFAULTS as C,
3544
+ EXACT_MAX_NODES as D,
3524
3545
  EXACT_TILES_PER_PASS as E,
3525
3546
  FUSED_FRONTIER_MAX as F,
3526
3547
  GpuContext as G,
3527
- FR_REHEAT_FRACTION as H,
3548
+ SETTLE_FLOOR_UNBOUNDED as H,
3528
3549
  INDIRECT_ARGS_STRIDE as I,
3529
- FR_DEFAULTS as J,
3530
- SE_DEFAULTS as K,
3531
- LAYOUT_TUNING_DEFAULTS as L,
3550
+ GRID_BBOX_MARGIN as J,
3551
+ GRID_EXTENT_FLOOR as K,
3552
+ LABEL_PROP_PASSES_PER_SUBMIT as L,
3532
3553
  MAX_WORKGROUPS_PER_DIM as M,
3533
- SETTLE_FLOOR_REFERENCE_NODES as N,
3534
- SE_SCALE_REFERENCE_NODES as O,
3535
- PARTIAL_BYTES as P,
3536
- ARC_WINDOW_ALIGN as Q,
3554
+ FR_ADAPTIVE_MAX_ITERATIONS as N,
3555
+ FR_START_TEMPERATURE as O,
3556
+ PARALLEL_MERGE_LIMIT as P,
3557
+ FA2_FLAG_ADAPTIVE as Q,
3537
3558
  RADIX_BINS as R,
3538
3559
  STATE_HEADER_BYTES as S,
3539
3560
  TRACE_RECORD_BYTES as T,
3540
3561
  UNIFORM_SLOT_BYTES as U,
3541
- PASSTHROUGH_FORMAT_CODES as V,
3562
+ SETTLE_FLOOR_FRACTION as V,
3542
3563
  WebGpuGraphError as W,
3543
- STORAGE_ALIGN as X,
3544
- WORKGROUP_SIZE as Y,
3545
- isSoftwareAdapter as Z,
3564
+ FR_REHEAT_FRACTION as X,
3565
+ FR_DEFAULTS as Y,
3566
+ SE_DEFAULTS as Z,
3567
+ SETTLE_FLOOR_REFERENCE_NODES as _,
3546
3568
  WGSL_RESERVED_WORDS as a,
3569
+ ARC_WINDOW_ALIGN as a0,
3570
+ PASSTHROUGH_FORMAT_CODES as a1,
3571
+ STORAGE_ALIGN as a2,
3572
+ WORKGROUP_SIZE as a3,
3573
+ isSoftwareAdapter as a4,
3547
3574
  U32_MAX as b,
3548
3575
  MAX_LEVELS_PER_SUBMIT as c,
3549
3576
  deviceLostError as d,
@@ -3555,19 +3582,19 @@ export {
3555
3582
  BC_BATCH_BUDGET_FRACTION as j,
3556
3583
  BC_MAX_BATCH as k,
3557
3584
  BC_BACKWARD_LEVELS_PER_SUBMIT as l,
3558
- GRID_COARSEST_SIDE as m,
3559
- GRID_MIN_SIDE as n,
3560
- GRID_SORT_BITS as o,
3561
- FA2_DEFAULTS as p,
3562
- MAX_ITERATIONS_PER_STEP as q,
3563
- MAX_1D_ITEMS as r,
3564
- hasErrorCode as s,
3565
- FA2_FLAG_FIRST as t,
3566
- GRID_HUB_CELL as u,
3567
- EXACT_MAX_NODES as v,
3568
- SETTLE_FLOOR_UNBOUNDED as w,
3569
- GRID_BBOX_MARGIN as x,
3570
- GRID_EXTENT_FLOOR as y,
3571
- FR_ADAPTIVE_MAX_ITERATIONS as z
3585
+ APSP_TILE as m,
3586
+ GROUP_ROW_THREAD_MAX as n,
3587
+ GROUP_ROW_THREAD_LIMIT as o,
3588
+ GROUP_HASH_LOAD_FACTOR as p,
3589
+ GRID_COARSEST_SIDE as q,
3590
+ GRID_MIN_SIDE as r,
3591
+ GRID_SORT_BITS as s,
3592
+ FA2_DEFAULTS as t,
3593
+ MAX_ITERATIONS_PER_STEP as u,
3594
+ MAX_1D_ITEMS as v,
3595
+ hasErrorCode as w,
3596
+ FA2_FLAG_FIRST as x,
3597
+ PARTIAL_BYTES as y,
3598
+ GRID_HUB_CELL as z
3572
3599
  };
3573
- //# sourceMappingURL=context-oXphO3yj.js.map
3600
+ //# sourceMappingURL=context-VIvatQOo.js.map