Skip to content

layer_numerics: add address capture, bad-value locate, allocator snap… - #267

Open
qianghan-amd wants to merge 3 commits into
ROCm:mainfrom
qianghan-amd:users/qianghan/layer-numerics-v2
Open

layer_numerics: add address capture, bad-value locate, allocator snap…#267
qianghan-amd wants to merge 3 commits into
ROCm:mainfrom
qianghan-amd:users/qianghan/layer-numerics-v2

Conversation

@qianghan-amd

Copy link
Copy Markdown
Contributor

…shot, and tensor dump

Add v2 diagnostic capabilities to the NaN logger for tracing memory-aliasing corruption to its producer buffer:

  • NANLOG_ADDR: record GPU data_ptr + storage extent per tensor (default ON, sync-free)
  • NANLOG_LOCATE: count bad rows per tensor to distinguish tile-sized late writes from numeric blowup
  • NANLOG_BAD_VALUES: record first bad element position and value (GPU-side reductions, no host sync)
  • NANLOG_ALLOC_SNAPSHOT: enable PyTorch allocator event recorder, dump on first NaN detection
  • NANLOG_DUMP_TENSOR: save full corrupted tensor to disk on first detection

Also adds LOGGER_REFERENCE.md (full technical reference) and updates README.md with streamlined run instructions.

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

…shot, and tensor dump

Add v2 diagnostic capabilities to the NaN logger for tracing
memory-aliasing corruption to its producer buffer:

- NANLOG_ADDR: record GPU data_ptr + storage extent per tensor (default ON, sync-free)
- NANLOG_LOCATE: count bad rows per tensor to distinguish tile-sized late writes from numeric blowup
- NANLOG_BAD_VALUES: record first bad element position and value (GPU-side reductions, no host sync)
- NANLOG_ALLOC_SNAPSHOT: enable PyTorch allocator event recorder, dump on first NaN detection
- NANLOG_DUMP_TENSOR: save full corrupted tensor to disk on first detection

Also adds LOGGER_REFERENCE.md (full technical reference) and updates
README.md with streamlined run instructions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@qianghan-amd
qianghan-amd force-pushed the users/qianghan/layer-numerics-v2 branch from d6f3178 to cc402e9 Compare July 1, 2026 21:36
qianghan-amd and others added 2 commits July 7, 2026 20:31
… test suite

_fwd_hook stashed a layer's output (act) before its input, so the one-shot
NANLOG_DUMP_TENSOR captured the output instead of the corrupt input -- the
aliased 8 MiB block that is the whole point of the emb_proj aliasing workflow.
Stash the input before the output so the input wins when both go bad in the same
step; layers where only the output is bad still dump the output, so nothing is
lost. Also correct the NANLOG_DUMP_TENSOR docstring (one-shot, input-preferred).

Add test_logger.py: 215-assertion pre-delivery suite covering all channels,
BAD_VALUES, ADDR, LOCATE, ALLOC_SNAPSHOT, and DUMP_TENSOR. Test 12 asserts the
dumped tensor is the input ([256,8192]), which is the regression guard for this
fix.

Co-authored-by: Cursor <cursoragent@cursor.com>
A customer-facing guide that stages the diagnostic runs from least to most
perturbation, one new capability per round (BAD_VALUES + wide watch scope ->
ALLOC_SNAPSHOT -> DUMP_TENSOR), so a timing-sensitive aliasing NaN is confirmed
and its donor named before the heavier, race-perturbing flags are enabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant