Repository navigation
[fly][gr] Unify the gr read api for both prefill and decode - #56
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Timed Total calls do not record their actual address-sensitive internal workspace allocations.
Review effort: Balanced
Findings: 1
What changed in this PR
Unifies decode and prefill behind the public gr_read API and makes performance baselines self-contained.
Changes:
- Adds cached, graph-compatible functional dispatch with optional output tensors.
- Adds frozen Torch/Triton baselines and expanded API tests.
- Reworks benchmarking to use a single startup hardware gate.
| File | Description |
|---|---|
src/pyhip/ops/gr_read/__init__.py |
Exports the unified API. |
src/pyhip/ops/gr_read/flydsl/__init__.py |
Re-exports gr_read. |
src/pyhip/ops/gr_read/flydsl/host.py |
Implements dispatch, validation, and compilation caching. |
tests/ops/gr_read/baselines.py |
Adds frozen performance baselines. |
tests/ops/gr_read/bench_gr_read_compare.py |
Updates benchmark protocols and hardware gating. |
tests/ops/gr_read/test_gr_read.py |
Adds API, graph, cache, and baseline coverage. |
tests/ops/gr_read/readme.md |
Documents the API and benchmark process. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| emit({'type': 'addresses', 'rows': rows, 'total_entry': 'gr_read', | ||
| 'total_partial': 'allocated internally for each call; P_stages is only used by stage measurements', | ||
| 'buffers': [{k: address(v) for (k, v) in (('X', c.x), ('WD_raw', c.wd), ('WU_raw', c.wu), ('WD_packed', c.pd), ('WU_packed', c.pu), ('P_stages', c.p), ('Y', c.y), ('Baseline_WD', c.baseline_wd), ('Baseline_WU', c.baseline_wu), ('Baseline_Y', c.baseline_y)) if v is not None} for c in cases]}) |
There was a problem hiding this comment.
This only affects the exported json and does not impact normal functionality. I have also updated the related tests.
| @@ -1,13 +1,12 @@ | |||
| # SPDX-License-Identifier: MIT | |||
There was a problem hiding this comment.
Could you please move this file to the folder pyhip/benchmarks/gr_read and add a readme.md in the pyhip/benchmarks/gr_read which should include the performance data and the code sample for using this ops?
We expect the following contract:
- there is a benchscirpt in
pyhip/benchmarkds/gr_readto- do the tuning(optional, if needed)
- test overall performance
- generate performance report
- there is a readme.md in
pyhip/benchmarkds/gr_readfor the end user to quickly lookup the performance data and the code snippets to do the integration - there may some test scripts in
tests/ops/gr_read/for each kernel, such asGRReadDecodeGRReadPrefilletc.(it's for the new kernel, the existing can be unchanged.)
There was a problem hiding this comment.
I have moved the perf tests and readme to pyhip/benchmarks and left the acc test (for both prefill and decode) in tests/ops/gr_read/.
The only remaining part is the auto-tuning step, which still relies on many empirically tuned values for gfx942 (80cu).

This PR makes following changes:
/opt/sglangand addstests/ops/gr_read/baselines.pywhich containes current sglang implementation (torch compile and triton kernel)rocm-smiamong multiple stages and between each batch. Becauserocm-smiutilization data has sampling lag, it is not reliable for frequent idle checks. The benchmark requires the gpu to be idle before running (gpu utilization <=5% VRAM usages <=20%). The new implementation performs idle check only once before warmup.benchmarks/gr_readTest
acc
perf