Skip to content

PolyBench datasets, exact union model for imperfect nests, fuse/shift, measurement + SSRF hardening (0.3.0) - #33

Merged
cluster2600 merged 11 commits into
mainfrom
feat/polybench-sizes-union-codegen
Oct 21, 2026
Merged

cluster2600 merged 11 commits into
mainfrom
feat/polybench-sizes-union-codegen

Conversation

@cluster2600

Copy link
Copy Markdown
Owner

Follow-ups to #32: real PolyBench sizes, exact legality for the imperfect-nest solvers, executable fuse/shift, steadier measurement, and request-time SSRF protection. It also bumps the version to 0.3.0 for the release.

What changes

PolyBench datasets. MINI…EXTRALARGE are now PolyBench/C 4.2.1's exact per-kernel sizes, copied from its headers (gemm LARGE = 1000×1100×1200), instead of scale factors. A new DEFAULT class keeps each kernel's built-in size and is the default everywhere: agent, MCP, TUI and tests. 3mm, atax, bicg and fdtd-2d now use PolyBench's rectangular shapes. The two non-PolyBench extras still use scale factors.

  • bench.py/baselines.py default to LARGE, where locality matters, and gain --size, --rounds and --kernels.
  • The gemm bench schedule is now tile3d(32, 128, 64): 12.8× confirmed, against 9.8× untiled at LARGE.

Exact legality for imperfect nests. The new compilot/union.py models every statement at once and replaces the single "binding" statement per kernel:

  • each statement's domain comes from its loops, and its accesses are read from its C body;
  • the loop tree becomes a 2d+1 schedule;
  • setup scalars become 0-d arrays, and statement-declared scalars (double w = …) are expanded over their loop scope.

The scheduled code is generated by ISL, with those scalars declared in their original scope, and checked against the plain loop-tree baseline. All previous verdicts hold. It also finds three foralls the old model rejected: durbin i2, gramschmidt i2 and j.

  • Fixes run_agent.py --kernel <solver> and MCP optimize crashing on imperfect kernels (no .ek).
  • Removes the 9 dead binding specs.

fuse(L) / shift(L, c). In multi-statement and stencil kernels, a statement can run inside the previous statement's loops. The whole sequence becomes one union, with accesses read from the bodies, so every dependence between statements is checked. Examples:

  • jacobi fuses only after shift(i, 1), and parallel(i) on that fused loop is rejected;
  • 2mm fuses at i but not at j;
  • 3mm and gemver fusions that break a dependence are rejected;
  • kernels whose in-place resets can't be hoisted refuse fusion with a clear message.

Measurement.

  • Every generated program prints its OpenMP thread count.
  • busy_warning() flags a loaded host (1-minute load above half the CPUs) in bench.py, run_agent.py and MCP results.
  • COMPILOT_OMP_BIND=1 opts into pinned threads. It's off by default: on WSL2, 20+20 alternating runs showed no variance reduction (max/min 3.97× pinned vs 2.85× unpinned).

Connection guard. LLM requests connect through a guard that resolves the host once, refuses link-local addresses, and connects only to the addresses it checked. This closes DNS rebinding and redirects to the metadata endpoint; the _check_base_url check stays as the early, readable rejection. test_parallel_safety now runs at SMALL (4–7 minutes → about 40 s).

A bug the tests caught along the way

fused_nest passed loop_is_parallel the wrong key. That matched no statements, so an empty dependence set passed as "parallel". The new fusion test caught it through the checksum: jacobi-1d's fused, shifted parallel(i) raced. Fixed in 27f7739, and loop_is_parallel now refuses a loop with no statements.

Behaviour changes

  • The size classes mean PolyBench's datasets now, so callers that passed LARGE explicitly get much bigger problems. DEFAULT gives the old LARGE sizes.
  • Imperfect kernels: transforms other than parallel are reported unsupported without a legality check (it used to run against the binding statement).
  • Fusion hoists per-statement output resets ahead of the fused nest, and refuses when an earlier statement uses such an output.

Testing

  • All 19 test modules pass in Docker (clang 19, Python 3.14). test_tiramisu_parity skips itself because libtiramisu isn't built.
  • New: tests/test_union.py (loop tree, 11 fusion cases).
  • Extended: test_imperfect (ISL identity == loop-tree baseline for all 9 kernels, the two new foralls, the prompt-builder fix), test_polybench (160 kernel×dataset instances against PolyBench's tables), test_confirm (thread count, busy warning, opt-in pinning) and test_review_fixes (connection guard incl. redirect to the metadata endpoint).
  • pyflakes-clean.
  • Not verified: macOS, Tiramisu parity, live LLM runs. Timings were taken on a 16-thread WSL2 host whose load average swung between 0.3 and 10.

🤖 Generated with Claude Code

cluster2600 and others added 5 commits October 21, 2026 09:28
…, measurement and SSRF hardening

Sizes (6): MINI..EXTRALARGE are now PolyBench/C 4.2.1's own per-kernel
dataset tables (from its headers); DEFAULT, the new default everywhere,
keeps each kernel's built-in size. 3mm/atax/bicg/fdtd-2d use PolyBench's
rectangular shapes. bench.py/baselines.py default to LARGE (where tiling
pays: gemm tile3d 12.8x vs 9.8x untiled) with --size/--rounds/--kernels.

Imperfect nests (7): legality is exact over all statements via the new
compilot/union.py (domains from loops, accesses read from the C bodies,
the loop tree as a 2d+1 schedule, setup scalars as 0-d arrays, declared
scalars expanded over their loop scope), replacing the single binding
statement per kernel. Code is generated by ISL (scalars declared in their
original scope) and checked against the plain loop-tree baseline. Finds
three foralls the old model rejected (durbin i2, gramschmidt i2 and j).
Also fixes run_agent/MCP optimize crashing on imperfect kernels (no .ek).

Fusion (8): fuse(L) runs a statement inside the previous one's loops,
shift(L, c) offsets a loop; multi-statement and stencil kernels then
schedule the statement sequence as one union (accesses from the bodies),
so e.g. jacobi fuses only after shift(i, 1) and 2mm only at i.

Measurement (9): programs print their OpenMP thread count; busy_warning()
flags a loaded host (bench, run_agent, MCP); COMPILOT_OMP_BIND=1 opts into
pinned threads (off by default: no variance reduction measured on WSL2).

Hardening (10): LLM requests connect through a guard that resolves once,
refuses link-local addresses and connects to what it checked (closes DNS
rebinding and redirects to the metadata endpoint). test_parallel_safety
runs at SMALL (minutes -> seconds).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…notes

README, how-it-works, architecture and user-guide describe the dataset
classes, the union model for imperfect nests and fusion, the fuse/shift
DSL ops, thread counts / busy warnings / opt-in pinning, and the new
bench flags. The architecture page's single-binding-statement section is
replaced by the exact union model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tness

fused_nest passed loop_is_parallel the composite (depth, betas) key where
it expects the betas, so the lookup matched no statement and an empty
dependence set passed as parallel. test_union caught it through the
checksum: jacobi1d parallel(i) on the shifted, fused loop raced.
loop_is_parallel now refuses a loop with no statements.

Real PolyBench SMALL made the fine-grained wavefront tests (a fork/join
per wavefront step) exceed the run timeout: seidel2d/montecarlo/imperfect
correctness tests now use MINI with small time-step counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Version bump for the release that ships #32 (ISL codegen from the proven
schedule, real tiling, re-measured bests) and this PR (PolyBench datasets,
exact union model for imperfect nests, fuse/shift, measurement and
connection hardening). Breaking: tile2d/tile3d semantics, generate_c needs
poly= for schedules, sizes default to DEFAULT, the npm launcher no longer
reads ./.venv.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T08:13:41.675499Z db3f4a1 Manual request
🔒 Security Review ✅ Completed 2026-10-21T07:38:14.249196Z c46680a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c46680a99a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compilot/llm.py Resolved
Comment thread compilot/kernels.py Resolved
Comment thread bench.py Resolved
…rnels

- OpenAI-compatible requests (the base_url an MCP caller picks) ignore
  HTTP(S)_PROXY: through a proxy the connection guard could only vet the
  proxy, which would then resolve and fetch a link-local target for us.
  Gemini (fixed host) still honours proxies. (Codex review, P1)
- bench.py/baselines.py: unknown --kernels names are an argument error and
  an empty result says so, instead of a ZeroDivisionError. (Codex review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cluster2600

Copy link
Copy Markdown
Owner Author

@codex review

… skip

Naive baselines at PolyBench LARGE can exceed the 120 s run timeout
(floyd-warshall N=2800 did, aborting bench.py). RUN_TIMEOUT is now
configurable (COMPILOT_RUN_TIMEOUT, bench.py/baselines.py --timeout), and a
kernel whose baseline or candidate fails is reported as skipped while the
rest of the benchmark continues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0789e85d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compilot/llm.py Resolved
AWS serves IMDS over IPv6 at fd00:ec2::254 (unique-local, not link-local)
and Alibaba Cloud at 100.100.100.200; both passed the link-local checks.
llm.is_blocked_address (link-local or METADATA_ADDRESSES, also as
IPv4-mapped IPv6) now backs both the early base_url check and the
connect-time guard. (Codex review, P1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cluster2600

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 21f51fb394

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bench.py Resolved
--rounds 0 reached ab_speedup and died in statistics.median([]); argparse
now rejects non-positive values, and rerun/ab_speedup raise a clear
ValueError if called with fewer than one round. (Codex review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cluster2600

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5c7549766

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compilot/union.py Resolved
…al nest

In the fused path a statement's 2d+1 vector reflects its transforms, so
tiling can put parallel(L) deeper than the original nest; loop_members
compared against the original labels, found no statement and reported a
legal schedule as invalid. Depth is now read from the time vector
(n_loops), also for placing statement-declared scalars. (Codex review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cluster2600

Copy link
Copy Markdown
Owner Author

@codex review

Indicative numbers from the WSL2 host (load average 3.8-10): bench geomean
3.0x over 14 kernels (gemm 10.4x, 2mm 11.7x), and 1.55x over naive
auto-parallelization; floyd-warshall at N=2800 exceeds the default run
timeout and is reported as skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cluster2600
cluster2600 merged commit 362a080 into main Oct 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant