{"id":51664,"date":"2025-08-11T02:34:10","date_gmt":"2025-08-10T18:34:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51664.html"},"modified":"2025-08-11T02:34:10","modified_gmt":"2025-08-10T18:34:10","slug":"%e5%a4%9a%e6%a8%a1%e6%80%81%e5%ad%a6%e4%b9%a0%e7%b3%bb%e5%88%97%e5%9b%9b%ef%bc%89%ef%bc%9a%e6%89%8b%e5%8a%a8%e5%af%b9%e9%bd%90%e5%92%8c%e5%9d%87%e8%a1%a1%e6%89%b9%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51664.html","title":{"rendered":"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406"},"content":{"rendered":"<h3 id=\"%E5%BC%95%E8%A8%80\">\u5f15\u8a00<\/h3>\n<p>\u5728\u5f53\u4eca\u4eba\u5de5\u667a\u80fd\u9886\u57df&#xff0c;\u591a\u6a21\u6001\u5b66\u4e60\u5df2\u6210\u4e3a\u6700\u524d\u6cbf\u7684\u7814\u7a76\u65b9\u5411\u4e4b\u4e00\u3002\u4e0e\u5355\u6a21\u6001\u6a21\u578b\u76f8\u6bd4&#xff0c;\u591a\u6a21\u6001\u6a21\u578b\u80fd\u591f\u540c\u65f6\u5904\u7406\u548c\u7406\u89e3\u6765\u81ea\u4e0d\u540c\u6765\u6e90&#xff08;\u5982\u56fe\u50cf\u3001\u6587\u672c\u3001\u97f3\u9891\u7b49&#xff09;\u7684\u6570\u636e&#xff0c;\u4ece\u800c\u66f4\u63a5\u8fd1\u4eba\u7c7b\u8ba4\u77e5\u4e16\u754c\u7684\u65b9\u5f0f\u3002\u7136\u800c&#xff0c;\u8fd9\u79cd\u80fd\u529b\u7684\u63d0\u5347\u4e5f\u5e26\u6765\u4e86\u65b0\u7684\u6280\u672f\u6311\u6218&#xff0c;\u7279\u522b\u662f\u5728\u6570\u636e\u9884\u5904\u7406\u548c\u8bad\u7ec3\u7b56\u7565\u65b9\u9762\u3002\u4e0a\u4e00\u7bc7\u6211\u4eec\u8ba8\u8bba\u4e86FSDP&#xff0c;\u8fd9\u4e00\u7bc7\u8fdb\u4e00\u6b65\u8ba8\u8bba\u4e00\u4e2a\u5728\u5206\u5e03\u5f0f\u8bad\u7ec3\u4e2d\u201c\u5e38\u88ab\u5ffd\u7565\u4f46\u5f88\u91cd\u8981\u201d\u7684\u5de5\u7a0b\u7ec6\u8282&#xff1a;PyTorch \u7684 FSDP \u4e0d\u4f1a\u81ea\u52a8\u5904\u7406 padding \u6216 batch \u5bf9\u9f50\u95ee\u9898\u3002<\/p>\n<hr \/>\n<h3 id=\"%E2%9D%8C%20FSDP%20%E4%B8%8D%E5%81%9A%E4%BB%80%E4%B9%88%EF%BC%9F\">\u274c FSDP \u4e0d\u505a\u4ec0\u4e48&#xff1f;<\/h3>\n<p>FSDP&#xff08;Fully\u202fSharded\u202fData\u202fParallel&#xff09;\u4ec5\u8d1f\u8d23&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5206\u5e03\u5f0f\u8bad\u7ec3\u7ed3\u6784&#xff1a;\u6a21\u578b\u53c2\u6570\u5207\u7247&#xff08;shard&#xff09;\u3001\u68af\u5ea6\u901a\u4fe1\u3001\u4f18\u5316\u72b6\u6001\u5207\u7247<\/p>\n<\/li>\n<li>\n<p>\u63d0\u4f9b\u9ad8\u6548\u7684\u591a\u5361\u8bad\u7ec3\u652f\u6301&#xff0c;\u5305\u62ec activation checkpoint\u3001zero-redundancy optimizer \u7b49<\/p>\n<\/li>\n<\/ul>\n<p>\u5b83\u4e0d\u4f1a&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u81ea\u52a8\u586b\u5145&#xff08;padding&#xff09;\u4e0d\u540c\u957f\u5ea6\u8f93\u5165<\/p>\n<\/li>\n<li>\n<p>\u81ea\u52a8\u5bf9\u9f50 batch \u7684 sequence \u957f\u5ea6<\/p>\n<\/li>\n<li>\n<p>\u8c03\u6574\u4e0d\u540c GPU \u4e0a\u7684\u6570\u636e\u91cf\u5e73\u8861<\/p>\n<\/li>\n<li>\n<p>\u63d2\u4ef6\u751f\u6210 attention mask<\/p>\n<\/li>\n<\/ul>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u6240\u6709\u4e0e sequence \u957f\u5ea6\u5206\u5e03\u548c padding \u76f8\u5173\u7684\u95ee\u9898\u90fd\u9700\u8981\u4f60\u81ea\u5df1\u5904\u7406\u3002<\/p>\n<hr \/>\n<h3 id=\"%F0%9F%9A%A8%20%E4%BD%A0%E5%BF%85%E9%A1%BB%E8%A7%A3%E5%86%B3%E7%9A%84%E9%97%AE%E9%A2%98\">&#x1f6a8; \u4f60\u5fc5\u987b\u89e3\u51b3\u7684\u95ee\u9898<\/h3>\n<li>\n<p>\u624b\u5199 collate_fn&#xff1a;\u5b9e\u73b0 padding \u548c truncation&#xff0c;\u786e\u4fdd batch \u4e2d\u6bcf\u6761\u6837\u672c\u957f\u5ea6\u4e00\u81f4<\/p>\n<\/li>\n<li>\n<p>\u63a7\u5236\u6bcf\u4e2a device \u7684\u6837\u672c\u8d1f\u8f7d&#xff1a;\u907f\u514d\u67d0\u5757 GPU \u5904\u7406\u5927\u91cf\u8d85\u957f\u6587\u672c\u800c\u5176\u4ed6 GPU \u7a7a\u95f2&#xff0c;\u5bfc\u81f4\u901f\u5ea6\u548c\u663e\u5b58\u4e0d\u5e73\u8861<\/p>\n<\/li>\n<li>\n<p>\u751f\u6210 attention_mask&#xff1a;padding \u90e8\u5206\u4e0d\u5e94\u53c2\u4e0e attention \u8ba1\u7b97&#xff0c;\u9700\u8981 mask \u6389<\/p>\n<\/li>\n<hr \/>\n<h2 id=\"SplitModalitySampler%C2%A0\">SplitModalitySampler<\/h2>\n<p>SplitModalitySampler\u00a0\u662f\u4e00\u79cd\u7528\u4e8e\u591a\u6a21\u6001\u6570\u636e&#xff08;\u5982\u6587\u672c&#043;\u56fe\u50cf&#xff09;\u7684\u91c7\u6837\u5668&#xff0c;\u65e8\u5728\u89e3\u51b3\u00a0load balancing&#xff08;\u8d1f\u8f7d\u5747\u8861&#xff09;\u548c\u00a0\u957f\u5ea6\u76f8\u8fd1\u6837\u672c\u5206\u7ec4&#xff08;\u51cf\u5c11padding&#xff09;\u4e4b\u95f4\u7684\u77db\u76fe\u3002\u5b83\u7684\u6838\u5fc3\u601d\u60f3\u662f\u00a0\u6309\u6a21\u6001\u62c6\u5206\u6837\u672c&#xff0c;\u518d\u5206\u522b\u8fdb\u884c\u52a8\u6001\u6279\u5904\u7406&#xff08;dynamic batching&#xff09;&#xff0c;\u4ece\u800c\u517c\u987e\u6548\u7387\u548c\u5185\u5b58\u4f18\u5316\u3002<\/p>\n<hr \/>\n<h4 id=\"1.%20%E6%A0%B8%E5%BF%83%E7%9B%AE%E6%A0%87\">1. \u6838\u5fc3\u76ee\u6807<\/h4>\n<ul>\n<li>\n<p>Load Balancing: \u5728\u591a\u5361\u6216\u591a\u8fdb\u7a0b\u8bad\u7ec3\u65f6&#xff0c;\u786e\u4fdd\u6bcf\u4e2aGPU\u7684batch\u8ba1\u7b97\u91cf\u5747\u8861&#xff0c;\u907f\u514d\u67d0\u4e9b\u5361\u8d1f\u8f7d\u8fc7\u9ad8\u800c\u62d6\u6162\u6574\u4f53\u8bad\u7ec3\u3002<\/p>\n<\/li>\n<li>\n<p>\u957f\u5ea6\u76f8\u8fd1\u7684\u6837\u672c\u5206\u7ec4: \u5c06\u957f\u5ea6\u76f8\u4f3c\u7684\u6837\u672c&#xff08;\u5982\u6587\u672c\u957f\u5ea6&#xff09;\u5206\u5230\u540c\u4e00\u4e2abatch&#xff0c;\u51cf\u5c11padding\u5e26\u6765\u7684\u8ba1\u7b97\u6d6a\u8d39\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f20\u7edf\u65b9\u6cd5&#xff08;\u5982\u7eaf\u6309\u957f\u5ea6\u5206\u6876&#xff09;\u53ef\u80fd\u5bfc\u81f4\u67d0\u4e9bGPU\u5206\u5230\u592a\u591a\u957f\u6837\u672c\u800c\u8d1f\u8f7d\u4e0d\u5747&#xff0c;\u800c\u7eaf\u968f\u673a\u91c7\u6837\u5219\u53ef\u80fd\u589e\u52a0padding\u3002<\/p>\n<hr \/>\n<h4 id=\"2.%20%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86\">2. \u5de5\u4f5c\u539f\u7406<\/h4>\n<h5 id=\"(1)%20%E6%8C%89%E6%A8%A1%E6%80%81%E6%8B%86%E5%88%86%E6%A0%B7%E6%9C%AC\">(1) \u6309\u6a21\u6001\u62c6\u5206\u6837\u672c<\/h5>\n<ul>\n<li>\n<p>\u5c06\u6570\u636e\u96c6\u6309\u6a21\u6001&#xff08;\u5982\u7eaf\u6587\u672c\u3001\u6587\u672c&#043;\u56fe\u50cf\u3001\u7eaf\u56fe\u50cf\u7b49&#xff09;\u5206\u6210\u591a\u4e2a\u5b50\u96c6&#xff0c;\u56e0\u4e3a\u4e00\u822c\u5e26\u56fe\u7247\u7684\u5bf9\u8bdd\u548c\u7eaf\u6587\u672c\u7684\u5723\u8bde\u957f\u5ea6\u76f8\u5dee\u5f88\u5927\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5b50\u96c6A&#xff1a;\u4ec5\u6587\u672c&#xff08;\u65e0\u56fe\u50cf&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u5b50\u96c6B&#xff1a;\u6587\u672c&#043;\u56fe\u50cf<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>def get_modality_lengths(self, n_image_patches: int) -&gt; List[Tuple[bool, int]]:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 &#034;&#034;&#034;Get a list of modalities (unimodal \/ text-only vs. multimodal) and length of conversations per example.&#034;&#034;&#034;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 modality_lengths &#061; []<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 for example in self.examples:<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 is_multimodal &#061; &#034;image&#034; in example<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 n_words &#061; sum([len(turn[&#034;value&#034;].replace(&#034;&lt;image&gt;&#034;, &#034;&#034;).split()) for turn in example[&#034;conversations&#034;]])<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 modality_lengths.append((is_multimodal, (n_image_patches &#043; n_words) if is_multimodal else n_words))<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 return modality_lengths<br \/>\nmultimodal_indices, multimodal_lengths &#061; zip(<br \/>\n            *[(idx, length) for idx, (is_multimodal, length) in enumerate(self.modality_lengths) if is_multimodal]<br \/>\n)<\/p>\n<p># Handle Special Case &#8211;&gt; no &#034;unimodal&#034; inputs<br \/>\nunimodal_split &#061; [<br \/>\n            (idx, length) for idx, (is_multimodal, length) in enumerate(self.modality_lengths) if not is_multimodal<br \/>\n] <\/p>\n<h5 id=\"(2)%20%E5%9D%87%E8%A1%A1%E5%88%86%E9%85%8D%E6%89%B9%E6%AC%A1\">(2) \u5747\u8861\u5206\u914d\u6279\u6b21<\/h5>\n<ul>\n<li>\n<p>\u4ece\u6bcf\u4e2a\u5b50\u96c6\u7684\u6309\u9700\u91c7\u6837&#xff0c;\u786e\u4fdd&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e0d\u540cGPU\u5206\u914d\u7684batch\u603b\u8ba1\u7b97\u91cf&#xff08;\u5982\u6587\u672ctoken\u603b\u6570&#043;\u56fe\u50cf\u50cf\u7d20\u603b\u6570&#xff09;\u5747\u8861\u3002\u6bd4\u5982\u6211\u4eec\u53ef\u4ee5\u7528\u4ee5\u4e0b\u4ee3\u7801\u5c06batch sz &#061; 128\u7684\u6570\u636e\u5206\u5230\u4e24\u4e2agpu\u4e0a&#xff1a;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>    &#064;staticmethod<br \/>\n    def reindex_batch(batch_idxs: List[int], idx2lengths: List[int], n_buckets: int) -&gt; List[List[int]]:<br \/>\n        &#034;&#034;&#034;Re-indexes a batch in a way that is conducive to DistributedSampler &#043; grouping by seqlen per rank.&#034;&#034;&#034;<br \/>\n        assert len(batch_idxs) % n_buckets &#061;&#061; 0, &#034;Batch length is not divisible by &#096;num_replicas&#096;!&#034;<\/p>\n<p>        # Establish initial buckets, capacities, and max number of elements per bucket<br \/>\n        n_examples_per_bucket &#061; len(batch_idxs) \/\/ n_buckets<br \/>\n        bucket_indices &#061; [[] for _ in range(n_buckets)]<br \/>\n        bucket_lengths &#061; [0 for _ in range(n_buckets)]<\/p>\n<p>        # Note that &#096;batch_idxs&#096; is already sorted by corresponding length (in descending order)<br \/>\n        for idx in batch_idxs:<br \/>\n            shortest_bucket_idx &#061; bucket_lengths.index(min(bucket_lengths))<br \/>\n            bucket_indices[shortest_bucket_idx].append(idx)<\/p>\n<p>            # Update &#096;bucket_lengths&#096; &#8211;&gt; set length to infinity if at capacity!<br \/>\n            bucket_lengths[shortest_bucket_idx] &#043;&#061; idx2lengths[idx]<br \/>\n            if len(bucket_indices[shortest_bucket_idx]) &#061;&#061; n_examples_per_bucket:<br \/>\n                bucket_lengths[shortest_bucket_idx] &#061; float(&#034;inf&#034;)<\/p>\n<p>        return bucket_indices<br \/>\nmm_sorted_batch_idxs &#061; [sorted(b, key&#061;lambda i: multimodal_lengths[i], reverse&#061;True) for b in mm_batch_idxs]<br \/>\nmm_length_bucketed_idxs &#061; [<br \/>\n            self.reindex_batch(batch, multimodal_lengths, self.num_replicas) for batch in mm_sorted_batch_idxs<br \/>\n        ]<br \/>\n# flatten<br \/>\nmm_output_idxs &#061; [idx for batch in mm_length_bucketed_idxs for bucket in batch for idx in bucket] <\/p>\n<p>\u5206\u5b8c\u540e\u7684\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<p>Rank 0:128 125 124 121 &#8230;<\/p>\n<p>Rank 1:127 126 123 122 &#8230;<\/p>\n<p>\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u8d1f\u8f7d\u5747\u8861\u3002<\/p>\n<p>\u6700\u540e\u62c9\u5e73&#xff0c;\u53d8\u6210\u4e86:[128, 125, 124, 121, 127, 126, 123, 122].<\/p>\n<h5>(3)\u00a0\u957f\u5ea6\u76f8\u8fd1\u7684\u6837\u672c\u5206\u7ec4<\/h5>\n<ul>\n<li><span style=\"color:#494949\">Pytorch\u5c06\u4e00\u4e2abatch\u7684\u6570\u636e\u5206\u53d1\u5230\u4e0d\u540c\u7684GPU\u4e0a&#xff0c;\u9ed8\u8ba4\u662f\u6309rank\u987a\u5e8f\u53d1\u7684&#xff0c;\u8fd9\u6837\u5c31\u9020\u6210\u4e86\u5b9e\u9645\u957f\u5ea6\u76f8\u8fd1\u7684\u6837\u672c\u5e76\u672a\u5206\u5728\u4e00\u7ec4\u3002\u6bd4\u5982[100,99,2,1]&#xff1a;<\/span>\n<ul>\n<li>\n<p>Rank 0&#xff1a;100,2\u00a0\u2192 \u9700\u8981\u00a098\u00a0\u4e2apad token<\/p>\n<\/li>\n<li>\n<p>Rank 1&#xff1a;99, 1\u00a0\u2192 \u9700\u8981\u00a098\u00a0\u4e2apad token<\/p>\n<\/li>\n<li>\n<p><span style=\"color:#494949\">\u7ed3\u679c\u662f\u7ec4\u5185\u957f\u5ea6\u5dee\u522b\u8fc7\u5927&#xff0c;\u4e0d\u4ec5\u663e\u5b58\u7684\u5229\u7528\u7387\u4e0d\u9ad8&#xff0c;\u4e5f\u4f1a\u51cf\u7f13\u8bad\u7ec3\u901f\u5ea6\u3002<\/span><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5982\u679c\u662f\u5148\u6309\u6bcf\u4e2arank\u9700\u8981\u5904\u7406\u7684\u6570\u636e\u91cfreshape&#xff0c;\u518d\u91cd\u65b0\u5206\u914d&#xff1a;<\/p>\n<ul>\n<li>\n<p>Rank 0:100, 99\u2192 \u9700\u8981 1\u4e2apad token<\/p>\n<\/li>\n<li>\n<p>Rank 1: 2,1\u2192 \u9700\u8981 1\u00a0\u4e2apad token<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p># naive way: without reshape<br \/>\n# optimized way: reshape and slicing, here per_replica_batch_size &#061; 2<br \/>\nper_replica_batch_indices_t &#061; indices_t.reshape(-1, per_replica_batch_size)<br \/>\n# continuous chunk within the mini-batch<br \/>\nreplica_indices_t &#061; per_replica_batch_indices_t[self.rank :: self.num_replicas] <\/p>\n<p>\u8fd9\u91ccrank 0\u8bbe\u5907\u7531\u4e8e\u8981\u5904\u7406\u957f\u5f97\u591a\u7684\u5e8f\u5217(100 vs 2)\u800c\u8017\u65f6\u660e\u663e\u66f4\u957f&#xff0c;\u5bfc\u81f4\u8bbe\u5907\u95f4\u4e0d\u5e73\u8861\u548c\u7a7a\u95f2\u7b49\u5f85\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;\u5728\u6211\u4eec\u4e0a\u4e00\u6b65\u5148\u6309\u957f\u5ea6\u5747\u5206\u540e&#xff0c;rank 1\u4e2d\u7684\u6700\u5927\u957f\u5ea6\u5c06\u662f\u5f53\u524dbatch\u4e2d\u7b2c\u4e8c\u957f\u7684&#xff0c;\u5404\u8bbe\u5907\u95f4\u7684\u8d1f\u8f7d\u4f1a\u5f88\u5e73\u8861(128 vs 127)\u3002<\/p>\n<p>\u5efa\u8bae&#xff1a;\u628a\u6700\u957f\u7684\u6279\u6b21\u653e\u5728\u6700\u524d\u9762&#xff0c;\u8fd9\u6837\u5982\u679c\u4f1a\u51fa\u73b0OOM&#xff0c;\u5c31\u80fd\u5feb\u901f\u5931\u8d25\u3002<\/p>\n<h5>&#x1f3b2; \u4ecd\u7136\u8db3\u591f\u968f\u673a<\/h5>\n<p>\u56e0\u4e3a\u5212\u5206batch\u4e4b\u524d\u4f1a\u5148\u968f\u673a\u6253\u4e71id&#xff0c;batch\u4e4b\u95f4\u8fd8\u662f\u4f1a\u6709\u4e00\u5b9a\u7684\u968f\u673a\u6027\u3002\u80fd\u4fdd\u8bc1\u6bcf\u4e2abatch\u7684\u6570\u636e\u91cf\u5927\u81f4\u5dee\u4e0d\u591a\u3002<\/p>\n<hr \/>\n<h4 id=\"3.%20%E4%BC%98%E5%8A%BF\">3. \u4f18\u52bf<\/h4>\n<ul>\n<li>\n<p>\u51cf\u5c11Padding&#xff1a;\u540c\u4e00batch\u5185\u6837\u672c\u957f\u5ea6\u76f8\u8fd1&#xff0c;\u663e\u5b58\u5229\u7528\u7387\u9ad8\u3002<\/p>\n<\/li>\n<li>\n<p>\u8d1f\u8f7d\u5747\u8861&#xff1a;\u901a\u8fc7\u62c6\u5206\u6a21\u6001\u548c\u52a8\u6001\u8c03\u5ea6&#xff0c;\u5e73\u8861\u591aGPU\u7684\u8ba1\u7b97\u91cf\u3002<\/p>\n<\/li>\n<li>\n<p>\u7075\u6d3b\u6027&#xff1a;\u652f\u6301\u6df7\u5408\u6a21\u6001&#xff08;\u5982\u90e8\u5206\u6837\u672c\u6709\u6587\u672c\u65e0\u56fe\u50cf&#xff09;<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>&#x1f4da; \u53c2\u8003\u6587\u732e<\/p>\n<li>\n<p>LLaVA Trainer\u00a0 \u89c6\u89c9-\u8bed\u8a00\u5bf9\u9f50\u4e0e\u6307\u4ee4\u5fae\u8c03\u8bad\u7ec3\u903b\u8f91\u7684\u6838\u5fc3\u5b9e\u73b0<\/p>\n<\/li>\n<li>\n<p>HuggingFace Transformers &#8211; Trainer Utilities \u9ad8\u6548\u8bad\u7ec3\u4e0e\u5206\u5e03\u5f0f\u6279\u5904\u7406\u7684PyTorch\u6838\u5fc3\u5de5\u5177\u96c6<\/p>\n<\/li>\n<li>\n<p>OpenVLA &#8211; Batching Utilities \u591a\u6a21\u6001token\u5bf9\u9f50\u4efb\u52a1\u4e2d\u4f7f\u7528\u7684\u5b9a\u5236\u5316\u6279\u5904\u7406\u903b\u8f91<\/p>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb981\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u63a2\u8ba8\u4e86\u591a\u6a21\u6001\u5b66\u4e60\u4e2d\u7684\u5206\u5e03\u5f0f\u8bad\u7ec3\u6311\u6218\uff0c\u91cd\u70b9\u5206\u6790\u4e86PyTorch FSDP\u6846\u67b6\u5728\u6570\u636e\u5904\u7406\u65b9\u9762\u7684\u5c40\u9650\u6027\u3002FSDP\u867d\u652f\u6301\u53c2\u6570\u5207\u7247\u548c\u68af\u5ea6\u901a\u4fe1\uff0c\u4f46\u4e0d\u81ea\u52a8\u5904\u7406padding\u3001batch\u5bf9\u9f50\u7b49\u95ee\u9898\u3002\u4e3a\u6b64\u63d0\u51faSplitModalitySampler\u89e3\u51b3\u65b9\u6848\uff0c\u901a\u8fc7\u6309\u6a21\u6001\u62c6\u5206\u6837\u672c\u3001\u52a8\u6001\u6279\u5904\u7406\u548c\u957f\u5ea6\u76f8\u8fd1\u5206\u7ec4\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u548c\u663e\u5b58\u4f18\u5316\u3002\u8be5\u65b9\u6cd5\u80fd\u6709\u6548\u51cf\u5c11padding\u6d6a\u8d39\uff0c\u5e73\u8861\u591aGPU\u8ba1\u7b97\u91cf\uff0c\u9002\u7528\u4e8e\u6df7\u5408\u6a21\u6001\u6570\u636e\u8bad\u7ec3\uff0c\u4e3a\u591a\u6a21\u6001\u6a21\u578b\u7684\u9ad8\u6548\u8bad\u7ec3\u63d0\u4f9b\u4e86\u5b9e\u7528\u65b9\u6848\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50,5123,86],"topic":[],"class_list":["post-51664","post","type-post","status-publish","format-standard","hentry","category-server","tag-50","tag-5123","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/51664.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb981\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u63a2\u8ba8\u4e86\u591a\u6a21\u6001\u5b66\u4e60\u4e2d\u7684\u5206\u5e03\u5f0f\u8bad\u7ec3\u6311\u6218\uff0c\u91cd\u70b9\u5206\u6790\u4e86PyTorch FSDP\u6846\u67b6\u5728\u6570\u636e\u5904\u7406\u65b9\u9762\u7684\u5c40\u9650\u6027\u3002FSDP\u867d\u652f\u6301\u53c2\u6570\u5207\u7247\u548c\u68af\u5ea6\u901a\u4fe1\uff0c\u4f46\u4e0d\u81ea\u52a8\u5904\u7406padding\u3001batch\u5bf9\u9f50\u7b49\u95ee\u9898\u3002\u4e3a\u6b64\u63d0\u51faSplitModalitySampler\u89e3\u51b3\u65b9\u6848\uff0c\u901a\u8fc7\u6309\u6a21\u6001\u62c6\u5206\u6837\u672c\u3001\u52a8\u6001\u6279\u5904\u7406\u548c\u957f\u5ea6\u76f8\u8fd1\u5206\u7ec4\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u548c\u663e\u5b58\u4f18\u5316\u3002\u8be5\u65b9\u6cd5\u80fd\u6709\u6548\u51cf\u5c11padding\u6d6a\u8d39\uff0c\u5e73\u8861\u591aGPU\u8ba1\u7b97\u91cf\uff0c\u9002\u7528\u4e8e\u6df7\u5408\u6a21\u6001\u6570\u636e\u8bad\u7ec3\uff0c\u4e3a\u591a\u6a21\u6001\u6a21\u578b\u7684\u9ad8\u6548\u8bad\u7ec3\u63d0\u4f9b\u4e86\u5b9e\u7528\u65b9\u6848\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51664.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T18:34:10+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51664.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51664.html\",\"name\":\"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T18:34:10+00:00\",\"dateModified\":\"2025-08-10T18:34:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51664.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51664.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51664.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/51664.html","og_locale":"zh_CN","og_type":"article","og_title":"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb981\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u6458\u8981\uff1a\u672c\u6587\u63a2\u8ba8\u4e86\u591a\u6a21\u6001\u5b66\u4e60\u4e2d\u7684\u5206\u5e03\u5f0f\u8bad\u7ec3\u6311\u6218\uff0c\u91cd\u70b9\u5206\u6790\u4e86PyTorch FSDP\u6846\u67b6\u5728\u6570\u636e\u5904\u7406\u65b9\u9762\u7684\u5c40\u9650\u6027\u3002FSDP\u867d\u652f\u6301\u53c2\u6570\u5207\u7247\u548c\u68af\u5ea6\u901a\u4fe1\uff0c\u4f46\u4e0d\u81ea\u52a8\u5904\u7406padding\u3001batch\u5bf9\u9f50\u7b49\u95ee\u9898\u3002\u4e3a\u6b64\u63d0\u51faSplitModalitySampler\u89e3\u51b3\u65b9\u6848\uff0c\u901a\u8fc7\u6309\u6a21\u6001\u62c6\u5206\u6837\u672c\u3001\u52a8\u6001\u6279\u5904\u7406\u548c\u957f\u5ea6\u76f8\u8fd1\u5206\u7ec4\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u548c\u663e\u5b58\u4f18\u5316\u3002\u8be5\u65b9\u6cd5\u80fd\u6709\u6548\u51cf\u5c11padding\u6d6a\u8d39\uff0c\u5e73\u8861\u591aGPU\u8ba1\u7b97\u91cf\uff0c\u9002\u7528\u4e8e\u6df7\u5408\u6a21\u6001\u6570\u636e\u8bad\u7ec3\uff0c\u4e3a\u591a\u6a21\u6001\u6a21\u578b\u7684\u9ad8\u6548\u8bad\u7ec3\u63d0\u4f9b\u4e86\u5b9e\u7528\u65b9\u6848\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/51664.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T18:34:10+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51664.html","url":"https:\/\/www.wsisp.com\/helps\/51664.html","name":"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T18:34:10+00:00","dateModified":"2025-08-10T18:34:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51664.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51664.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51664.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u591a\u6a21\u6001\u5b66\u4e60\u7cfb\u5217(\u56db\uff09\uff1a\u624b\u52a8\u5bf9\u9f50\u548c\u5747\u8861\u6279\u5904\u7406"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=51664"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51664\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51664"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}