Skip to content

Latest commit

 

History

History
807 lines (765 loc) · 22.2 KB

index.md

File metadata and controls

807 lines (765 loc) · 22.2 KB
title Performance profile
<style> .saps-filter-bar { position: sticky; top: 0; z-index: 30; background: var(--theme-background, #fff); padding: 0.5rem 0; margin: 0.35rem 0 0.75rem; border-bottom: 1px solid var(--theme-foreground-faintest, #e2e2ea); } .saps-tag-menu-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; } .saps-tag-count { font-size: 0.72rem; color: var(--theme-foreground-muted, #5f6b73); margin-left: 0.2rem; } .saps-tag-menu { display: inline-block; min-width: 0; width: 11rem; max-width: 11rem; position: relative; vertical-align: top; } .saps-tag-menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: space-between; gap: 0.45rem; width: 100%; padding: 0.4rem 0.75rem; border: 1px solid var(--theme-foreground-faintest, #d9d9e3); border-radius: 999px; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 700; line-height: 1.2; box-sizing: border-box; transition: border-color 0.12s ease, color 0.12s ease; } .saps-tag-menu summary:hover, .saps-tag-menu[open] summary { border-color: #3b9cba; color: #2f7d95; } .saps-tag-menu summary::-webkit-details-marker { display: none; } .saps-tag-menu summary::after { content: "▾"; font-size: 0.72rem; } .saps-tag-menu[open] summary::after { content: "▴"; } .saps-tag-menu__panel { margin-top: 0.25rem; padding: 0.4rem 0.55rem; border: 1px solid var(--theme-foreground-faintest, #d9d9e3); border-radius: 0.75rem; background: var(--theme-background, #fff); box-shadow: 0 0.5rem 1.2rem rgba(30, 30, 30, 0.08); position: absolute; left: 0; z-index: 40; box-sizing: border-box; width: 11.5rem; max-width: 11.5rem; min-width: 0; max-height: 17rem; overflow-y: auto; overflow-x: hidden; } .saps-tag-menu__actions { display: flex; gap: 0.35rem; padding-bottom: 0.3rem; margin-bottom: 0.25rem; border-bottom: 1px solid var(--theme-foreground-faintest, #e6e6ee); } .saps-tag-menu__action { appearance: none; border: 1px solid var(--theme-foreground-faintest, #d9d9e3); background: transparent; color: inherit; border-radius: 999px; padding: 0.12rem 0.5rem; font-size: 0.6rem; font-weight: 600; cursor: pointer; } .saps-tag-menu__action:hover { border-color: #3b9cba; color: #2f7d95; } .saps-tag-menu__section { display: flex; flex-direction: column; gap: 0.15rem; } .saps-tag-menu__section + .saps-tag-menu__section { margin-top: 0.3rem; } .saps-tag-menu__section-label { font-size: 0.54rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--theme-foreground-muted, #5f6b73); font-weight: 700; padding: 0.05rem 0; } .saps-tag-menu__panel label { display: flex; align-items: flex-start; gap: 0.25rem; width: 100%; max-width: 100%; min-width: 0; font-size: 0.62rem; font-weight: 500; white-space: normal; overflow-wrap: anywhere; word-break: break-word; line-height: 1.25; cursor: pointer; } .saps-tag-menu__panel input[type="checkbox"] { margin: 0.1rem 0.3rem 0 0; accent-color: #3b9cba; } @media (max-width: 42rem) { .saps-tag-menu { width: auto; max-width: none; flex: 1 1 9.5rem; } .saps-tag-menu__panel { width: min(16rem, calc(100vw - 3rem)); max-width: none; } } /* Right-aligns the color legend above the chart (see the `className: "saps-plot"` option passed to Plot.plot below). */ .saps-plot-figure { justify-content: right; margin: 0.1rem 0; } .saps-section { margin: 1.4rem 0 2.1rem; padding-top: 0.25rem; } .saps-section + .saps-section { border-top: 1px solid var(--theme-foreground-faintest, #e2e2ea); padding-top: 1.25rem; } .saps-section-heading { margin: 0 0 0.6rem; font-size: 1.2rem; font-weight: 700; } .saps-controls-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; margin: 0.2rem 0 0.85rem; } .saps-control-group { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; } .saps-control-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--theme-foreground-muted, #5f6b73); } .saps-pill-group { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; } .saps-pill { appearance: none; border: 1px solid var(--theme-foreground-faintest, #d9d9e3); background: var(--theme-background, #fff); color: inherit; border-radius: 999px; padding: 0.32rem 0.72rem; font-size: 0.7rem; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease; } .saps-pill:hover { border-color: #3b9cba; color: #2f7d95; } .saps-pill[aria-pressed="true"] { background: #3b9cba; border-color: #3b9cba; color: #fff; } .saps-pill[aria-pressed="true"]:hover { background: #2f7d95; border-color: #2f7d95; color: #fff; } .saps-radar-wrap { position: relative; margin: 0.4rem 0 1rem; } .saps-radar-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.65rem 0.5rem; align-items: center; } .saps-radar-ref-card { grid-column: 1 / span 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.25rem 0.35rem; } .saps-radar-panel-title { font-size: 0.84rem; font-weight: 700; text-align: center; margin-bottom: 0.15rem; color: #2a2a35; } .saps-radar-legend-svg { width: 100%; max-width: 28rem; height: auto; overflow: visible; display: block; } .saps-radar-fw-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0.15rem 0.1rem; } .saps-radar-cell-svg { width: 100%; max-width: 11.2rem; height: auto; display: block; overflow: visible; } .saps-radar-fw-caption { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; margin-top: 0.25rem; font-size: 0.8rem; font-weight: 600; white-space: nowrap; } .saps-radar-swatch { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex: 0 0 auto; } .saps-radar-gpu-badge { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.05rem 0.32rem; border-radius: 999px; background: #ececf4; color: #4a4a62; } @media (max-width: 60rem) { .saps-radar-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } } @media (max-width: 42rem) { .saps-radar-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .saps-radar-ref-card { grid-column: 1 / -1; grid-row: auto; } } .saps-radar-tooltip { position: absolute; z-index: 40; pointer-events: none; background: rgba(24, 24, 30, 0.94); color: #fff; padding: 0.45rem 0.65rem; border-radius: 0.45rem; font-size: 0.72rem; line-height: 1.38; box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.22); max-width: 20rem; } .saps-radar-tooltip__title { font-weight: 700; margin-bottom: 0.15rem; } .saps-radar-tooltip__sub { color: #c8c8d8; margin-top: 0.1rem; } .saps-outcome-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.85rem; margin: 0.25rem 0 0.6rem; font-size: 0.72rem; line-height: 1.3; } .saps-outcome-legend__item { display: inline-flex; align-items: center; gap: 0.35rem; } .saps-outcome-legend__swatch { width: 0.72rem; height: 0.72rem; border-radius: 2px; border: 1px solid rgba(0, 0, 0, 0.12); display: inline-block; } .saps-tags-details { margin: 0 0 0.9rem; padding: 0.1rem 0.7rem; border: 1px solid var(--theme-foreground-faintest, #d9d9e3); border-radius: 0.4rem; } .saps-tags-details > summary { padding: 0.35rem 0; cursor: pointer; font-size: 0.76rem; font-weight: 700; color: var(--theme-foreground-muted, #5f6b73); } .saps-tags-details__body { padding: 0.25rem 0 0.5rem; } </style>
import {buildProfile} from "./components/profile.js";
const [results, benchmarks, run] = await Promise.all([
  FileAttachment("./data/results.csv").csv(),
  FileAttachment("./data/benchmarks.csv").csv(),
  FileAttachment("./data/run.json").json()
]);
const profile = buildProfile(results, benchmarks, run.frameworks);
import {GPU_FRAMEWORKS, frameworkColors, orderFrameworks} from "./components/palette.js";
import {computeRadarPanels, renderRadarGrid} from "./components/radar.js";
import {renderOutcomeLegend, summarizeOutcomes} from "./components/outcomes.js";
const outcomes = await FileAttachment("./data/outcomes.csv").csv();
const orderedFrameworks = orderFrameworks(Object.keys(profile.series));
const fwColorMap = frameworkColors(orderedFrameworks);
const availableRadarPanels = computeRadarPanels(results, benchmarks, orderedFrameworks, {
  failureTime: run.timeout ?? 180
});

Results from ${html<a href=${run.resultsUrl} target="_blank" rel="noopener">${run.run}</a>}. Each benchmark has equal weight, divided among its selected datasets.

import {tagMenu} from "./components/tagMenu.js";

const hiddenTags = new Set(["standard", "test", "trace", "suite-standard", "suite-test", "suite-trace"]);
const workloadTags = new Set([
  "high-dimensional",
  "tensor",
  "large-query",
  "elementary-ops",
  "transcendental-ops",
  "shape-ops",
  "linalg-ops",
  "fancy-ops",
  "index-ops",
  "nonzero-fill",
  "iterative",
  "dense",
  "hypersparse",
  "dynamic-sparsity"
]);
const groupOf = (tag) => {
  if (tag.startsWith("feature-") || workloadTags.has(tag)) return "workload";
  if (tag.startsWith("suite-")) return "suites";
  return "concepts";
};

const allTags = [...new Set(profile.problems.flatMap((p) => p.tags))]
  .filter((tag) => !hiddenTags.has(tag))
  .sort();

const keepMenu = tagMenu(allTags, {
  label: "Include tags",
  groupOf,
  groupOrder: ["workload", "suites", "concepts"],
  showActions: true
});
const dropMenu = tagMenu(allTags, {
  label: "Exclude tags",
  groupOf,
  groupOrder: ["workload", "suites", "concepts"],
  showActions: true
});
const frameworkMenu = tagMenu(orderedFrameworks, {
  label: "Frameworks",
  value: orderedFrameworks,
  groupOf: (fw) => (GPU_FRAMEWORKS.has(fw) ? "GPU" : "CPU"),
  groupOrder: ["CPU", "GPU"],
  showActions: true,
  formatSummary: (count, totalCount) =>
    count === totalCount ? "Frameworks (All)" : `Frameworks (${count}/${totalCount})`
});

const countEl = document.createElement("span");
countEl.className = "saps-tag-count";

const filterBar = document.createElement("div");
filterBar.className = "saps-filter-bar";
const row = document.createElement("div");
row.className = "saps-tag-menu-row";
row.append(keepMenu, dropMenu, frameworkMenu, countEl);
filterBar.append(row);
display(filterBar);

const keep = Generators.input(keepMenu);
const drop = Generators.input(dropMenu);
const selectedFrameworks = Generators.input(frameworkMenu);
const keepSet = new Set(keep);
const dropSet = new Set(drop);
const ok = profile.problems.map((p) =>
  (keepSet.size === 0 || p.tags.some((t) => keepSet.has(t))) &&
  !p.tags.some((t) => dropSet.has(t))
);
countEl.textContent = `${ok.filter(Boolean).length.toLocaleString()} problems`;

const nKept = new Map();
profile.problems.forEach((p, i) => {
  if (ok[i]) nKept.set(p.benchmark, (nKept.get(p.benchmark) ?? 0) + 1);
});
const total = nKept.size;
const xMax = Math.min(profile.xMax, 100);

const solvable = Array.isArray(profile.solvable)
  ? profile.solvable
  : (() => {
      const solved = new Set();
      for (const points of Object.values(profile.series)) {
        for (const [i] of points) solved.add(i);
      }
      return profile.problems.map((_, i) => solved.has(i));
    })();

let completablePct = 0;
if (total > 0) {
  profile.problems.forEach((p, i) => {
    if (ok[i] && solvable[i]) {
      completablePct += (100 / nKept.get(p.benchmark)) / total;
    }
  });
}

const curves = total === 0 ? [] : Object.entries(profile.series).flatMap(([framework, points]) => {
  let cum = 0;
  const pts = points
    .filter(([i, ratio]) => ok[i] && ratio <= xMax)
    .map(([i, ratio]) => ({
      framework,
      ratio,
      pct: (100 * (cum += 1 / nKept.get(profile.problems[i].benchmark))) / total
    }));
  pts.unshift({framework, ratio: 1, pct: 0});
  pts.push({framework, ratio: xMax, pct: pts.at(-1)?.pct ?? 0});
  return pts;
});
const selectedSet = new Set(selectedFrameworks);
const visibleFrameworks = orderedFrameworks.filter((fw) => selectedSet.has(fw));
const visibleCurves = curves.filter((pt) => selectedSet.has(pt.framework));
const radarPanels = computeRadarPanels(results, benchmarks, orderedFrameworks, {
  failureTime: run.timeout ?? 180,
  okMask: ok
});
function pillGroup(options, initialValue) {
  const container = document.createElement("div");
  container.className = "saps-pill-group";
  let current = initialValue;
  const buttons = options.map(([value, label]) => {
    const btn = document.createElement("button");
    btn.type = "button";
    btn.className = "saps-pill";
    btn.textContent = label;
    btn.setAttribute("aria-pressed", String(value === current));
    btn.addEventListener("click", () => {
      current = value;
      for (const b of buttons) b.setAttribute("aria-pressed", String(b.dataset.value === current));
      container.dispatchEvent(new Event("input", {bubbles: true}));
    });
    btn.dataset.value = value;
    container.append(btn);
    return btn;
  });
  Object.defineProperty(container, "value", {
    get: () => current,
    set: (v) => {
      current = v;
      for (const b of buttons) b.setAttribute("aria-pressed", String(b.dataset.value === current));
    }
  });
  return container;
}
Workload tags

Each benchmark/dataset is tagged with workload descriptors, discovered programmatically through tracing. The table below lists each tag and a short description.

Tag Description
high-dimensional 5 or more dimensions in a tensor.
tensor 3 or more dimensions in a tensor.
large-query 5 or more operands on one line.
elementary-ops PEMDAS-only.
transcendental-ops Contains sin, cos, pow, exp, or related operations.
shape-ops Reshape, concat, transpose, squeeze, or similar operations.
linalg-ops Contains xp.linalg or solver-like operations; dot is okay.
fancy-ops min, max, and, or, shift, or similar operations.
index-ops Contains indexing.
nonzero-fill Uses a fill value other than zero.
iterative Loops over a matrix or repeats until convergence.
dense Exclusively dense problems.
hypersparse Contains hypersparsity, such as nnz << n for a dimension.
dynamic-sparsity Sparse-sparse interactions may change the sparsity pattern.

Performance profile

const xTicks = [1, 2, 4, 10, 20, 40, 100].filter((t) => t <= xMax);
if (xTicks.at(-1) < xMax) xTicks.push(xMax);
const yTicks = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];

display(
  total === 0
    ? html`<p role="status">No problems match these tags.</p>`
    : visibleFrameworks.length === 0
      ? html`<p role="status">No frameworks selected.</p>`
      : Plot.plot({
          className: "saps-plot",
          width,
          height: 540,
          marginLeft: 56,
          marginRight: 20,
          marginBottom: 42,
          x: {
            type: "log",
            domain: [1, xMax],
            ticks: xTicks,
            tickFormat: (d) => `${d}×`,
            label: "Ratio (runtime / best runtime)"
          },
          y: {
            domain: [0, 100],
            ticks: yTicks,
            tickFormat: (d) => `${d}%`,
            grid: true,
            label: "% of suite completed"
          },
          color: {
            legend: true,
            domain: visibleFrameworks,
            range: visibleFrameworks.map((fw) => fwColorMap[fw])
          },
          marks: [
            Plot.ruleY([completablePct], {
              stroke: "#444",
              strokeDasharray: "6,4",
              strokeWidth: 1.5
            }),
            Plot.text(
              [
                {
                  ratio: xMax,
                  pct: completablePct,
                  label: `Completable by any framework (${completablePct.toFixed(1)}%)`
                }
              ],
              {
                x: "ratio",
                y: "pct",
                text: "label",
                textAnchor: "end",
                dx: -4,
                dy: completablePct > 93 ? 13 : -8,
                fill: "#333",
                fontSize: 11.5,
                fontWeight: 600
              }
            ),
            Plot.line(visibleCurves, {
              x: "ratio",
              y: "pct",
              stroke: "framework",
              curve: "step-after",
              strokeWidth: 2.8,
              tip: {
                format: {
                  x: (d) => `${Number(d).toFixed(2)}×`,
                  y: (d) => `${Number(d).toFixed(1)}%`
                }
              }
            })
          ]
        })
);

At 1×, a framework matches the fastest runtime for a problem. At 2×, it takes at most twice as long. The dashed line marks the share of the suite completable by at least one framework. Failed measurements remain in the suite but do not contribute successes. Include tags match any selection; exclude tags take precedence.

Radar profiles

const defaultRadarPanel = availableRadarPanels.some((p) => p.id === "character")
  ? "character"
  : (availableRadarPanels[0]?.id ?? "character");
const radarGroupControl = pillGroup(
  availableRadarPanels.map((p) => [p.id, p.title]),
  defaultRadarPanel
);
const radarMetricControl = pillGroup(
  [
    ["penalized_speed", "Penalized speed"],
    ["completion", "Completion"]
  ],
  "penalized_speed"
);

const groupWrap = document.createElement("div");
groupWrap.className = "saps-control-group";
const groupLabel = document.createElement("span");
groupLabel.className = "saps-control-label";
groupLabel.textContent = "Grouping";
groupWrap.append(groupLabel, radarGroupControl);

const metricWrap = document.createElement("div");
metricWrap.className = "saps-control-group";
const metricLabel = document.createElement("span");
metricLabel.className = "saps-control-label";
metricLabel.textContent = "Metric";
metricWrap.append(metricLabel, radarMetricControl);

const radarControlsRow = document.createElement("div");
radarControlsRow.className = "saps-controls-row";
radarControlsRow.append(groupWrap, metricWrap);
display(radarControlsRow);

const selectedRadarPanel = Generators.input(radarGroupControl);
const selectedRadarMetric = Generators.input(radarMetricControl);
renderRadarGrid(radarPanels, {
  selectedPanel: selectedRadarPanel,
  metric: selectedRadarMetric,
  visibleFrameworks
})

Analysis by framework evaluated across application groups, computational character, and trace-derived features. Penalized speed is the geometric mean slowdown relative to the fastest framework over every problem at least one framework solved, charging failures the ${run.timeout ?? 180} s measurement timeout and capping slowdowns at 1000×. Completion is the share of problems solved relative to the framework that solved the most in that group. Larger shapes are better.

Outcomes analysis

const outcomeModeControl = pillGroup(
  [["all", "All outcomes"], ["failures", "Failures only"]],
  "all"
);
const outcomeScopeNote = document.createElement("span");
outcomeScopeNote.className = "saps-tag-count";
const outcomeControlsRow = document.createElement("div");
outcomeControlsRow.className = "saps-controls-row";
outcomeControlsRow.append(outcomeModeControl, outcomeScopeNote);
display(outcomeControlsRow);
const outcomeMode = Generators.input(outcomeModeControl);
const includeSuccess = outcomeMode === "all";
const outcomeSummary = summarizeOutcomes(outcomes, visibleFrameworks, ok, {includeSuccess});
const keptCount = ok.filter(Boolean).length;
outcomeScopeNote.textContent =
  keptCount === profile.problems.length
    ? `All ${keptCount.toLocaleString()} problems`
    : `Filtered to ${keptCount.toLocaleString()} of ${profile.problems.length.toLocaleString()} problems`;

const outcomeEl = document.createElement("div");
if (visibleFrameworks.length === 0) {
  const msg = document.createElement("p");
  msg.setAttribute("role", "status");
  msg.textContent = "No frameworks selected.";
  outcomeEl.append(msg);
} else if (outcomeSummary.totalMeasurements === 0) {
  const msg = document.createElement("p");
  msg.setAttribute("role", "status");
  msg.textContent = "No measurements match these tags.";
  outcomeEl.append(msg);
} else {
  outcomeEl.append(renderOutcomeLegend(outcomeSummary.outcomes));
  outcomeEl.append(
    Plot.plot({
      width,
      height: 360,
      marginBottom: 62,
      marginLeft: 54,
      x: {
        domain: outcomeSummary.frameworks,
        label: "Framework",
        tickRotate: -30
      },
      y: {
        domain: [0, 1],
        grid: true,
        label: "Fraction of results",
        tickFormat: (d) => `${Math.round(d * 100)}%`
      },
      marks: [
        Plot.barY(outcomeSummary.segments, {
          x: "framework",
          y1: "y0",
          y2: "y1",
          fill: "color",
          fillOpacity: "opacity",
          stroke: "#ffffff",
          strokeWidth: 0.75,
          title: (d) =>
            `${d.framework}\n${d.label}: ${d.pct.toFixed(1)}% (${d.count.toLocaleString()} / ${d.total.toLocaleString()})`
        }),
        Plot.tip(
          outcomeSummary.segments,
          Plot.pointer({
            x: "framework",
            y: (d) => (d.y0 + d.y1) / 2,
            title: (d) =>
              `${d.framework}\n${d.label}: ${d.pct.toFixed(1)}%\n${d.count.toLocaleString()} of ${d.total.toLocaleString()} runs`
          })
        ),
        Plot.ruleY([0])
      ]
    })
  );
}
display(outcomeEl);

Each failed run is assigned one category determined from its status and diagnostic log. Runs that go beyond the ${run.timeout ?? 180} s budget count as timeout. Other failures match the error class if possible (oom, not implemented, type error, attribute error, value error, runtime error, assertion, import error).