intellikit icon indicating copy to clipboard operation
intellikit copied to clipboard

Kerncap docs misdescribe kernarg metadata, Triton language detection, and validation tolerances

Open coleramos425 opened this issue 2 weeks ago • 0 comments

docs/tools/kerncap.md and kerncap/README.md describe three kerncap behaviors that don't match the code. Review on #205 caught the same mistakes in the kerncap-isolate skill, which had copied them from these docs. #205 fixes the skill; these docs still need fixing.

1. Argument layout lives in metadata.json, not dispatch.json

  • Where: docs/tools/kerncap.md:327 says capture/dispatch.json contains the "kernarg layout".
  • Actual: dispatch.json records only the total kernarg_size (src/kerncap.hip:1469). The per-argument layout is written to capture/metadata.json as kernarg_slots (src/kerncap.hip:1395, read by kerncap/reproducer.py:823).

2. Omitting --source-dir for Triton requires --language triton

  • Where: docs/tools/kerncap.md:226 says kerncap can fall back to compile-shim source snapshots when --source-dir is omitted.
  • Actual: the language is only auto-detected when source_dir is given (run_extract in kerncap/extract.py), and the compile shim that writes the snapshots is only installed when language == "triton" (kerncap/capturer.py:59). Without --language triton, extraction takes the plain HIP path and records no snapshots.

3. Tolerances don't apply to default (VA-faithful) captures

  • Where:
    • "Validate … np.allclose against captured reference": docs/tools/kerncap.md:25, kerncap/README.md:20
    • Triton --tolerance 1e-3 --rtol 1e-2 examples: docs/tools/kerncap.md:175-176, 193-194, kerncap/README.md:127-128
    • "use kerncap validate --tolerance <atol> to relax the threshold": docs/tools/kerncap.md:349
  • Actual: any capture with capture/dispatch.json (HIP, and Triton with the default HSA backend) is validated by _validate_replay() (kerncap/validator.py:144). It never receives the tolerances; _compare_replay_outputs() compares raw bytes. --tolerance/--rtol only affect legacy captures without dispatch.json, such as --triton-backend python.

Suggested fix

Update the passages above to match the code. For #3, describe validation as byte-exact by default and present tolerances as legacy-only.

coleramos425 avatar Nov 18 '26 00:11 coleramos425