feat(hip2hip): inject generic task contract at framework level#38
Merged
Merged
Conversation
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>
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/*)torch2hipcuda2hipinstruction2tritonrepositoryThe injection sites in both
src/prompt_builder.pyandagents/geak_v3/launch_agent.pyare gated by anif task_type_name == 'hip2hip':check; nothing else in either file moves.Other things this PR does not touch:
config.yamlmodified).default_cheatsheet.yaml, the architecture cheatsheets, or the GPU arch-precheck directive.What changes
A new
### Task Contract (Generic)section is rendered into the agent prompt for everytask_type == 'hip2hip'task. The contract enumerates:target_kernel_functionsfield so the agent sees exactly which symbols are part of the contract.extern "C"shims.compile_command/correctness_command/performance_commandmust succeed against the modified source with no edits to the test runner and no extra build flags.__shared__/ dynamic LDS allocations are introduced.The contract is injected from two places, mirroring the section ordering used by each prompt path:
src/prompt_builder.py::prompt_builder— regular agents. Inserted right after the### Source Codesection.agents/geak_v3/launch_agent.py— GEAK-v3 (usessimple_prompt_builder, bypasses the regular path). Mirrors the cheatsheet injection added in Enable RDNA4 (gfx1201) HIP support: arch cheatsheets, prompt builder, preprocessing #35.Why framework-level (not per-task
prompt.instructions)Across the 36 current hip2hip configs:
gpumode/*already have a generic role-preamble inprompt.instructions(no contract bullets).others/*haveinstructions: nullandcheatsheet: 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
src/prompt_builder.py::prompt_builderpath verified.agents/geak_v3/launch_agent.pypath verified (logsincl. hip2hip contractwhen fired).hip2hiptask confirms the agent receives the contract intask_prompt.md.task_prompt.mdis byte-identical.