[AMD][Bugfix] Fix vattn_asm HIP error 709 under CUDA graph capture on ROCm 10 (#39513)
Co-authored-by: jacky.cheng <yichiche@amd.com>
This commit is contained in:
@@ -165,6 +165,39 @@ class TestVattnSegPlan(CustomTestCase):
|
||||
self.assertLessEqual(e_plan, max(2 * e_leg, 0.02))
|
||||
torch.cuda.empty_cache()
|
||||
|
||||
def test_launches_on_a_side_stream_and_under_graph_capture(self):
|
||||
# ROCm 10 images carry two libamdhip64 of the same SONAME (torch loads
|
||||
# _rocm_sdk_core, LD_LIBRARY_PATH points at _rocm_sdk_devel). Binding
|
||||
# the wrong one still loads the module and still launches on the default
|
||||
# stream, so only a torch stream catches it: every launch there fails
|
||||
# with hipErrorContextIsDestroyed (709). Decode captures graphs, so this
|
||||
# is the path serving actually takes.
|
||||
V = self.V
|
||||
lens, qlens, hq, hkv = [4096, 3777], [4, 2], 16, 1
|
||||
k, v, bt, q, cu_q, seq_lens, kd, vd = make(lens, qlens, hq, hkv)
|
||||
scale = 1.0 / math.sqrt(HD)
|
||||
r = ref(k, v, bt, q, cu_q, seq_lens, kd, vd, hq, hkv)
|
||||
|
||||
stream = torch.cuda.Stream()
|
||||
with torch.cuda.stream(stream):
|
||||
eager = V.mtp_verify_attn_fwd_asm(
|
||||
q, k, v, bt, seq_lens, cu_q, kd, vd, scale
|
||||
)
|
||||
stream.synchronize()
|
||||
self.assertLess((eager.float() - r).abs().max().item(), 0.05)
|
||||
|
||||
out = torch.empty_like(eager)
|
||||
g = torch.cuda.CUDAGraph()
|
||||
V.reset_seg_plan_cache()
|
||||
with torch.cuda.graph(g, stream=stream):
|
||||
V.mtp_verify_attn_fwd_asm(
|
||||
q, k, v, bt, seq_lens, cu_q, kd, vd, scale, out=out
|
||||
)
|
||||
out.zero_()
|
||||
g.replay()
|
||||
torch.cuda.synchronize()
|
||||
self.assertLess((out.float() - r).abs().max().item(), 0.05)
|
||||
|
||||
def test_plan_cache_per_forward(self):
|
||||
V = self.V
|
||||
lens, qlens, hq, hkv = [248000, 60000, 9000, 500, 17, 0], [4] * 6, 16, 1
|
||||
|
||||
Reference in New Issue
Block a user