Skip to content

[FIX][TEST] Add device attr to FakeTensor for OOB report#302

Merged
Jokeren merged 3 commits intomainfrom
test/sanitizer-oob-fake-tensor
Mar 3, 2026
Merged

[FIX][TEST] Add device attr to FakeTensor for OOB report#302
Jokeren merged 3 commits intomainfrom
test/sanitizer-oob-fake-tensor

Conversation

@mark14wu
Copy link
Copy Markdown
Collaborator

@mark14wu mark14wu commented Mar 2, 2026

Summary

  • FakeTensor was missing a device attribute, causing the sanitizer OOB report (print_oob_record_pdb_style) to crash with AttributeError when SANITIZER_ENABLE_FAKE_TENSOR=1 (virtual memory mode) is enabled.
  • Added device = "fake_tensor" to FakeTensor.
  • Added an end-to-end test (test_oob_with_fake_tensor) that enables virtual memory mode, runs an OOB kernel, and verifies the sanitizer produces a full report without crashing.

Test plan

  • uv run pytest tests/end_to_end/test_sanitizer.py::test_oob_with_fake_tensor -x -v passes
  • CI passes all existing tests

mark14wu added 2 commits March 1, 2026 23:32
…r OOB

FakeTensor was missing a `device` attribute, causing the sanitizer OOB
report to crash with AttributeError when virtual_memory mode is enabled.
Add the attribute and an end-to-end test that verifies the full OOB
report completes without error.
@mark14wu mark14wu requested a review from Jokeren March 2, 2026 04:46
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Sanitizer Performance Benchmark

Benchmark main (min) PR (min) Change
simple_load_store 0.005s 0.005s -0.0%
gemm 0.021s 0.021s -0.4%
gemm_oob 0.021s 0.022s +0.3%
indirect_load 0.066s 0.066s +0.1%
nested_loop 0.022s 0.022s +0.3%
block_pointer_loop_advance 0.007s 0.007s +0.2%
liger_jsd 0.138s 0.137s -0.1%
flaggems_layernorm 2.598s 2.617s +0.7%
Total 2.877s 2.896s +0.7%

Iterations: 1 warmup + 40 measured

The virtual_memory/FakeTensor path does not require a real CUDA
device, so drop the explicit device arg to allow the test to run
on CPU-only CI machines.
@Jokeren
Copy link
Copy Markdown
Member

Jokeren commented Mar 2, 2026

@mark14wu
Copy link
Copy Markdown
Collaborator Author

mark14wu commented Mar 2, 2026

Can we just use pytorch's https://docs.pytorch.org/docs/stable/user_guide/torch_compiler/torch.compiler_fake_tensor.html?

Yes, I'm trying to refactor fake tensor in #303.

This test only add a string attribute to the existing fake tensor class to avoid a crash in OOB report.

@mark14wu
Copy link
Copy Markdown
Collaborator Author

mark14wu commented Mar 2, 2026

Can we just use pytorch's https://docs.pytorch.org/docs/stable/user_guide/torch_compiler/torch.compiler_fake_tensor.html?

@Jokeren BTW the current FakeTensor implementation is the same lightweight as PyTorch's Fake Tensor.

@Jokeren Jokeren merged commit 18674e2 into main Mar 3, 2026
5 of 6 checks passed
@Jokeren Jokeren deleted the test/sanitizer-oob-fake-tensor branch March 3, 2026 14:45
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