GPT-5.6 Sol · Training

T03 · Packed DP2

Valid

Qwen3-4B CodeOpt packed DP2 training 2dev · Implementation Optimization

1.28×PERFORMANCE RATIO
148TOOL EVENTS
2TEXT PATCHES
0BINARY NAMES

01 / PROCESS MAP

Tool activity

Each row shows one agent’s tool events in its own recorded order. Colors show broad activities; bar widths do not represent duration.

Main agentGPT-5.6 Sol · 148 visible calls

InspectEditValidateExecuteBuildProfileRollbackOther
92Inspect
13Edit
24Validate
9Execute
10Other

02 / EVENT SEQUENCE

Event timeline

Requests are grouped by agent, activity and topic. Delegations open into child branches. Summaries describe visible requests; tool errors and missing responses are flagged. A recorded response does not establish command success or a performance improvement.

Show event timelineHide event timeline110 groups · 148 calls

Scroll within this panel to view all events. Command sketches retain familiar programs and options. Values become <val> or <n>; paths, addresses and script bodies are hidden as <path>, <url> and <script>.

Main agent

  1. Inspect · Task requirements

    Requested workspace inspection, environment setup or inspection and file and log inspection related to task requirements.

    2 calls · #0001–#0002

    pwdprintenv <vars>sed -n <val> <path>rg --files <path> <path> <path> <path> <path>sortgit -C <path> <val> --short
  2. Inspect · Checkpoints & weight state

    Requested file and log inspection related to checkpoints & weight state.

    1 call · #0003–#0003

    wc -l <path> <path> <path> <path> <path> <path> <path>
  3. Execute · Checkpoints & weight state

    Requested file and log inspection related to checkpoints & weight state.

    1 call · #0004–#0004

    sed -n <val> <path><command> <args>
  4. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0005–#0005

    bash <script>
  5. Inspect · Checkpoints & weight state

    Requested source searches related to checkpoints & weight state.

    1 call · #0006–#0006

    rg -n <val> <path>
  6. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0007–#0007

    sed -n <val> <path>
  7. Validate · Benchmark & validation setup

    Requested workspace inspection, file and log inspection and script or workload execution related to benchmark & validation setup.

    3 calls · #0008–#0010

    ls -l -h <val><command> <args>tail -n <n> <val>bash <script>cp <path> <path>sha256sum <path>
  8. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    6 calls · #0011–#0016

    rg -n <val> <path> <path> <path> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> <path> -g <path>rg -n <val> <path> <path>rg -n <val> <path>
  9. Inspect · Device memory

    Requested source searches and file and log inspection related to device memory.

    1 call · #0017–#0017

    rg -n <val> <path>tail -n <n>
  10. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    2 calls · #0018–#0019

    rg -n <val> <path> <path> <path>head -n <n>sed -n <val> <path>
  11. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0020–#0020

    sed -n <val> <path>
  12. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    2 calls · #0021–#0022

    rg -n <val> <val> --glob <path> --glob <path>rg -n <val> <path> <path> <path>head -n <n>rg -n <val> <path> <path> <path> -g <path>sed -n <val> <path>
  13. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    4 calls · #0023–#0026

    sed -n <val> <path>rg -n <val> <path>rg -n <val> <path> <path>rg -n <val> <path> <path> -g <path>head -n <n>
  14. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0027–#0027

    sed -n <val> <path>
  15. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    2 calls · #0028–#0029

    sed -n <val> <path>sed -n <val> <path> <n> > <path>truerg -n <val> <path> -g <path>head -n <n>
  16. Execute · Benchmark & validation setup

    Requested workspace inspection, source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0030–#0030

    ls -l -h <path> <n> > <path>true<command> <args>echo <val>rg <path> <val>tail -n <n>
  17. Other · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0031–#0031

    bash <script>
  18. Inspect · Benchmark & validation setup

    Requested file and log inspection and source searches related to benchmark & validation setup.

    1 call · #0032–#0032

    tail -n <n> <path>rg -n <val> <path>tail -n <n>
  19. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    2 calls · #0033–#0034

    sed -n <val> <path>rg -n <val> <path> <path> -g <path>head -n <n>
  20. Execute · Benchmark & validation setup

    Requested workspace file updates and repository inspection related to benchmark & validation setup.

    1 call · #0035–#0035

    cp <path> <path>git -C <path> <val> --short
  21. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0036–#0036

    Apply patch <patch>
  22. Inspect · Attention kernels

    Requested script or workload execution, source searches and file and log inspection related to attention kernels.

    2 calls · #0037–#0038

    python -m <module> <script>rg --files <val>rg <val>head -n <n>rg --filesrg <path>
  23. Validate · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0039–#0039

    <command> <args>echo <val>tail -n <n> <val>
  24. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0040–#0040

    rg <path> <path>tail -n <n>
  25. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0041–#0041

    bash <script>
  26. Inspect · Optimizer & gradients

    Requested source searches and file and log inspection related to optimizer & gradients.

    1 call · #0042–#0042

    rg -n <val> <path> <path> <path>head -n <n>
  27. Inspect · Parallelism & communication

    Requested file and log inspection related to parallelism & communication.

    1 call · #0043–#0043

    sed -n <val> <path>
  28. Validate · Benchmark & validation setup

    Requested workspace file updates and repository inspection related to benchmark & validation setup.

    1 call · #0044–#0044

    cp <path> <path>git -C <path> <val> --check
  29. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0045–#0045

    Apply patch <patch>
  30. Other · Source & workspace

    Requested script or workload execution and repository inspection related to source & workspace.

    1 call · #0046–#0046

    python -m <module> <script>git -C <path> <val> --check
  31. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    1 call · #0047–#0047

    rg -n <path> <path> <path>tail -n <n>tail -n <n> <path>
  32. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0048–#0048

    bash <script>
  33. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0049–#0049

    Apply patch <patch>
  34. Other · Source & workspace

    Requested script or workload execution and repository inspection related to source & workspace.

    1 call · #0050–#0050

    python -m <module> <script>git -C <path> <val> --check
  35. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    2 calls · #0051–#0052

    rg -n <path> <path> <path>tail -n <n>tail -n <n> <path>
  36. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0053–#0053

    bash <script>
  37. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    1 call · #0054–#0054

    sed -n <val> <path>rg -n <val> <path> -g <val>head -n <n>
  38. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0055–#0055

    sed -n <val> <path>rg -n <val> <path> <path> <path>
  39. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0056–#0056

    rg -n <val> <path>head -n <n>sed -n <val> <path>
  40. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    2 calls · #0057–#0058

    sed -n <val> <path>rg -n <val> <path>
  41. Inspect · Optimizer & gradients

    Requested source searches and file and log inspection related to optimizer & gradients.

    1 call · #0059–#0059

    rg -n <val> <path>tail -n <n>
  42. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    1 call · #0060–#0060

    rg -n <val> <path>sed -n <val> <path>
  43. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    3 calls · #0061–#0063

    sed -n <val> <path>rg -n <val> <path>head -n <n>rg -n <val> <path> <path>
  44. Execute · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0064–#0064

    <command> <args>echo <val>rg <path> <val>tail -n <n>
  45. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0065–#0065

    rg <path> <path>sed -E <path>
  46. Execute · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0066–#0066

    <command> <args>rg <path> <val>tail -n <n>
  47. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0067–#0067

    rg <path> <path>sed -E <path>
  48. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0068–#0068

    python - <script>
  49. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0069–#0069

    rg <path> <path>tail -n <n>
  50. Validate · Benchmark & validation setup

    Requested workspace file updates and script or workload execution related to benchmark & validation setup.

    1 call · #0070–#0070

    cp <path> <path>bash <script>
  51. Execute · Benchmark & validation setup

    Requested workspace file updates related to benchmark & validation setup.

    1 call · #0071–#0071

    cp <path> <path>
  52. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0072–#0072

    Apply patch <patch>
  53. Inspect · Parallelism & communication

    Requested source searches and file and log inspection related to parallelism & communication.

    1 call · #0073–#0073

    rg -n <path> <path> <path>tail -n <n>
  54. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0074–#0074

    python -m <module> <script>bash <script>
  55. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0075–#0075

    Apply patch <patch>
  56. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0076–#0076

    sed -n <val> <path>
  57. Edit · Attention kernels

    Requested code edits related to attention kernels.

    3 calls · #0077–#0079

    Apply patch <patch>
  58. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0080–#0080

    rg -n <path> <path> <path>tail -n <n>tail -n <n> <path>
  59. Validate · Attention kernels

    Requested script or workload execution and repository inspection related to attention kernels.

    1 call · #0081–#0081

    python -m <module> <script> <script>git diff --checkbash <script>
  60. Edit · Parallelism & communication

    Requested code edits related to parallelism & communication.

    1 call · #0082–#0082

    Apply patch <patch>
  61. Edit · Source & workspace

    Requested code edits related to source & workspace.

    2 calls · #0083–#0084

    Apply patch <patch>
  62. Inspect · Parallelism & communication

    Requested script or workload execution, source searches and file and log inspection related to parallelism & communication.

    1 call · #0085–#0085

    python -m <module> <script> <script> <script>rg --files <path> <n> > <path>rg <val>head -n <n>
  63. Inspect · Source & workspace

    Requested source searches and file and log inspection related to source & workspace.

    1 call · #0086–#0086

    rg --files <path>rg <path>head -n <n>
  64. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0087–#0087

    rg -n <path> <path> <path>tail -n <n>
  65. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0088–#0088

    bash <script>
  66. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    2 calls · #0089–#0090

    sed -n <val> <path>rg -n <val> <path>head -n <n>
  67. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0091–#0091

    Apply patch <patch>
  68. Validate · Benchmark & validation setup

    Requested source searches, file and log inspection and workspace inspection related to benchmark & validation setup.

    3 calls · #0092–#0094

    rg -n <path> <path> <path>tail -n <n>ls -l <path> <n> > <path>truels -l -h <path>tail -n <n> <path> <n> > <path>
    3 more command sketches
    python -m <module> <script>git -C <path> <val> --checkbash <script>
  69. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0095–#0095

    sed -n <val> <path>
  70. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0096–#0096

    Apply patch <patch>
  71. Validate · Benchmark & validation setup

    Requested workspace inspection, source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0097–#0097

    ls -l -h <path> <n> > <path>true<command> <args>echo <val>rg <path> <val>tail -n <n>
  72. Validate · Checkpoints & weight state

    Requested source searches, file and log inspection and workspace inspection related to checkpoints & weight state.

    3 calls · #0098–#0100

    rg <path> <path> <path>tail -n <n>du <flag> <args>truefind <path> -type <val> -maxdepth <n> <flag> <args>rg <val> <path> <path>
    3 more command sketches
    ps <flag> <args>rg <val>rg -v <val>
  73. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0101–#0101

    tail -n <n> <path>
  74. Inspect · Checkpoints & weight state

    Requested workspace inspection, file and log inspection and runtime inspection related to checkpoints & weight state.

    4 calls · #0102–#0105

    find <path> -maxdepth <n> <flag> <args>tail -n <n>df -h <val>free -hrg -n <val> <path> <path>head -n <n>
    6 more command sketches
    rg -n <val> <path>sed -n <val> <path><command> <args>sed -n <val> <path> <n> > <path>rg <val> <path> <n> > <path>find <path> -type <val> <flag> <args>
  75. Validate · Checkpoints & weight state

    Requested workspace inspection, source searches and file and log inspection related to checkpoints & weight state.

    1 call · #0106–#0106

    find <path> -type <val> <flag> <args>rg <val> <path> <path>tail -n <n><command> <args>rg <val> <path>
  76. Inspect · Checkpoints & weight state

    Requested workspace inspection, source searches and file and log inspection related to checkpoints & weight state.

    1 call · #0107–#0107

    find <path> -type <val> <flag> <args>rg <val> <path> <path>tail -n <n>
  77. Validate · Benchmark & validation setup

    Requested workspace inspection, source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0108–#0108

    ls -l -h <path> <n> > <path>truerg <path> <path> <path> <n> > <path>tail -n <n>ps <flag> <args>rg <path>
    2 more command sketches
    rg -v <val>head -n <n>
  78. Inspect · Checkpoints & weight state

    Requested source searches and file and log inspection related to checkpoints & weight state.

    1 call · #0109–#0109

    rg <path> <path> <path>tail -n <n>tail -n <n> <path>
  79. Inspect · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0110–#0110

    rg <path> <path> <path>tail -n <n>
  80. Validate · Benchmark & validation setup

    Requested workspace file updates and script or workload execution related to benchmark & validation setup.

    1 call · #0111–#0111

    cp <path> <path>python -m <module> <script>bash <script>
  81. Execute · Benchmark & validation setup

    Requested source searches and file and log inspection related to benchmark & validation setup.

    1 call · #0112–#0112

    <command> <args>echo <val>rg <path> <val>tail -n <n>
  82. Inspect · Benchmark & validation setup

    Requested source searches, file and log inspection and workspace inspection related to benchmark & validation setup.

    3 calls · #0113–#0115

    rg <path> <path>tail -n <n>ls -l <flag> <args>
  83. Validate · Benchmark & validation setup

    Requested workspace file updates and script or workload execution related to benchmark & validation setup.

    1 call · #0116–#0116

    cp <path> <path>bash <script>
  84. Inspect · Source & workspace

    Requested environment setup or inspection, source searches and workspace inspection related to source & workspace.

    1 call · #0117–#0117

    envrg <val>find <val> -maxdepth <n> -type <val> <flag> <args>sorttail -n <n>
  85. Execute · Benchmark & validation setup

    Requested workspace file updates and script or workload execution related to benchmark & validation setup.

    1 call · #0118–#0118

    cp <path> <path>bash <script><command> <args>
  86. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    2 calls · #0119–#0120

    git status --shortgit diff --statgit diff --check
  87. Inspect · Attention kernels

    Requested repository inspection related to attention kernels.

    1 call · #0121–#0121

    git diff <flag> <args>
  88. Inspect · Parallelism & communication

    Requested repository inspection related to parallelism & communication.

    1 call · #0122–#0122

    git diff <flag> <args>
  89. Inspect · Benchmark & validation setup

    Requested workspace inspection, source searches and file and log inspection related to benchmark & validation setup.

    2 calls · #0123–#0124

    find <val> -maxdepth <n> -type <val> <flag> <args>sortrg <val>jq -r <path> <path> <path>jq -n <flag> <args>
  90. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    1 call · #0125–#0125

    rg --files <val>rg <val>head -n <n>
  91. Other · Attention kernels

    Requested script or workload execution and repository inspection related to attention kernels.

    1 call · #0126–#0126

    python -m <module> <script> <script>git diff --check
  92. Other · Parallelism & communication

    Requested script or workload execution and repository inspection related to parallelism & communication.

    1 call · #0127–#0127

    python -m <module> <script> <script> <script> <script>git diff --check
  93. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    2 calls · #0128–#0129

    rg --filesrg <path>rg <val>head -n <n>
  94. Inspect · Parallelism & communication

    Requested file and log inspection related to parallelism & communication.

    1 call · #0130–#0130

    sed -n <val> <path>
  95. Inspect · Task requirements

    Requested workspace inspection and source searches related to task requirements.

    1 call · #0131–#0131

    find <val> -maxdepth <n> -type <val> <flag> <args>sortrg <val>
  96. Execute · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0132–#0132

    python -m <module> -i <path> <path>
  97. Inspect · Checkpoints & weight state

    Requested file and log inspection related to checkpoints & weight state.

    1 call · #0133–#0133

    jq <val> <path>
  98. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0134–#0134

    sed -n <val> <path>
  99. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0135–#0135

    sed -n <val> <path>
  100. Inspect · Attention kernels

    1 tool error

    Requested source searches and file and log inspection related to attention kernels.

    2 calls · #0136–#0137

    rg -n <val> <path> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> -S
  101. Inspect · Dependencies & build setup

    Requested file and log inspection related to dependencies & build setup.

    1 call · #0138–#0138

    sed -n <val> <path>jq <val> <path>
  102. Inspect · Task requirements

    Requested file and log inspection and workspace inspection related to task requirements.

    1 call · #0139–#0139

    jq <val> <path>find <path> -maxdepth <n> -type <val> <flag> <args>sort
  103. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0140–#0140

    sed -n <val> <path>
  104. Validate · Attention kernels

    1 tool error

    Requested test runs related to attention kernels.

    1 call · #0141–#0141

    pytest -q <path>
  105. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0142–#0142

    bash <script>
  106. Other · Attention kernels

    1 tool error

    Requested tool activity related to attention kernels.

    1 call · #0143–#0143

    <command> <args>
  107. Other · Parallelism & communication

    1 tool error

    Requested tool activity related to parallelism & communication.

    1 call · #0144–#0144

    <command> <args>
  108. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0145–#0145

    jq -e <path> <path>
  109. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    2 calls · #0146–#0147

    git status --shortgit diff --check
  110. Inspect · Attention kernels

    Requested source searches related to attention kernels.

    1 call · #0148–#0148

    rg -n <val> <path> <path>rg -n <val> <path> <path> <path> <path>

03 / CANDIDATE ARTIFACT

Text patches & binary names

Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.

mindspeed · 2 changed files

Base commit: df2ea7fad8e43016b0e2edbf7ce16026496df2ae

diff --git a/mindspeed/core/fusions/fused_rope.py b/mindspeed/core/fusions/fused_rope.pyindex 00a3d66e41411ac63b1e52536194bc47fa38d397..c595c61d0a7731d5d7d0135c907a27cc51fe4d1a 100644--- a/mindspeed/core/fusions/fused_rope.py+++ b/mindspeed/core/fusions/fused_rope.py@@ -47,6 +47,22 @@ def apply_rotary_pos_emb_bshd(     Returns:         Tensor: The input tensor after applying RoPE     """+    cos_, sin_ = _rotary_cos_sin(freqs, t.dtype, mscale)+    return _apply_rotary_pos_emb_with_cos_sin(+        t,+        cos_,+        sin_,+        rotary_interleaved=rotary_interleaved,+        multi_latent_attention=multi_latent_attention,+    )+++def _rotary_cos_sin(+    freqs: Tensor,+    dtype: torch.dtype,+    mscale: float = 1.0,+) -> tuple[Tensor, Tensor]:+    """Materialize the non-differentiable RoPE constants for a tensor dtype."""     args = get_full_args()     _mscale = mscale     if hasattr(args, "rope_scaling_type") and args.rope_scaling_type == "yarn":@@ -55,15 +71,28 @@ def apply_rotary_pos_emb_bshd(             / yarn_get_mscale(args.yarn_scaling_factor, args.rope_scaling_mscale_all_dim)         ) +    return (+        (torch.cos(freqs) * _mscale).to(dtype),+        (torch.sin(freqs) * _mscale).to(dtype),+    )+++def _apply_rotary_pos_emb_with_cos_sin(+    t: Tensor,+    cos_: Tensor,+    sin_: Tensor,+    rotary_interleaved: bool = False,+    multi_latent_attention: bool = False,+) -> Tensor:+    """Apply already-materialized RoPE constants to an input tensor."""+    args = get_full_args()     if multi_latent_attention:         x1 = t[..., 0::2]         x2 = t[..., 1::2]         t = torch.cat((x1, x2), dim=-1) -    rot_dim = freqs.shape[-1]+    rot_dim = cos_.shape[-1]     t, t_pass = t[..., :rot_dim], t[..., rot_dim:]-    cos_ = (torch.cos(freqs) * _mscale).to(t.dtype)-    sin_ = (torch.sin(freqs) * _mscale).to(t.dtype)      if getattr(args, "use_fused_rotary_pos_emb"):         mode = 1 if rotary_interleaved else 0diff --git a/mindspeed/core/transformer/flash_attention/reset_attention_mask/adaptor.py b/mindspeed/core/transformer/flash_attention/reset_attention_mask/adaptor.pyindex cf83901088842333b53425ad794c7da0c3b75ea7..f54e1e7d75e94dce42eb4ec5a896ee577fd41f6a 100644--- a/mindspeed/core/transformer/flash_attention/reset_attention_mask/adaptor.py+++ b/mindspeed/core/transformer/flash_attention/reset_attention_mask/adaptor.py@@ -31,7 +31,11 @@ from megatron.core.transformer.multi_latent_attention import MLASelfAttention from mindspeed.utils import get_position_ids, set_position_ids from mindspeed.core.context_parallel.get_batch_utils import get_actual_seq_len, set_actual_seq_len from mindspeed.core.context_parallel.rotary_pos_embedding_utils import get_pos_emb_on_this_cp_rank-from mindspeed.core.fusions.fused_rope import apply_rotary_pos_emb_bshd, apply_rotary_pos_emb+from mindspeed.core.fusions.fused_rope import (+    _apply_rotary_pos_emb_with_cos_sin,+    _rotary_cos_sin,+    apply_rotary_pos_emb,+)   def _p2p_ops_eod(@@ -599,13 +603,17 @@ def gpt_forward_wrapper(fn):     def wrapper(*args, **kwargs):         actual_seq_len = get_actual_seq_len() +        # Fusion attention consumes cumulative sequence lengths as a host list.+        # Materialize it once per microbatch instead of converting the same device+        # tensor in every transformer layer (and once each for Q and KV there).+        actual_seq_len_list = actual_seq_len.tolist()+         packed_seq_params = PackedSeqParams(             qkv_format='thd',-            cu_seqlens_q=actual_seq_len,-            cu_seqlens_kv=actual_seq_len+            cu_seqlens_q=actual_seq_len_list,+            cu_seqlens_kv=actual_seq_len_list         ) -        actual_seq_len_list = actual_seq_len.tolist()         max_actual_seq_len = actual_seq_len_list[0]         for i in range(1, len(actual_seq_len_list)):             max_actual_seq_len = max(max_actual_seq_len, actual_seq_len_list[i] - actual_seq_len_list[i - 1])@@ -677,10 +685,40 @@ def apply_rotary_pos_emb_thd(     """      position_ids = cu_seqlens.position_ids-    block_size, bsz = position_ids.shape-    freqs = freqs[position_ids.view(-1)].reshape(block_size, bsz, 1, -1)--    return apply_rotary_pos_emb_bshd(t, freqs, rotary_interleaved, multi_latent_attention, mscale)+    cache = getattr(cu_seqlens, '_mindspeed_rotary_cos_sin', None)+    if (+        cache is None+        or cache[0] is not freqs+        or cache[1] is not position_ids+        or cache[2] != t.dtype+        or cache[3] != rotary_interleaved+        or cache[4] != multi_latent_attention+        or cache[5] != mscale+    ):+        block_size, bsz = position_ids.shape+        selected_freqs = freqs[position_ids.view(-1)].reshape(+            block_size, bsz, 1, -1+        )+        cos_, sin_ = _rotary_cos_sin(selected_freqs, t.dtype, mscale)+        cache = (+            freqs,+            position_ids,+            t.dtype,+            rotary_interleaved,+            multi_latent_attention,+            mscale,+            cos_,+            sin_,+        )+        cu_seqlens._mindspeed_rotary_cos_sin = cache++    return _apply_rotary_pos_emb_with_cos_sin(+        t,+        cache[6],+        cache[7],+        rotary_interleaved=rotary_interleaved,+        multi_latent_attention=multi_latent_attention,+    )   def Eod_get_rotary_seq_len(@@ -736,6 +774,20 @@ def rotary_forward(self, max_seq_len: int, offset: int = 0, packed_seq: bool = F     if self.inv_freq.device.type == 'cpu':         # move `inv_freq` to GPU once at the first micro-batch forward pass         self.inv_freq = self.inv_freq.to(device=torch.cuda.current_device())++    cache_key = (+        max_seq_len,+        offset,+        self.inv_freq.device,+        self.inv_freq.dtype,+        self.inv_freq._version,+        self.seq_len_interpolation_factor,+        self.rotary_interleaved,+    )+    cached = getattr(self, '_mindspeed_rotary_freqs', None)+    if cached is not None and cached[0] == cache_key:+        return cached[1]+     seq = (             torch.arange(max_seq_len, device=self.inv_freq.device, dtype=self.inv_freq.dtype)             + offset@@ -756,4 +808,6 @@ def rotary_forward(self, max_seq_len: int, offset: int = 0, packed_seq: bool = F     # emb [seq_length, .., dim]     emb = emb[:, None, None, :] +    self._mindspeed_rotary_freqs = (cache_key, emb)+     return emb
mindspeed_llm · 4 changed files

Base commit: 72c49a6260c73669678b8f39b1ba41a4789bb555

diff --git a/megatron/core/tensor_parallel/cross_entropy.py b/megatron/core/tensor_parallel/cross_entropy.pyindex 27c8f06344062d657d7c272f8468ae8ecda7bdfa..2f4470695b97dcee9310fe60b9e716691edb09be 100644--- a/megatron/core/tensor_parallel/cross_entropy.py+++ b/megatron/core/tensor_parallel/cross_entropy.py@@ -127,15 +127,18 @@ class _VocabParallelCrossEntropy(torch.autograd.Function):         vocab_parallel_logits, logits_max = VocabParallelCrossEntropy.calculate_logits_max(             vocab_parallel_logits         )-        torch.distributed.all_reduce(-            logits_max, op=torch.distributed.ReduceOp.MAX, group=get_tensor_model_parallel_group()-        )+        world_size = get_tensor_model_parallel_world_size()+        if world_size > 1:+            torch.distributed.all_reduce(+                logits_max,+                op=torch.distributed.ReduceOp.MAX,+                group=get_tensor_model_parallel_group(),+            )          # Get the partition's vocab indices         get_vocab_range = VocabUtility.vocab_range_from_per_partition_vocab_size         partition_vocab_size = vocab_parallel_logits.size()[-1]         rank = get_tensor_model_parallel_rank()-        world_size = get_tensor_model_parallel_world_size()         vocab_start_index, vocab_end_index = get_vocab_range(partition_vocab_size, rank, world_size)          (target_mask, masked_target_1d, predicted_logits, sum_exp_logits, exp_logits) = (@@ -145,17 +148,18 @@ class _VocabParallelCrossEntropy(torch.autograd.Function):         )          # All reduce is needed to get the chunks from other GPUs.-        torch.distributed.all_reduce(-            predicted_logits,-            op=torch.distributed.ReduceOp.SUM,-            group=get_tensor_model_parallel_group(),-        )+        if world_size > 1:+            torch.distributed.all_reduce(+                predicted_logits,+                op=torch.distributed.ReduceOp.SUM,+                group=get_tensor_model_parallel_group(),+            ) -        torch.distributed.all_reduce(-            sum_exp_logits,-            op=torch.distributed.ReduceOp.SUM,-            group=get_tensor_model_parallel_group(),-        )+            torch.distributed.all_reduce(+                sum_exp_logits,+                op=torch.distributed.ReduceOp.SUM,+                group=get_tensor_model_parallel_group(),+            )          exp_logits, loss = VocabParallelCrossEntropy.calculate_cross_entropy_loss(             exp_logits, predicted_logits, sum_exp_logitsdiff --git a/megatron/core/timers.py b/megatron/core/timers.pyindex 27195169a1dfcbb744555b6ebe8ea5c0c9b22717..3c529c484f0403fe99d4b85599191168b017449d 100644--- a/megatron/core/timers.py+++ b/megatron/core/timers.py@@ -409,6 +409,11 @@ class Timers:                                       Defaults to False.         """ +        # Avoid allocating a device tensor and launching an all-gather when all+        # requested timers are disabled by the configured timing log level.+        if not any(name in self._timers for name in names):+            return+         output_string = self.get_all_timers_string(names, normalizer, reset, barrier)         # If no input rank is provided, log on last rank.         if rank is None:diff --git a/megatron/training/utils.py b/megatron/training/utils.pyindex 61a69e140a74acc3caaf982470d0d5266a1d3394..059d137777fb177e902796aabe306015e1ca6a16 100644--- a/megatron/training/utils.py+++ b/megatron/training/utils.py@@ -230,11 +230,15 @@ def reduce_max_stat_across_model_parallel_group(stat: float) -> float:      We use an all_reduce max since the values have already been summed across optimizer ranks where possible     """+    group = mpu.get_model_parallel_group()+    if torch.distributed.get_world_size(group=group) == 1:+        return stat+     if stat is None:         stat = -1.0     stat = torch.tensor([stat], dtype=torch.float32, device=torch.cuda.current_device())     torch.distributed.all_reduce(-        stat, op=torch.distributed.ReduceOp.MAX, group=mpu.get_model_parallel_group()+        stat, op=torch.distributed.ReduceOp.MAX, group=group     )     if stat.item() == -1.0:         return None@@ -246,13 +250,17 @@ def logical_and_across_model_parallel_group(input: bool) -> bool:     """     This function gathers a bool value across the model parallel group     """+    group = mpu.get_model_parallel_group()+    if torch.distributed.get_world_size(group=group) == 1:+        return bool(input)+     if input is True:         input = 1     else:         input = 0     input = torch.tensor([input], dtype=torch.int, device=torch.cuda.current_device())     torch.distributed.all_reduce(-        input, op=torch.distributed.ReduceOp.MIN, group=mpu.get_model_parallel_group()+        input, op=torch.distributed.ReduceOp.MIN, group=group     )     return bool(input.item()) diff --git a/pretrain_gpt.py b/pretrain_gpt.pyindex 5a8506bb3f73e23ca5e1c1e2562d0a861c433cfb..dd25dba207de8a0d5aef0e2c3bca27eff625b3b6 100644--- a/pretrain_gpt.py+++ b/pretrain_gpt.py@@ -3,6 +3,7 @@ """Pretrain GPT."""  import os+import sys from functools import partial from typing import Union @@ -55,6 +56,23 @@ def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megat     args = get_args()     use_te = args.transformer_impl == "transformer_engine" +    # Communication overlap only changes when the distributed optimizer's+    # reduce-scatter and parameter all-gather are scheduled.  Enable it after+    # argument parsing (and before DDP construction) for supported DP jobs.+    if (+        args.use_distributed_optimizer+        and args.data_parallel_size > 1+        and not args.use_legacy_models+    ):+        args.overlap_grad_reduce = True+        args.overlap_param_gather = True++    # Long-lived training tensors do not need cyclic collection on the hot+    # path.  Megatron's manual mode collects once before the first update and,+    # with a zero interval, keeps later updates free of uncoordinated GC pauses.+    args.manual_gc = True+    args.manual_gc_interval = 0+     print_rank_0('building GPT model ...')     # Experimental loading arguments from yaml     if args.yaml_cfg is not None:@@ -294,15 +312,38 @@ def train_valid_test_datasets_provider(train_val_test_num_samples):     return train_ds, valid_ds, test_ds  +def _finalize_distributed_process():+    # A multi-rank training process owns several billion-parameter Python+    # objects whose interpreter finalizers otherwise serialize process exit.+    # Once all device work and ranks are synchronized, explicitly tear down the+    # process group and let the OS release process-owned tensors in one pass.+    if torch.distributed.is_initialized() and torch.distributed.get_world_size() > 1:+        torch.cuda.synchronize()+        torch.distributed.barrier()+        torch.distributed.destroy_process_group()+        sys.stdout.flush()+        sys.stderr.flush()+        os._exit(0)++ @auto_coverage def main():     # Temporary for transition to core datasets     train_valid_test_datasets_provider.is_distributed = True -    pretrain(train_valid_test_datasets_provider,-             model_provider,-             ModelType.encoder_or_decoder,-             forward_step)+    try:+        pretrain(train_valid_test_datasets_provider,+                 model_provider,+                 ModelType.encoder_or_decoder,+                 forward_step)+    except SystemExit as exc:+        # Megatron uses a successful SystemExit for checkpoint/duration exit+        # intervals.  Preserve nonzero failures, but finalize successful exits+        # through the same bounded distributed teardown as normal completion.+        if exc.code not in (None, 0):+            raise++    _finalize_distributed_process()   if __name__ == "__main__":