Skip to content

feat(hip2hip): inject generic task contract at framework level#38

Merged
irvineoy merged 1 commit into
geak_benchmarkfrom
feature/hip2hip-framework-constraints
May 8, 2026
Merged

feat(hip2hip): inject generic task contract at framework level#38
irvineoy merged 1 commit into
geak_benchmarkfrom
feature/hip2hip-framework-constraints

Conversation

@mehdi-saeedi
Copy link
Copy Markdown
Collaborator

@mehdi-saeedi mehdi-saeedi commented May 7, 2026

Summary

Follow-up to #35 (review thread). @irvineoy asked that the four generic task constraints — preserve kernel names/signatures, keep launch/config interface compatible, keep the build/test interface intact, handle shared-memory launch sizing — survive the cleanup of the MI300X-specific prompt that previously lived in tasks/hip2hip/others/points_in_boxes/config.yaml. Per the agreed plan, this PR adds them at the framework level so every hip2hip task gets the same contract, with no per-task YAML duplication.

No-touch guarantee

This PR is strictly additive for task_type == 'hip2hip' only. The following task types are untouched by this change — they render the exact same prompt before and after:

  • triton2triton (incl. rocmbench/*, geak_eval/*, repository/rocprim/*)
  • torch2hip
  • cuda2hip
  • instruction2triton
  • repository

The injection sites in both src/prompt_builder.py and agents/geak_v3/launch_agent.py are gated by an if task_type_name == 'hip2hip': check; nothing else in either file moves.

Other things this PR does not touch:

  • No task YAML edits (no config.yaml modified).
  • No new dependencies.
  • No changes to evaluator, scorer, task discovery, runner, or worktree handling.
  • No changes to default_cheatsheet.yaml, the architecture cheatsheets, or the GPU arch-precheck directive.
  • The cheatsheet injection added in Enable RDNA4 (gfx1201) HIP support: arch cheatsheets, prompt builder, preprocessing #35 is preserved verbatim — the contract is appended alongside it, not in place of it.

What changes

A new ### Task Contract (Generic) section is rendered into the agent prompt for every task_type == 'hip2hip' task. The contract enumerates:

  1. Preserve kernel function names and signatures — listed by name from the task's own target_kernel_functions field so the agent sees exactly which symbols are part of the contract.
  2. Keep the launch / configuration interface compatible — grid/block dims, stream usage, host-side launch helpers, Python bindings, extern "C" shims.
  3. Output must remain directly compilable and runnable — the task's existing compile_command / correctness_command / performance_command must succeed against the modified source with no edits to the test runner and no extra build flags.
  4. Handle shared-memory launch sizing correctly when __shared__ / dynamic LDS allocations are introduced.

The contract is injected from two places, mirroring the section ordering used by each prompt path:

Why framework-level (not per-task prompt.instructions)

Across the 36 current hip2hip configs:

  • 24 gpumode/* already have a generic role-preamble in prompt.instructions (no contract bullets).
  • 12 others/* have instructions: null and cheatsheet: null.

Adding the contract per-config would require touching 36 YAMLs and inevitably drift over time. Hosting it in one function keeps the contract in lockstep across tasks, single-source-of-truth, and architecture-neutral by construction.

Diffstat

```text
agents/geak_v3/launch_agent.py | +17 -2
src/prompt_builder.py | +11 -1
src/prompts/task_type.py | +66
3 files, +94 / -3
```

Test plan

  • All 36 hip2hip configs render with the contract present and the correct kernel name(s) listed.
  • Sampled triton2triton configs (5/5) do NOT receive the contract (correctly scoped).
  • Regular src/prompt_builder.py::prompt_builder path verified.
  • GEAK-v3 agents/geak_v3/launch_agent.py path verified (logs incl. hip2hip contract when fired).
  • End-to-end run on a representative hip2hip task confirms the agent receives the contract in task_prompt.md.
  • Spot-check that an agent attempting to rename a target kernel function sees the contract section in its initial prompt.
  • Spot-check a triton2triton run pre/post this PR — task_prompt.md is byte-identical.

Adds a uniform Task Contract section to every hip2hip task prompt with
the four constraints raised in the PR #35 review:
  1. Preserve kernel function names and signatures (named per-task from
     `target_kernel_functions` so the agent sees exactly which symbols
     are part of the contract).
  2. Keep the launch / configuration interface compatible (grid/block
     dims, stream usage, host-side launch helpers / Python bindings).
  3. Output must remain directly compilable and runnable with the
     existing `compile_command` / `correctness_command` /
     `performance_command` — no edits to the test runner.
  4. Handle shared-memory launch sizing correctly when `__shared__` /
     dynamic LDS allocations are introduced.

Hosts the contract in `src/prompts/task_type.py::hip2hip_task_contract`
and injects it from `src/prompt_builder.py` (regular path) and
`agents/geak_v3/launch_agent.py` (GEAK-v3 simple_prompt_builder path,
mirroring the cheatsheet injection added in PR #35) so the contract
reaches every agent uniformly.

Why framework-level (not per-task `prompt.instructions`):
  - Applies uniformly to all 36 current hip2hip configs (24 gpumode/*
    with populated `instructions` + 12 others/* with `instructions:
    null`) without per-task duplication or drift.
  - Single source of truth: future edits update one function, not 36
    YAMLs.
  - Architecture-neutral by construction (no MI300X-specific hardware
    text, which was the original problem in
    `tasks/hip2hip/others/points_in_boxes/config.yaml` that PR #35
    cleaned up).

Scope:
  - Only `task_type == 'hip2hip'`. `triton2triton`, `torch2hip`,
    `cuda2hip`, `repository`, `instruction2triton` unchanged.
  - No task YAML edits.
  - No new dependencies.

Verification:
  - All 36 hip2hip configs render with the contract present and the
    correct kernel name(s) listed.
  - 5/5 sampled triton2triton configs do NOT receive the contract
    (correctly scoped).
  - Both injection paths exercised (regular `prompt_builder` and
    GEAK-v3 `launch_agent`).

Follow-up to PR #35 review thread (irvineoy's request).

Co-authored-by: Cursor <cursoragent@cursor.com>
@irvineoy
Copy link
Copy Markdown
Collaborator

irvineoy commented May 8, 2026

Thanks!

@irvineoy irvineoy merged commit 0d3fc5e into geak_benchmark May 8, 2026
@mehdi-saeedi mehdi-saeedi deleted the feature/hip2hip-framework-constraints branch May 8, 2026 14:24
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.

2 participants