Skip to content

PR-1c: Compiler.run(target=) kwarg threading — InitialProg.target + KernelCtx.target#80

Merged
StarGazerM merged 1 commit into
design/redesign-packagefrom
feat/pr-1c-compiler-target-kwarg
May 20, 2026
Merged

PR-1c: Compiler.run(target=) kwarg threading — InitialProg.target + KernelCtx.target#80
StarGazerM merged 1 commit into
design/redesign-packagefrom
feat/pr-1c-compiler-target-kwarg

Conversation

@StarGazerM

Copy link
Copy Markdown
Collaborator

Summary

Third of 5 splits of the original PR-1. Plumbing-only — threads target: str = 'cuda' through the compile pipeline so Phase B2-2 (multi-target render dispatch) has the dispatch authority hook to wire to. Per spec § 2.3 + § 3.3.

  • Compiler.run(prog, *, pipeline, target='cuda') accepts the new kwarg; restored via try/finally (exception-safe)
  • InitialProg.target: str = 'cuda', KernelCtx.target: str = 'cuda' (both frozen dataclass field additions)
  • VerifyRenderabilityShim reads state.target instead of hardcoded 'cuda' literal
  • Default 'cuda' everywhere — preserves existing call-site behavior

Test plan

  • Full suite: 1672 passed, 7 skipped (+9 new tests, no regressions)
  • Byte-equivalence (3 suites): 532 passed, 2 skipped
  • ruff check + format (CI v0.9.10): clean
  • mypy: 147 errors in 39 files — unchanged from baseline

D10 confirmation

LowerCtx (src/srdatalog/ir/core/lower_ctx.py) already pins 5 fields including target (pre-PR-1c addition). PR-1c threads target via carrier dataclasses + a transient Compiler.active_target attr — never touches LowerCtx.

Out of scope (later splits)

  • PR-1d (CudaRenderCtx extraction — in flight, parallel)
  • PR-1e (pragma scratch flags → kwargs)
  • Phase B2-2 (actual per-target render dispatch wiring)
  • Phase B2-3 (multi-target compilation targets=[...])

🤖 Generated with Claude Code

Adds the target dispatch hook required by Phase B2 work without
changing render behavior. `Compiler.run` accepts `target='cuda'` and
exposes it on `compiler.active_target` for the duration of the call;
`InitialProg` and `KernelCtx` gain a `target: str = 'cuda'` field;
`VerifyRenderabilityShim` reads `state.target` instead of the hardcoded
literal. Defaults preserve byte-equivalence on every existing call site.

Per docs/phase_decomposition_redesign.md §2.3 (target monopolization)
and §3.3.1 (target chosen at run time). Per-target render dispatch
itself lands in Phase B2-2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StarGazerM
StarGazerM merged commit aa6c475 into design/redesign-package May 20, 2026
3 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