{"id":539,"date":"2025-06-24T16:34:11","date_gmt":"2025-06-24T08:34:11","guid":{"rendered":"https:\/\/189505.xyz\/?p=539"},"modified":"2025-06-24T16:44:55","modified_gmt":"2025-06-24T08:44:55","slug":"os-replace%e5%9c%a8nfs%e4%b8%8a%e4%b8%8d%e6%98%afatomic%e7%9a%84","status":"publish","type":"post","link":"https:\/\/189505.xyz\/?p=539","title":{"rendered":"os.replace\u5728nfs\u4e0a\u4e0d\u662fatomic\u7684"},"content":{"rendered":"<h1>\n\u590d\u73b0\u95ee\u9898\u7684\u65b9\u6cd5<br \/>\n<\/h1>\n<p>\u4e0b\u9762\u662f\u6838\u5fc3\u90e8\u5206\u4ee3\u7801\uff0ctest_gemm\u90e8\u5206\u548c\u76f8\u5173\u4f9d\u8d56\u7684\u4ee3\u7801\uff0c\u5728test\/test_core.py\u53ef\u4ee5\u627e\u5230<\/p>\n<pre><code>def test_gemm() -&gt; None:\n    print(&#039;Testing GEMM:&#039;)\n    for m in (64, 128, 4096):\n        for k, n in [(576, 7168), (7168, 2112), (1536, 24576), (512, 32768), (16384, 7168), (7168, 4096), (2048, 7168)]:\n            x_fp8, y_fp8, out, ref_out = construct(m, k, n)\n            deep_gemm.gemm_fp8_fp8_bf16_nt(x_fp8, y_fp8, out)\n            diff = calc_diff(out, ref_out)\n            assert diff &lt; 0.001, f&#039;{m=}, {k=}, {n=}, {diff:.5f}&#039;\n\n            # noinspection PyShadowingNames\n            def test_func():\n                deep_gemm.gemm_fp8_fp8_bf16_nt(x_fp8, y_fp8, out)\n\n            t = bench_kineto(test_func, &#039;fp8_gemm&#039;, suppress_kineto_output=True)\n            print(f&#039; &gt; Perf (m={m:5}, n={n:5}, k={k:5}): {t * 1e6:4.0f} us | &#039;\n                  f&#039;throughput: {2 * m * n * k \/ t \/ 1e12:4.0f} TFLOPS, &#039;\n                  f&#039;{(m * k + k * n + m * n * 2) \/ 1e9 \/ t:4.0f} GB\/s&#039;)\n    print()\n\ndef worker():\n    child_env = os.environ[&quot;CUDA_VISIBLE_DEVICES&quot;]\n    print(f&quot;child env:{child_env}, pid:{os.getpid()}&quot;)\n    while True:\n        test_gemm()\n\nif __name__ == &#039;__main__&#039;:\n    multiprocessing.set_start_method(&#039;spawn&#039;)  # \u8bbe\u7f6e\u542f\u52a8\u65b9\u6cd5\n    old_cuda_visible_devices = os.environ[&quot;CUDA_VISIBLE_DEVICES&quot;]\n    var_list = old_cuda_visible_devices.split(&#039;,&#039;)\n    childs = []\n    for local_env in var_list:\n        os.environ[&quot;CUDA_VISIBLE_DEVICES&quot;] = local_env\n        p = multiprocessing.Process(target=worker)\n        p.start()\n        childs.append(p)\n    for p in childs:\n        p.join()\n<\/code><\/pre>\n<p>\u5982\u679c\u8fd0\u884c<\/p>\n<pre><code>rm -rf \/tmp\/deep_gemm_like \/mnt\/yrfs\/users\/like\/dg_cache; DG_JIT_CACHE_DIR=\/mnt\/yrfs\/users\/like\/dg_cache CUDA_VISIBLE_DEVICES=&quot;0,1,2,3,4,5,6,7&quot; python3 ~\/package\/\/DeepGEMM\/temp\/n2_mp.py<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u5728\u591a\u8fdb\u7a0b\u73af\u5883\u4e0b\uff0cdeep_gemm\u8c03\u7528os.replace\u7684\u65f6\u5019\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u539f\u5b50\u64cd\u4f5c\u3002<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1aDG_JIT_CACHE_DIR\u653e\u5230\u672c\u5730\u786c\u76d8\u4e0a<\/p>\n<pre><code>export DG_JIT_CACHE_DIR=\/tmp\/deep_gemm_like<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u590d\u73b0\u95ee\u9898\u7684\u65b9\u6cd5 \u4e0b\u9762\u662f\u6838\u5fc3\u90e8\u5206\u4ee3\u7801\uff0ctest_gemm\u90e8\u5206\u548c\u76f8\u5173\u4f9d\u8d56\u7684\u4ee3\u7801\uff0c\u5728test\/test_core.p &#8230; <a title=\"os.replace\u5728nfs\u4e0a\u4e0d\u662fatomic\u7684\" class=\"read-more\" href=\"https:\/\/189505.xyz\/?p=539\" aria-label=\"More on os.replace\u5728nfs\u4e0a\u4e0d\u662fatomic\u7684\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/539"}],"collection":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=539"}],"version-history":[{"count":2,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":541,"href":"https:\/\/189505.xyz\/index.php?rest_route=\/wp\/v2\/posts\/539\/revisions\/541"}],"wp:attachment":[{"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/189505.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}