Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/amd-kfd-launch/bundle.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / amd-kfd-launch / bundle.py` 86 lines · 5420 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 # External notebook-test artifact packaging; not a production dependency. 4 import argparse,base64,hashlib,json,lzma,subprocess 5 from pathlib import Path 6 p=argparse.ArgumentParser() 7 p.add_argument('--gate',type=Path,required=True) 8 p.add_argument('--out',type=Path,required=True) 9 a=p.parse_args() 10 root=Path(__file__).resolve().parents[2] 11 def sha(b): return hashlib.sha256(b).hexdigest() 12 def git(tree,*args): return subprocess.check_output(['git','-C',str(tree),*args]) 13 summary=json.loads((a.gate/'summary.json').read_text()) 14 assert summary['failures']==0 15 compiler=(root/'backend/amd/kfd/launch/COMPILER').read_text().splitlines() 16 assert compiler[1].split()[0]==summary['compiler'] 17 bundle={'sources':{'launcher_head':git(root,'rev-parse','HEAD').decode().strip(),'compiler_head':compiler[0].split()[0],'compiler_sha256':summary['compiler'],'launcher_source_sha256':{str(f.relative_to(root)):sha(f.read_bytes()) for f in sorted((root/'backend/amd/kfd/launch').glob('*.om'))}},'assets':{}} 18 bundle['sources']['notebook_template_sha256']=sha((root/'tests/amd-kfd-launch/notebook.py.in').read_bytes()) 19 REFERENCE_LABEL='REFERENCE (AMD runtime loading our object, not the Omega launcher)' 20 def add(name,data,source): 21 bundle['assets'][name]={'sha256':sha(data),'xz_base85':base64.b85encode(lzma.compress(data,preset=9|lzma.PRESET_EXTREME)).decode(),'source':source} 22 binary=(a.gate/'launch-x86').read_bytes() 23 assert sha(binary)==summary['binaries']['x86'] 24 add('omega-launch',binary,{'gate':'tests/amd-kfd-launch/check.py'}) 25 vadd=(a.gate/'vadd.hsaco').read_bytes() 26 assert sha(vadd)==summary['objects']['vadd'] 27 add('vadd.hsaco',vadd,{'repository_head':bundle['sources']['launcher_head'],'producer':'backend/amd/gfx942/hsaco.om'}) 28 a.out.mkdir(parents=True,exist_ok=False) 29 for name,record in bundle['assets'].items(): 30 path=a.out/name; path.write_bytes(lzma.decompress(base64.b85decode(record['xz_base85']))) 31 if name=='omega-launch': path.chmod(0o700) 32 text=(root/'tests/amd-kfd-launch/notebook.py.in').read_text() 33 assert text.count('@BUNDLE@')==1 34 cell=text.replace('@BUNDLE@',json.dumps(bundle,separators=(',',':'))) 35 (a.out/'cell.py').write_text(cell) 36 (a.out/'bundle.json').write_text(json.dumps(bundle,indent=2)+'\n') 37 readme=f"""# launch4 notebook probe 38 39 READY for the authorized MI300X notebook queue-pointer fix run. CPU launcher gates passed; 40 actual KFD/GPU execution and the HIP comparison remain NOT_RUN. 41 42 Paste all of `cell.py` into one notebook cell. It needs x86-64 Linux, Python 3 43 standard library, executable temporary storage, permission to open `/dev/kfd`, 44 the readable gfx942 topology node and its exact DRM render device. The comparison 45 needs the installed ROCm torch package and the libamdhip64 that it loads; no torch 46 kernels are run. No package/model downloads, credentials, strace or dmesg are needed. 47 48 Download `amdserve-launch4.txt`, including on failure. CONTROLS is first, every 49 launcher stdout line is saved as it arrives, and RESULT is last. The direct vadd 50 uses its existing timeout, printed as `OMEGA diag wait_timeout_ns`, and existing 51 packet bytes. The read-pointer page now initializes the AMD CP queue tail with 52 64-bit pointer mode. The only device experiment is this corrected direct launch, 53 compared with the separately retained launch3 baseline. It reads queue properties, 54 queue pointers, signal, packet header/addresses, loaded 55 descriptor fields and first eight output words on success or timeout. Values 56 are decimal; create_queue_input_qword_N is the little-endian u64 at byte offset 57 8*N in the 88-byte ioctl input, including compiler-bound mapping addresses. 58 Returned queue ID and full doorbell offset are separate rows. 59 60 The notebook reads the child's KFD proc directory and queue/occupancy/VRAM files 61 while signal_wait runs. Missing/inaccessible files are reported, not inferred. 62 It then runs the identical vadd object and inputs once through HIP, even if Omega 63 timed out. These rows are labelled `{REFERENCE_LABEL}`. No new doorbell value, 64 extra Omega packet, alternative dispatch, other kernel, or Spark test is attempted. 65 66 Interpret observations together, not as a diagnosis: unchanged read pointer 67 with advanced write pointer may indicate CP did not consume the packet; expected 68 output with a nonzero signal may indicate execution without signal completion; 69 NaN fill means those output words were not observed written. Asynchronous reads 70 are not a coherent device-wide snapshot. HIP success alone does not establish 71 why direct dispatch failed. Host dispatch timing is not GPU event timing. 72 73 Cell bytes: {len(cell.encode())} 74 Cell sha256: {sha(cell.encode())} 75 Binary sha256: {sha(binary)} 76 Launcher source commit: {bundle['sources']['launcher_head']} 77 Compiler source commit: {bundle['sources']['compiler_head']} 78 Compiler sha256: {summary['compiler']} 79 80 `bundle.json` records every object source commit and digest. `SHA256SUMS` covers 81 every delivered file, including this README and cell.py, except itself. 82 """ 83 (a.out/'README.md').write_text(readme) 84 files=sorted(f for f in a.out.iterdir() if f.is_file()) 85 (a.out/'SHA256SUMS').write_text(''.join(sha(f.read_bytes())+' '+f.name+'\n' for f in files)) 86 print(json.dumps({'cell_bytes':len(cell.encode()),'cell_sha256':sha(cell.encode()),'binary_sha256':sha(binary),'assets':{k:v['sha256'] for k,v in bundle['assets'].items()},'device':'NOT_RUN'},sort_keys=True))