Skip to content

feat(aorlta): a rewards catalog, and a timing reward where an undecidable measurement is unscored - #615

Draft
vivekkhandelwal1 wants to merge 6 commits into
feat/aorlta-example-hip-kernelsfrom
feat/aorlta-rewards-catalog
Draft

vivekkhandelwal1 wants to merge 6 commits into
feat/aorlta-example-hip-kernelsfrom
feat/aorlta-rewards-catalog

Conversation

@vivekkhandelwal1

Copy link
Copy Markdown
Collaborator

A rewards catalog and a timing reward.

  • docs/REWARDS.md: every check adapter and reward function AORLTA ships (parse, compile, reference match, normalised match, timing), what each needs, and its states and reasons. It also says how to write your own while keeping the service's rules: a reward in [-1.55, 1.0], parts base, broke_healthy, length, and an unsettled check that is never clean.
  • aorlta.reward.timing: judges a candidate's per-launch times against a reference's, taken interleaved on one GPU. faster only past the noise floor (the larger of a minimum and the two relative MADs), not_faster only past it the other way. Noisy, within-noise, too-few or invalid samples are unscored, never clean. A settled verdict carries a measurement record.
  • rewardfn.speedup: grades a clean reward by the measured speedup, 0.75 to 1.0 when faster by the ratio and below 0.5 when measured and not.
  • The HIP example gets an optional hipk-speed profile with a ref.speedup leg (hipk.time). It uses the same design as ref.native in feat(aorlta): two worked examples (HIP kernels, Q&A), before/after eval, VALIDATION.md #613: the candidate and the reference are each compiled alone into a device code object, and a harness built from the task alone loads both, checks both outputs, times them interleaved, and writes its result to a record file. None of the candidate's host code runs, and stdout is never read.

Checked on an MI350X node with hip_kernels.py timecheck:

  • each reference against itself is not_faster at about 1.00 (vector_add, transpose, block_sum);
  • a candidate whose static initializer prints a fake 10x timing line is measured as itself (not_faster, 1.00);
  • a deliberately slow candidate is too_slow_to_measure within the default budget, and not_faster at 0.001 with a larger one;
  • a tiled transpose is 1.07x the naive reference: not_faster at the default ratio of 1.1, and clean at ratio 1.0, in two runs.

Stacked on #613. Draft.

…able measurement is unscored

docs/REWARDS.md lists the reward shapes AORLTA supports and what each needs. aorlta.reward.timing judges a candidate's
per-launch times against a reference's, taken interleaved on one GPU: faster only past the noise floor, not_faster only
past it the other way, and noisy, within-noise, too-few or invalid samples unscored, never clean. rewardfn.speedup
grades a clean reward by the measured speedup. The HIP example gets an optional hipk-speed profile with a ref.speedup
leg.
…ds-catalog

#613 now compiles a candidate alone into a device code object and reads the harness's verdict from a record file, so
the timing check is resolved onto the same design rather than linking the candidate's own object into the timing
program (where its static initializers would run and could print a timing line): hipk.time compiles the candidate
and the reference with --genco, the timing harness is built from the task alone and finds the kernel in each code
object by its mangled signature, and the adapter reads only its record file. The symbol-table checks the old design
needed are gone with it, and the timing worker leases its GPU like hipk.run's. REWARDS.md is updated to match.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 10:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Incomplete cache identities allow stale timing and reward reuse after code changes, while unresolved relative candidate paths cause valid inputs to fail compilation.

2 open issues
What changed in this PR

Adds timing-based rewards to AORLTA’s check-and-reward pipeline, extending the HIP-kernel example with an optional speedup profile.

Changes:

  • Documents available checks, reward functions, and composition rules.
  • Adds noise-aware timing judgments and speedup scoring, leaving undecidable measurements unscored.
  • Adds an isolated HIP timing harness, scoring configuration, and test coverage.
File Description
aorlta/​tests/​reward/​test_timing.py Tests timing statistics, measurement records, and reward invariants.
aorlta/​tests/​examples/​test_hip_kernels.py Tests timing outcomes, harness generation, and profile integration.
aorlta/​src/​aorlta/​reward/​timing.py Implements timing judgments and speedup grades.
aorlta/​src/​aorlta/​reward/​rewardfn/​speedup.py Wraps correctness rewards with speedup scoring.
aorlta/​src/​aorlta/​reward/​adapters/​base.py Allows measurement records on clean legs.
aorlta/​README.md Links the rewards catalog.
aorlta/​examples/​hip-kernels/​hipk-speed.yaml Defines the optional timing profile and GPU allocation.
aorlta/​examples/​hip-kernels/​hip_kernels.py Adds the timing harness, adapter, reward registration, and CLI check.
aorlta/​docs/​REWARDS.md Catalogs checks, scoring rules, and extension contracts.
aorlta/​docs/​ADAPTING.md Links reward-extension guidance to the catalog.
aorlta/​configs/​hipk-speed-score.yaml Configures a HIP-kernel scoring run with timing rewards.

Review effort: Balanced

…and the judge; timecheck resolves its paths

- hipk.time's version named the compiler and its own file only, so a changed reference/<id>.hip, or a changed
  aorlta.reward.timing, reused cached legs; both are now in it.
- timecheck passed a relative --candidate or --pool through, and the check runs hipcc from a directory of its own;
  both are resolved first.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical issues allow timed launches to skip transpose work and cached speedups to persist across GPU changes, making performance rewards unreliable.

2 open issues
2 resolved since last review

Review effort: Balanced

…ing check's version names where it measures

- A timed batch reset the buffers once, so a kernel could skip work its first launch had done (a transpose that writes
  only sentinel-valued outputs, say) and be timed as faster. Every launch now runs on buffers reset just before it,
  outside its timed interval, and is timed alone.
- A speedup is a fact about one node's GPUs: the version now carries a fingerprint of the host and the gpus setting,
  so a run resumed on another node re-measures instead of reusing cached legs (and the reward entries keyed by them).
Copilot AI balanced review requested due to automatic review settings November 13, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Timed launches are never verified, allowing a stateful kernel to pass separate correctness checks while skipping measured work and reporting a false speedup.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Verify outputs after every timed launch

aorlta/​examples/​hip-kernels/​hip_kernels.py:656

Timed launches are never verified, so a kernel with a persistent device counter can pass the separate fresh(0) checks while skipping measured work and earning a clean speedup. With the default 20 launches, computing only on calls congruent to 1 modulo 21 passes every correctness check; buffer resets do not clear device globals. Verify each measured launch's outputs and guards after its stop event and before the next reset, propagate mismatches as unsettled, and add a stateful-kernel regression.

2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 13, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Timed launches lack output validation and retain device-global state, allowing stateful kernels to skip work while passing freshness checks and reporting invalid speedups.

1 open issue

Review effort: Balanced

Comment on lines +669 to +671
" float ms = 0.0f;",
" if (hipEventElapsedTime(&ms, t0, t1) != hipSuccess) return -1.0f;",
" total += ms;",

This branch has not been deployed

No deployments
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