Claude Opus 5 · Training

T05 · Training adapt

Valid

LFM2-1.2B model adapt training 1dev · Model Adaptation

1.34×PERFORMANCE RATIO
204TOOL EVENTS
1TEXT 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 agentClaude Opus 5 · 204 visible calls

InspectEditValidateExecuteBuildProfileRollbackOther
103Inspect
37Edit
20Validate
12Execute
32Other

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 timeline137 groups · 204 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 · Source & workspace

    Requested workspace inspection related to source & workspace.

    1 call · #0001–#0001

    echo <val>ls -l -a <val> <n> > <path>echo <path>
  2. Inspect · Task requirements

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

    3 calls · #0002–#0004

    ls -l -a <path> <n> > <path>find <path> -maxdepth <n> -name <val> <n> > <path>head -n <n>Read <path>
  3. Inspect · Source & workspace

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

    3 calls · #0005–#0007

    cd <path>find <path> -type <val>sortecho <flag>find <path> -type <val> -exec <val> -l <val>sort <flag>
    1 more command sketches
    Read <path>
  4. Inspect · Benchmark & validation setup

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

    4 calls · #0008–#0011

    Read <path>
  5. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0012–#0012

    Read <path>
  6. Inspect · Benchmark & validation setup

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

    1 call · #0013–#0013

    Read <path>
  7. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    3 calls · #0014–#0016

    Read <path>
  8. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    3 calls · #0017–#0019

    Read <path>
  9. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0020–#0020

    Read <path>
  10. Inspect · Checkpoints & weight state

    Requested workspace inspection related to checkpoints & weight state.

    1 call · #0021–#0021

    cd <path>lsecho <val>ls <val>ls <path>ls <path> <n> > <path>
    1 more command sketches
    echo <path>
  11. Inspect · Source & workspace

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

    5 calls · #0022–#0026

    lsecho <val>ls <val>ls <path> <n> > <path>head -n <n>cd <path>
    6 more command sketches
    cat <path>envgrep -i -E <val>sortfind <path> -maxdepth <n> -iname <val> <flag> <args>ls -l -a <path>
  12. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0027–#0027

    cd <path>python3 -c <script>
  13. Inspect · Source & workspace

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

    1 call · #0028–#0028

    python3 -c <script>ls <path>grep -i <val>
  14. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0029–#0029

    cd <path>python3 -c <script> <n> > <path>
  15. Other · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0030–#0030

    wc -l <path> <path> <n> > <path>
  16. Inspect · Source & workspace

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

    5 calls · #0031–#0035

    Read <path>date -uecho <val>cd <path>cat <path>grep -r -n <val> <path> <path> <path> <n> > <path>
    3 more command sketches
    head -n <n>ls <path>sed -n <val> <path>
  17. Inspect · Attention kernels

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

    1 call · #0036–#0036

    grep -r -n <val> --include <path> <path>head -n <n>echo <val>cat <path>
  18. Inspect · Source & workspace

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

    1 call · #0037–#0037

    cd <path>grep -n <val> <path>head -n <n>
  19. Inspect · Attention kernels

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

    1 call · #0038–#0038

    grep -r -n <val> --include <path> <path>head -n <n>
  20. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0039–#0039

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

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

    3 calls · #0040–#0042

    echo <val>cat <path>sed -n <val> <path>echo <path>cd <path>grep -n <val> -A <n> <path>
    6 more command sketches
    grep -n <val>head -n <n>grep -r -n <val> <path> --include <path> <n> > <path>grep -i <val>headgrep -r -n <val> <path>
  22. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0043–#0043

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

    Requested file and log inspection related to attention kernels.

    2 calls · #0044–#0045

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

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

    2 calls · #0046–#0047

    cd <path>grep -n <val> -A <n> <path>sed -n <val> <path>
  25. Inspect · Checkpoints & weight state

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

    1 call · #0048–#0048

    cd <path>grep -n <val> <path>head -n <n>
  26. Inspect · Source & workspace

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

    1 call · #0049–#0049

    cd <path>grep -n <val> <path>head -n <n>echo <val>sed -n <val> <path>
  27. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0050–#0050

    cd <path>sed -n <val> <path>echo <val>
  28. Inspect · Checkpoints & weight state

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

    1 call · #0051–#0051

    cd <path>sed -n <val> <path>echo <val>
  29. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0052–#0052

    Write <path>
  30. Inspect · Parallelism & communication

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

    2 calls · #0053–#0054

    cd <path>grep -n <val> -A <n> <path>grep -n <val> -A <n>head -n <n>echo <val>grep -n <val> <path> <path>
    4 more command sketches
    headsed -n <val> <path>awk <path> <path>sed -n <val>
  31. Edit · Convolution & sequence boundaries

    Requested code edits related to convolution & sequence boundaries.

    2 calls · #0055–#0056

    Write <path>Edit <path>
  32. Edit · Source & workspace

    Requested code edits related to source & workspace.

    2 calls · #0057–#0058

    Write <path>
  33. Edit · Checkpoints & weight state

    Requested code edits related to checkpoints & weight state.

    4 calls · #0059–#0062

    Write <path>Edit <path>
  34. Inspect · Checkpoints & weight state

    Requested environment setup or inspection, workspace file updates and script or workload execution related to checkpoints & weight state.

    1 call · #0063–#0063

    date -ucd <path>env <vars>rm -rf <val>mkdir -p <val>python3 <script> <val> <flag> <args>
    2 more command sketches
    tail -n <n>echo <flag>
  35. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0064–#0064

    cd <path>python3 -c <script> <n> > <path>
  36. Validate · Benchmark & validation setup

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

    1 call · #0065–#0065

    cd <path>rm -rf <path> <n> > <path>bash <script> <n> >& <path>tail -n <n>
  37. Validate · Checkpoints & weight state

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

    1 call · #0066–#0066

    cd <path>lsecho <val>grep -n -i <val> <val> <n> > <path>head -n <n>
  38. Validate · Benchmark & validation setup

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

    2 calls · #0067–#0068

    cd <path>bash <script> <n> >& <path>tail -n <n>echo <val>date -uenv <vars>
    5 more command sketches
    mkdir -p <val>cp -f <val> <val> <val> <path> <n> > <path>echo <flag>ls <val>cat <path>
  39. Execute · Benchmark & validation setup

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

    1 call · #0069–#0069

    cd <path>bash <script> <n> >& <path>python3 -c <script>
  40. Inspect · Benchmark & validation setup

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

    1 call · #0070–#0070

    cd <path>echo <val>tail -n <n> <val>
  41. Inspect · Runtime processes

    Requested script or workload execution, source searches and file and log inspection related to runtime processes.

    1 call · #0071–#0071

    python3 -c <script>grep -r -n <val> <path>head
  42. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0072–#0072

    date -uecho <val>python3 -c <script>
  43. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0073–#0073

    cd <path>sed -n <path> <path>head -n <n>
  44. Inspect · Checkpoints & weight state

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

    1 call · #0074–#0074

    cd <path>grep -n <val> <path>headecho <flag>head -n <n>echo <val>
    1 more command sketches
    sed -n <path> <path>
  45. Inspect · Source & workspace

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

    1 call · #0075–#0075

    cd <path>grep -n <val> <path>head -n <n>echo <val>tail -n <n> <path>
  46. Inspect · Benchmark & validation setup

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

    1 call · #0076–#0076

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

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

    1 call · #0077–#0077

    cd <path>sed -n <path> <path>grep -n <val>tail -n <n>
  48. Inspect · Benchmark & validation setup

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

    1 call · #0078–#0078

    cd <path>sed -n <val> <path>
  49. Inspect · Runtime processes

    Requested source searches and file and log inspection related to runtime processes.

    1 call · #0079–#0079

    cd <path>grep -n <val> <path>head -n <n>
  50. Execute · Batching & scheduling

    Requested script or workload execution and file and log inspection related to batching & scheduling.

    1 call · #0080–#0080

    cd <val>python3 -c <script> <n> > <path>head -n <n>
  51. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0081–#0081

    Write <path>
  52. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0082–#0082

    cat <path>
  53. Edit · Source & workspace

    Requested code edits related to source & workspace.

    3 calls · #0083–#0085

    Edit <path>
  54. Inspect · Benchmark & validation setup

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

    1 call · #0086–#0086

    cd <path>timeout <n> <path> <path> <n> >& <path>grep -v <val>tail -n <n>
  55. Inspect · Attention kernels

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

    1 call · #0087–#0087

    grep -r -n <val> <path> <path> <path> <n> > <path>head -n <n>echo <val>ls <path> <n> > <path>grep -r -l -n <val> <path>head
  56. Inspect · Source & workspace

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

    6 calls · #0088–#0093

    cd <path>sed -n <val> <path>grep -r -n <val> --include <path> <path>headecho <flag>grep -r -n <val> <path>
    4 more command sketches
    grep -n <val> <path>sed -n <path> <path>head -n <n>ls <path>
  57. Edit · Source & workspace

    Requested code edits related to source & workspace.

    4 calls · #0094–#0097

    Write <path>Edit <path>
  58. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0098–#0098

    Read <path>
  59. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0099–#0099

    Edit <path>
  60. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0100–#0100

    Read <path>
  61. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0101–#0101

    Edit <path>
  62. Other · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0102–#0102

    cd <val>python3 -c <script>
  63. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0103–#0103

    cd <path>python3 -m <module> <script> <script>echo <val>python3 -c <script>
  64. Validate · Benchmark & validation setup

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

    1 call · #0104–#0104

    cd <val>timeout <n> <val> <path> <n> >& <path>tail -n <n>
  65. Inspect · Source & workspace

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

    1 call · #0105–#0105

    env <vars>ls <val>head -n <n>echo <flag>wc -lmkdir -p <path>
    5 more command sketches
    mv <path> <path> <n> > <path>echo <val>ls -A <val>date -upython3 -c <script>
  66. Validate · Benchmark & validation setup

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

    2 calls · #0106–#0107

    cd <val>timeout <n> <val> <path> <n> >& <path>tail -n <n>env <vars>ls <val> <n> > <path>ls <path> <n> > <path>
    4 more command sketches
    echo <val><command> <args>echo <flag>diff < <path> -m <val> <flag> <args>
  67. Inspect · Source & workspace

    Requested workspace inspection related to source & workspace.

    1 call · #0108–#0108

    ls <path>
  68. Validate · Benchmark & validation setup

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

    2 calls · #0109–#0110

    cd <val>timeout <n> <val> <path> <n> >& <path>tail -n <n>env <vars>ls -l -a <val>grep -i <val>
    3 more command sketches
    echo <val>cat <path> <n> > <path>python3 -m <module> <n> > <path>
  69. Inspect · Benchmark & validation setup

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

    1 call · #0111–#0111

    cd <path>cat <path>echo <val>
  70. Validate · Benchmark & validation setup

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

    1 call · #0112–#0112

    env <vars>mkdir -p <path>cp <path> <path> <path> <n> > <path>mv <path> <path> <n> > <path>echo <val>date -u
    1 more command sketches
    python3 -c <script>
  71. Execute · Benchmark & validation setup

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

    2 calls · #0113–#0114

    cd <val>timeout <n> <val> <path> <n> >& <path>python3 -c <script>env <vars>
  72. Inspect · Runtime processes

    Requested source searches and file and log inspection related to runtime processes.

    1 call · #0115–#0115

    cd <path>grep -n <val> <path>echo <val>sed -n <path> <path>
  73. Edit · Source & workspace

    Requested code edits related to source & workspace.

    5 calls · #0116–#0120

    Write <path>Edit <path>
  74. Other · Source & workspace

    1 tool error

    Requested script or workload execution related to source & workspace.

    2 calls · #0121–#0122

    cd <path>timeout <n> <path> <path> <n> > <path>date -upython3 -c <script>
  75. Edit · Source & workspace

    Requested code edits related to source & workspace.

    3 calls · #0123–#0125

    Write <path>Edit <path>
  76. Other · Benchmark & validation setup

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

    1 call · #0126–#0126

    cd <path>timeout <n> <path> <path> <n> > <path>
  77. Edit · Source & workspace

    Requested code edits related to source & workspace.

    3 calls · #0127–#0129

    Write <path>Edit <path>
  78. Other · Runtime processes

    Requested script or workload execution related to runtime processes.

    1 call · #0130–#0130

    cd <path>timeout <n> <path> <path> <n> > <path>
  79. Inspect · Parallelism & communication

    Requested file and log inspection related to parallelism & communication.

    1 call · #0131–#0131

    cd <path>sed -n <path> <path>head -n <n>
  80. Inspect · Source & workspace

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

    1 call · #0132–#0132

    cd <path>git status --shorthead -n <n>echo <val>
  81. Other · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0133–#0133

    echo <path>git -C <path> <val> --shortecho <val>
  82. Inspect · Source & workspace

    Requested workspace inspection, file and log inspection and repository inspection related to source & workspace.

    1 call · #0134–#0134

    ls -l -a <path> <n> > <path>headecho <flag>ls <path> <n> > <path>git -C <path> <val> --short <flag> <args>grep -c <val>
    1 more command sketches
    echo <n>
  83. Inspect · Attention kernels

    Requested file and log inspection and workspace inspection related to attention kernels.

    1 call · #0135–#0135

    sed -n <val> <path> <n> > <path>find <path> -path <val> -name <path>head
  84. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0136–#0136

    date -upython3 -c <script>
  85. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0137–#0137

    sed -n <path> <path>
  86. Execute · Benchmark & validation setup

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

    2 calls · #0138–#0139

    rm -rf <path>echo <val>ls <path> <n> >& <path>head -n <n>env <vars>mkdir -p <path>
    4 more command sketches
    mv <path> <path> <n> > <path>cd <val>timeout <n> <val> <path> > <path> <n> >& <path>python3 -c <script>
  87. Inspect · Source & workspace

    1 tool error

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

    2 calls · #0140–#0141

    cat <path>echo <val>sed -n <path> <path>head -n <n>cd <val>timeout <n> <val> <path> <n> >& <path>
    1 more command sketches
    python3 -c <script>
  88. Other · Source & workspace

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

    1 call · #0142–#0142

    env <vars>python3 -m <module> <flag> <args>
  89. Other · Checkpoints & weight state

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

    1 call · #0143–#0143

    echo <path>git -C <path> <val> --short <flag> <args>echo <val>cd <path>wc -l <path> <path> <path> <path> <path> <path> <path>
  90. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0144–#0144

    date -upython3 -c <script>
  91. Inspect · Source & workspace

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

    2 calls · #0145–#0146

    cd <path>grep -n <val> <path> <path> <n> > <path>env <vars>ls -A <val>
  92. Inspect · Device memory

    Requested environment setup or inspection, workspace inspection and file and log inspection related to device memory.

    1 call · #0147–#0147

    env <vars>ls -A <val> <n> > <path>echo <flag>cat <path> <n> > <path>echo <val>
  93. Inspect · Source & workspace

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

    1 call · #0148–#0148

    env <vars>mkdir -p <path>mv <path> <path> <path> <n> > <path>echo <val>ls -A <val>
  94. Edit · Device memory

    Requested code edits related to device memory.

    3 calls · #0149–#0151

    Write <path>
  95. Other · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0152–#0152

    git -C <path> <val> <path>
  96. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0153–#0153

    Read <path>
  97. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0154–#0154

    date -upython3 -c <script>
  98. Inspect · Source & workspace

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

    1 call · #0155–#0155

    cd <path>grep -n <val> <path>head -n <n>
  99. Validate · Benchmark & validation setup

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

    3 calls · #0156–#0158

    env <vars>mkdir -p <path>mv <path> <path> <n> > <path>cd <val>timeout <n> <val> <path> <n> >& <path>python3 -c <script>
    3 more command sketches
    echo <val>diff < <path> -m <val> <flag> <args>cp <path> <path> <n> > <path>
  100. Execute · Benchmark & validation setup

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

    1 call · #0159–#0159

    cd <val>timeout <n> <val> <path> > <path> <n> >& <path>env <vars>python3 -c <script>
  101. Inspect · Source & workspace

    Requested script or workload execution, environment setup or inspection and workspace file updates related to source & workspace.

    2 calls · #0160–#0161

    cd <val>timeout <n> <val> <path> > <path> <n> >& <path>env <vars>python3 -c <script>mkdir -p <path>mv <path> <path> <path> <n> > <path>
    5 more command sketches
    echo <val>ls -A <val>echo <path>git -C <path> <val> --short <flag> <args>ls <path> <n> > <path>
  102. Validate · Benchmark & validation setup

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

    2 calls · #0162–#0163

    python3 -c <script>env <vars>mkdir -p <path>mv <path> <path> <n> > <path>cd <val>timeout <n> <val> <path> <n> >& <path>
    7 more command sketches
    timeout <n> <val> <path> > <path> <n> >& <path>mv <path> <path> <path> <n> > <path>echo <val>ls -A <val>find <path> <path> -name <val> <flag> <args>head -n <n>ls <path> <n> > <path>
  103. Inspect · Convolution & sequence boundaries

    Requested file and log inspection related to convolution & sequence boundaries.

    1 call · #0164–#0164

    Read <path>
  104. Other · Checkpoints & weight state

    Requested script or workload execution related to checkpoints & weight state.

    1 call · #0165–#0165

    cd <path><command> <args>python3 - <val> <script>
  105. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0166–#0166

    date -upython3 -c <script>
  106. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0167–#0167

    Write <path>
  107. Inspect · Source & workspace

    1 tool error

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

    1 call · #0168–#0168

    cd <path><command> <args><script> <args>env <vars>tail -n <n>tr <val> <val>
    1 more command sketches
    printf <val> <val> <val> <val> <val>
  108. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0169–#0169

    Write <path>
  109. Inspect · Source & workspace

    Requested environment setup or inspection and file and log inspection related to source & workspace.

    1 call · #0170–#0170

    cd <path><command> <args>env <vars>tail <flag>printf <val> <val> <val> <val> <val>
  110. Other · Source & workspace

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

    1 call · #0171–#0171

    rm -rf <path>echo <val>echo <path>git -C <path> <val> --short <flag> <args>python3 -c <script>
  111. Execute · Checkpoints & weight state

    Requested tool activity related to checkpoints & weight state.

    1 call · #0172–#0172

    cd <path>echo <val><command> <args>printf <val> <val> <val>date -u -r <path> <val> <n> > <path>
  112. Validate · Benchmark & validation setup

    Requested environment setup or inspection, workspace file updates and workspace inspection related to benchmark & validation setup.

    1 call · #0173–#0173

    env <vars>cp <path> <path> <path> <path> <path> <n> > <path>echo <val>ls -A <val>ls <path> <n> > <path>
  113. Execute · Benchmark & validation setup

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

    1 call · #0174–#0174

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>
  114. Inspect · Convolution & sequence boundaries

    Requested file and log inspection and source searches related to convolution & sequence boundaries.

    2 calls · #0175–#0176

    Read <path>cd <path>grep -n <val> <path>
  115. Inspect · Runtime processes

    Requested script or workload execution, runtime inspection and file and log inspection related to runtime processes.

    1 call · #0177–#0177

    python3 -c <script>echo <val>pgrep <flag> <args>headecho <path>ls -d <path> <n> > <path>
    1 more command sketches
    ls <path> <n> > <path>
  116. Inspect · Device memory

    Requested runtime inspection and file and log inspection related to device memory.

    1 call · #0178–#0178

    npu-smi info <n> > <path>head -n <n>echo <val>
  117. Execute · Benchmark & validation setup

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

    1 call · #0179–#0179

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args><command> <args>
  118. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0180–#0180

    cd <path>sed -n <path> <path>
  119. Inspect · Device memory

    Requested environment setup or inspection, workspace inspection and file and log inspection related to device memory.

    1 call · #0181–#0181

    env <vars>ls -A <val>echo <flag>cat <path>
  120. Other · Checkpoints & weight state

    Requested script or workload execution related to checkpoints & weight state.

    1 call · #0182–#0182

    python3 -c <script>echo <val>cd <path><command> <args>test -f <val>
  121. Inspect · Optimizer & gradients

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

    1 call · #0183–#0183

    cd <path>grep -r -n <val> <path>head -n <n>
  122. Inspect · Source & workspace

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

    1 call · #0184–#0184

    grep -r -n <val> <path> <n> > <path>head -n <n>
  123. Edit · Device memory

    Requested code edits related to device memory.

    2 calls · #0185–#0186

    Edit <path>
  124. Inspect · Source & workspace

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

    1 call · #0187–#0187

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>ls -A <path>
  125. Other · Attention kernels

    1 tool error

    Requested script or workload execution related to attention kernels.

    1 call · #0188–#0188

    cd <path>python3 - <script>echo <flag>
  126. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0189–#0189

    Read <path>
  127. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    2 calls · #0190–#0191

    python3 - <script>echo <flag>
  128. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0192–#0192

    python3 -c <script>python3 - <script>
  129. Validate · Benchmark & validation setup

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

    1 call · #0193–#0193

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>
  130. Execute · Benchmark & validation setup

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

    2 calls · #0194–#0195

    cd <val>timeout <n> <val> <path> > <path> <n> >& <path>env <vars>python3 -c <script>python3 - <script>
  131. Validate · Device memory

    Requested script or workload execution, environment setup or inspection and workspace file updates related to device memory.

    1 call · #0196–#0196

    cd <val>timeout <n> <val> <path> > <path> <n> >& <path>env <vars>python3 -c <script>mkdir -p <path>mv <path> <path> <path> <n> > <path>
    7 more command sketches
    cp <path> <path> <path> <n> > <path>echo <val>ls -A <val>ls <path> <n> > <path>npu-smi info <n> > <path>grep -E <val>head -n <n>
  132. Validate · Benchmark & validation setup

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

    1 call · #0197–#0197

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>
  133. Other · Checkpoints & weight state

    Requested script or workload execution and file and log inspection related to checkpoints & weight state.

    1 call · #0198–#0198

    python3 -c <script>cd <path>echo <val>wc -l <path> <path> <path> <path> <path> <path> <path>
  134. Other · Device memory

    Requested script or workload execution, repository inspection and runtime inspection related to device memory.

    1 call · #0199–#0199

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>npu-smi info <n> > <path>grep -E <val>ls <path> <n> > <path>
  135. Other · Source & workspace

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

    3 calls · #0200–#0202

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>echo <path>git -C <path> <val> <flag> <args>awk <val>
    1 more command sketches
    <command> <args>
  136. Validate · Benchmark & validation setup

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

    1 call · #0203–#0203

    python3 -c <script>echo <val>git -C <path> <val> --short <flag> <args>
  137. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0204–#0204

    python3 -c <script>

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_llm · 7 changed files

Base commit: 72c49a6260c73669678b8f39b1ba41a4789bb555

diff --git a/mindspeed_llm/core/models/lfm2/__init__.py b/mindspeed_llm/core/models/lfm2/__init__.pynew file mode 100644index 0000000000000000000000000000000000000000..1566b63006758eaf4ec70b8946a5178f32b50d52--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/__init__.py@@ -0,0 +1,9 @@+# Copyright (c) 2025, HUAWEI CORPORATION.  All rights reserved.+"""Native MCore building blocks for the LFM2 hybrid architecture."""++from mindspeed_llm.core.models.lfm2.short_conv import (+    Lfm2ShortConv,+    Lfm2ShortConvSubmodules,+)++__all__ = ["Lfm2ShortConv", "Lfm2ShortConvSubmodules"]diff --git a/mindspeed_llm/core/models/lfm2/architecture.py b/mindspeed_llm/core/models/lfm2/architecture.pynew file mode 100644index 0000000000000000000000000000000000000000..fda624670754e2dfbb5c57c0eb86608a8279f249--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/architecture.py@@ -0,0 +1,75 @@+# Copyright (c) 2025, HUAWEI CORPORATION.  All rights reserved.+"""Shared LFM2 architecture description.++Both the MCore layer specification and the HF/MCore checkpoint converter need+to agree on which blocks of the hybrid stack are attention blocks and which are+short-convolution blocks.  The pattern is a property of the published+architecture, so it is described once here and consumed by both.+"""++from __future__ import annotations++from typing import List, Optional, Sequence++CONV = "conv"+FULL_ATTENTION = "full_attention"++# Published block pattern of LiquidAI/LFM2.5-1.2B-Base (16 blocks).+LFM2_5_1_2B_LAYER_TYPES: List[str] = [+    CONV, CONV, FULL_ATTENTION, CONV,+    CONV, FULL_ATTENTION, CONV, CONV,+    FULL_ATTENTION, CONV, FULL_ATTENTION, CONV,+    FULL_ATTENTION, CONV, FULL_ATTENTION, CONV,+]++# Default short-convolution kernel width (``conv_L_cache`` in the HF config).+LFM2_CONV_KERNEL = 3++_KNOWN_PATTERNS = {len(LFM2_5_1_2B_LAYER_TYPES): LFM2_5_1_2B_LAYER_TYPES}+++def normalize_layer_types(layer_types: Sequence[str]) -> List[str]:+    """Validate a block-type sequence and return it as a plain list."""+    normalized = [str(item) for item in layer_types]+    unknown = sorted({item for item in normalized if item not in (CONV, FULL_ATTENTION)})+    if unknown:+        raise ValueError(f"unsupported LFM2 layer types: {unknown}")+    if not normalized:+        raise ValueError("LFM2 layer types must not be empty")+    return normalized+++def get_layer_types(+    num_layers: int, layer_types: Optional[Sequence[str]] = None+) -> List[str]:+    """Resolve the per-block operator pattern for an LFM2 stack.++    Args:+        num_layers: number of transformer blocks in the model.+        layer_types: explicit pattern; when omitted the published pattern for+            ``num_layers`` blocks is used.++    Returns:+        A list of ``"conv"`` / ``"full_attention"`` entries, one per block.+    """+    if layer_types is not None:+        normalized = normalize_layer_types(layer_types)+        if len(normalized) != num_layers:+            raise ValueError(+                f"LFM2 layer types describe {len(normalized)} blocks "+                f"but the model has {num_layers}"+            )+        return normalized++    known = _KNOWN_PATTERNS.get(num_layers)+    if known is None:+        raise ValueError(+            f"no published LFM2 block pattern for {num_layers} layers; "+            "pass layer_types explicitly"+        )+    return list(known)+++def is_attention_layer(layer_type: str) -> bool:+    """Return whether ``layer_type`` denotes a full-attention block."""+    return layer_type == FULL_ATTENTIONdiff --git a/mindspeed_llm/core/models/lfm2/short_conv.py b/mindspeed_llm/core/models/lfm2/short_conv.pynew file mode 100644index 0000000000000000000000000000000000000000..2f389f5ec43a2942c55a268d0f4690fb4bbdb72c--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/short_conv.py@@ -0,0 +1,188 @@+# Copyright (c) 2025, HUAWEI CORPORATION.  All rights reserved.+"""LFM2 short convolution operator.++The LFM2 hybrid stack replaces self-attention in most of its blocks with a+gated causal depth-wise short convolution.  The reference implementation+(``transformers.models.lfm2.modeling_lfm2.Lfm2ShortConv``) computes, for an+input ``x`` of shape ``[b, s, h]``::++    B, C, x = in_proj(x).transpose(-1, -2).chunk(3, dim=-2)+    y = C * causal_conv1d(B * x)+    out = out_proj(y.transpose(-1, -2))++This module provides the same operator for Megatron-Core, where activations+are laid out as ``[s, b, h]`` and the projections are parallel linears so the+block can be dropped into the ``self_attention`` slot of a+``TransformerLayer``.+"""++from __future__ import annotations++from dataclasses import dataclass+from typing import Optional, Tuple, Union++import torch+from torch import Tensor++from megatron.core.transformer.module import MegatronModule+from megatron.core.transformer.spec_utils import ModuleSpec, build_module+from megatron.core.transformer.transformer_config import TransformerConfig+from megatron.core.utils import divide+++@dataclass+class Lfm2ShortConvSubmodules:+    """Submodules used by :class:`Lfm2ShortConv`.++    Args:+        in_proj: column-parallel projection producing the ``B``, ``C`` and+            ``x`` streams (``3 * hidden_size`` outputs).+        out_proj: row-parallel projection back to ``hidden_size``.+    """++    in_proj: Union[ModuleSpec, type] = None+    out_proj: Union[ModuleSpec, type] = None+++class Lfm2ShortConv(MegatronModule):+    """Gated causal short convolution block of the LFM2 architecture.++    The module deliberately mirrors the attention interface expected by+    ``TransformerLayer``: it accepts (and ignores) the attention-only keyword+    arguments and returns an ``(output, bias)`` pair so the shared+    bias-dropout-add path can be reused unchanged.+    """++    def __init__(+        self,+        config: TransformerConfig,+        submodules: Lfm2ShortConvSubmodules,+        layer_number: int = 1,+        attn_mask_type=None,+        conv_kernel: Optional[int] = None,+        conv_bias: Optional[bool] = None,+        **kwargs,+    ) -> None:+        super().__init__(config=config)++        self.config = config+        self.layer_number = layer_number+        self.attn_mask_type = attn_mask_type+        self.hidden_size = config.hidden_size+        self.kernel_size = int(+            conv_kernel+            if conv_kernel is not None+            else getattr(config, "lfm2_conv_kernel", 3)+        )+        if self.kernel_size < 1:+            raise ValueError("LFM2 short convolution needs a positive kernel size")+        self.use_bias = bool(+            conv_bias if conv_bias is not None else getattr(config, "lfm2_conv_bias", False)+        )++        world_size = getattr(config, "tensor_model_parallel_size", 1)+        # The convolution is depth-wise, so each tensor-parallel rank owns a+        # contiguous slice of channels and needs no extra communication.+        self.hidden_size_per_partition = divide(self.hidden_size, world_size)++        self.in_proj = build_module(+            submodules.in_proj,+            self.hidden_size,+            3 * self.hidden_size,+            config=self.config,+            init_method=self.config.init_method,+            gather_output=False,+            bias=self.use_bias,+            skip_bias_add=False,+            is_expert=False,+            tp_comm_buffer_name="conv_in",+        )++        self.conv = torch.nn.Conv1d(+            in_channels=self.hidden_size_per_partition,+            out_channels=self.hidden_size_per_partition,+            kernel_size=self.kernel_size,+            groups=self.hidden_size_per_partition,+            bias=self.use_bias,+            padding=self.kernel_size - 1,+            dtype=self.config.params_dtype,+        )+        _mark_parallel_channel_weight(self.conv.weight, world_size)+        if self.conv.bias is not None:+            _mark_parallel_channel_weight(self.conv.bias, world_size)++        self.out_proj = build_module(+            submodules.out_proj,+            self.hidden_size,+            self.hidden_size,+            config=self.config,+            init_method=self.config.output_layer_init_method,+            bias=self.use_bias,+            input_is_parallel=True,+            skip_bias_add=True,+            is_expert=False,+            tp_comm_buffer_name="conv_out",+        )++    def _causal_depthwise_conv(self, gated: Tensor) -> Tensor:+        """Apply the causal depth-wise convolution to ``[s, b, h]`` input.++        ``nn.Conv1d`` expects ``[b, c, s]``, so the activation is transposed+        into channel-major layout, convolved with left padding, and the extra+        right-hand taps produced by the padding are dropped to keep the+        operator causal.+        """+        seq_len = gated.shape[0]+        # [s, b, h] -> [b, h, s]+        channel_major = gated.permute(1, 2, 0)+        convolved = self.conv(channel_major)[..., :seq_len]+        # [b, h, s] -> [s, b, h]+        return convolved.permute(2, 0, 1)++    def forward(+        self,+        hidden_states: Tensor,+        attention_mask: Optional[Tensor] = None,+        key_value_states: Optional[Tensor] = None,+        inference_context=None,+        rotary_pos_emb: Optional[Tensor] = None,+        rotary_pos_cos: Optional[Tensor] = None,+        rotary_pos_sin: Optional[Tensor] = None,+        attention_bias: Optional[Tensor] = None,+        packed_seq_params=None,+        sequence_len_offset: Optional[Tensor] = None,+        *,+        inference_params=None,+        **kwargs,+    ) -> Tuple[Tensor, Optional[Tensor]]:+        """Run the gated short convolution over ``[s, b, h]`` activations.++        The attention-specific keyword arguments are accepted so the module is+        interchangeable with ``SelfAttention`` inside ``TransformerLayer``;+        this operator is causal by construction and therefore ignores them.+        """+        projected, _ = self.in_proj(hidden_states)++        # [s, b, 3 * h] -> three [s, b, h] streams, matching the reference+        # chunk over the channel axis of the transposed projection.+        b_stream, c_stream, x_stream = torch.chunk(projected, 3, dim=-1)++        gated = b_stream * x_stream+        convolved = self._causal_depthwise_conv(gated)+        y = c_stream * convolved++        output, bias = self.out_proj(y)+        return output, bias+++def _mark_parallel_channel_weight(param: torch.nn.Parameter, world_size: int) -> None:+    """Tag a depth-wise convolution parameter with Megatron sharding metadata.++    The convolution owns a contiguous slice of the channel axis, so the+    parameter is partitioned along dimension 0 whenever tensor parallelism is+    enabled.  Megatron relies on these attributes when it builds parameter+    groups and when it gathers weights for checkpointing.+    """+    setattr(param, "tensor_model_parallel", world_size > 1)+    setattr(param, "partition_dim", 0)+    setattr(param, "partition_stride", 1)diff --git a/mindspeed_llm/tasks/checkpoint/lfm2_convert.py b/mindspeed_llm/tasks/checkpoint/lfm2_convert.pynew file mode 100644index 0000000000000000000000000000000000000000..535ac1ef20ef7aa3f5000280f3bedbdbe5a4f345--- /dev/null+++ b/mindspeed_llm/tasks/checkpoint/lfm2_convert.py@@ -0,0 +1,447 @@+# Copyright (c) 2025, HUAWEI CORPORATION.  All rights reserved.+"""HF <-> MCore checkpoint conversion for the LFM2 hybrid architecture.++The converter is a standalone command-line tool; it only needs ``torch`` and+``safetensors`` and never initializes Megatron, so it runs on the host without+an accelerator.++Usage::++    python -m mindspeed_llm.tasks.checkpoint.lfm2_convert hf-to-mcore \+        --load-dir <hf-dir> --save-dir <mcore-dir>++    python -m mindspeed_llm.tasks.checkpoint.lfm2_convert mcore-to-hf \+        --load-dir <mcore-dir> --save-dir <hf-dir> --config-dir <hf-dir>++Both directions are exact: every tensor is moved by reshape, split or+concatenation only, so a round trip reproduces the source weights bit for bit.+"""++from __future__ import annotations++import argparse+import json+import os+import shutil+import sys+from pathlib import Path+from typing import Any, Dict, List, Tuple++import torch++_REPO_ROOT = Path(__file__).resolve().parents[3]+if str(_REPO_ROOT) not in sys.path:+    sys.path.insert(0, str(_REPO_ROOT))++from mindspeed_llm.core.models.lfm2.architecture import (  # noqa: E402+    LFM2_CONV_KERNEL,+    get_layer_types,+    is_attention_layer,+)++CHECKPOINT_VERSION = 3.0+TRACKER_FILE = "latest_checkpointed_iteration.txt"+WEIGHTS_FILE = "model.safetensors"+DEFAULT_ITERATION = 1+# Files copied next to the exported weights so the result loads as a model.+CONFIG_FILES = (+    "config.json",+    "generation_config.json",+    "tokenizer.json",+    "tokenizer_config.json",+    "special_tokens_map.json",+    "chat_template.jinja",+)+++class Lfm2Architecture:+    """Resolved geometry of an LFM2 model, derived from its HF config."""++    def __init__(self, config: Dict[str, Any]) -> None:+        self.hidden_size = int(config["hidden_size"])+        self.num_layers = int(config["num_hidden_layers"])+        self.num_attention_heads = int(config["num_attention_heads"])+        self.num_query_groups = int(+            config.get("num_key_value_heads", self.num_attention_heads)+        )+        self.head_dim = int(+            config.get("head_dim", self.hidden_size // self.num_attention_heads)+        )+        self.vocab_size = int(config["vocab_size"])+        self.conv_kernel = int(config.get("conv_L_cache", LFM2_CONV_KERNEL))+        self.conv_bias = bool(config.get("conv_bias", False))+        self.layer_types = get_layer_types(self.num_layers, config.get("layer_types"))++        if self.num_attention_heads % self.num_query_groups != 0:+            raise ValueError(+                "num_attention_heads must be divisible by num_key_value_heads"+            )+        self.heads_per_group = self.num_attention_heads // self.num_query_groups++    @property+    def query_projection_size(self) -> int:+        return self.num_attention_heads * self.head_dim++    @property+    def kv_projection_size(self) -> int:+        return self.num_query_groups * self.head_dim+++def load_hf_config(directory: Path) -> Dict[str, Any]:+    """Read and validate an LFM2 ``config.json``."""+    config = json.loads((directory / "config.json").read_text(encoding="utf-8"))+    model_type = config.get("model_type")+    if model_type != "lfm2":+        raise ValueError(f"expected an lfm2 config, found model_type={model_type!r}")+    return config+++def merge_qkv(+    query: torch.Tensor,+    key: torch.Tensor,+    value: torch.Tensor,+    arch: Lfm2Architecture,+) -> torch.Tensor:+    """Interleave separate Q/K/V projections into MCore's fused layout.++    MCore stores ``linear_qkv`` grouped by query group: for every group the+    rows are ``[q_0 .. q_{n-1}, k, v]``, each of ``head_dim`` rows.+    """+    groups = arch.num_query_groups+    per_group = arch.heads_per_group+    head_dim = arch.head_dim+    hidden = query.shape[-1]++    query = query.reshape(groups, per_group * head_dim, hidden)+    key = key.reshape(groups, head_dim, hidden)+    value = value.reshape(groups, head_dim, hidden)+    fused = torch.cat((query, key, value), dim=1)+    return fused.reshape(groups * (per_group + 2) * head_dim, hidden)+++def split_qkv(+    fused: torch.Tensor, arch: Lfm2Architecture+) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:+    """Inverse of :func:`merge_qkv`."""+    groups = arch.num_query_groups+    per_group = arch.heads_per_group+    head_dim = arch.head_dim+    hidden = fused.shape[-1]++    grouped = fused.reshape(groups, (per_group + 2) * head_dim, hidden)+    query, key, value = torch.split(+        grouped, [per_group * head_dim, head_dim, head_dim], dim=1+    )+    return (+        query.reshape(arch.query_projection_size, hidden),+        key.reshape(arch.kv_projection_size, hidden),+        value.reshape(arch.kv_projection_size, hidden),+    )+++def merge_gate_up(gate: torch.Tensor, up: torch.Tensor) -> torch.Tensor:+    """Fuse the SwiGLU gate and up projections for MCore's ``linear_fc1``.++    MCore chunks ``linear_fc1`` output in two along the channel axis and applies+    SiLU to the first half, so the gate rows come first.+    """+    return torch.cat((gate, up), dim=0)+++def split_gate_up(fused: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor]:+    """Inverse of :func:`merge_gate_up`."""+    gate, up = torch.chunk(fused, 2, dim=0)+    return gate, up+++def hf_to_mcore_state_dict(+    weights: Dict[str, torch.Tensor], arch: Lfm2Architecture+) -> Dict[str, torch.Tensor]:+    """Map HF LFM2 weights onto MCore ``GPTModel`` parameter names."""+    out: Dict[str, torch.Tensor] = {}++    def take(name: str) -> torch.Tensor:+        if name not in weights:+            raise KeyError(f"missing HF tensor: {name}")+        return weights[name]++    # Embeddings are tied to the output projection, so MCore keeps a single+    # shared word-embedding parameter and allocates no output-layer weight.+    out["embedding.word_embeddings.weight"] = take("model.embed_tokens.weight")+    # HF ``embedding_norm`` is the final norm of the decoder stack.+    out["decoder.final_layernorm.weight"] = take("model.embedding_norm.weight")++    for index, layer_type in enumerate(arch.layer_types):+        hf = f"model.layers.{index}"+        mcore = f"decoder.layers.{index}"++        out[f"{mcore}.input_layernorm.weight"] = take(f"{hf}.operator_norm.weight")+        out[f"{mcore}.pre_mlp_layernorm.weight"] = take(f"{hf}.ffn_norm.weight")++        out[f"{mcore}.mlp.linear_fc1.weight"] = merge_gate_up(+            take(f"{hf}.feed_forward.w1.weight"), take(f"{hf}.feed_forward.w3.weight")+        )+        out[f"{mcore}.mlp.linear_fc2.weight"] = take(f"{hf}.feed_forward.w2.weight")++        if is_attention_layer(layer_type):+            out[f"{mcore}.self_attention.linear_qkv.weight"] = merge_qkv(+                take(f"{hf}.self_attn.q_proj.weight"),+                take(f"{hf}.self_attn.k_proj.weight"),+                take(f"{hf}.self_attn.v_proj.weight"),+                arch,+            )+            out[f"{mcore}.self_attention.linear_proj.weight"] = take(+                f"{hf}.self_attn.out_proj.weight"+            )+            out[f"{mcore}.self_attention.q_layernorm.weight"] = take(+                f"{hf}.self_attn.q_layernorm.weight"+            )+            out[f"{mcore}.self_attention.k_layernorm.weight"] = take(+                f"{hf}.self_attn.k_layernorm.weight"+            )+        else:+            out[f"{mcore}.self_attention.in_proj.weight"] = take(+                f"{hf}.conv.in_proj.weight"+            )+            out[f"{mcore}.self_attention.conv.weight"] = take(f"{hf}.conv.conv.weight")+            out[f"{mcore}.self_attention.out_proj.weight"] = take(+                f"{hf}.conv.out_proj.weight"+            )+            if arch.conv_bias:+                out[f"{mcore}.self_attention.conv.bias"] = take(f"{hf}.conv.conv.bias")++    return out+++def mcore_to_hf_state_dict(+    weights: Dict[str, torch.Tensor], arch: Lfm2Architecture+) -> Dict[str, torch.Tensor]:+    """Inverse mapping of :func:`hf_to_mcore_state_dict`."""+    out: Dict[str, torch.Tensor] = {}++    def take(name: str) -> torch.Tensor:+        if name not in weights:+            raise KeyError(f"missing MCore tensor: {name}")+        return weights[name]++    out["model.embed_tokens.weight"] = take("embedding.word_embeddings.weight")+    out["model.embedding_norm.weight"] = take("decoder.final_layernorm.weight")++    for index, layer_type in enumerate(arch.layer_types):+        hf = f"model.layers.{index}"+        mcore = f"decoder.layers.{index}"++        out[f"{hf}.operator_norm.weight"] = take(f"{mcore}.input_layernorm.weight")+        out[f"{hf}.ffn_norm.weight"] = take(f"{mcore}.pre_mlp_layernorm.weight")++        gate, up = split_gate_up(take(f"{mcore}.mlp.linear_fc1.weight"))+        out[f"{hf}.feed_forward.w1.weight"] = gate+        out[f"{hf}.feed_forward.w3.weight"] = up+        out[f"{hf}.feed_forward.w2.weight"] = take(f"{mcore}.mlp.linear_fc2.weight")++        if is_attention_layer(layer_type):+            query, key, value = split_qkv(+                take(f"{mcore}.self_attention.linear_qkv.weight"), arch+            )+            out[f"{hf}.self_attn.q_proj.weight"] = query+            out[f"{hf}.self_attn.k_proj.weight"] = key+            out[f"{hf}.self_attn.v_proj.weight"] = value+            out[f"{hf}.self_attn.out_proj.weight"] = take(+                f"{mcore}.self_attention.linear_proj.weight"+            )+            out[f"{hf}.self_attn.q_layernorm.weight"] = take(+                f"{mcore}.self_attention.q_layernorm.weight"+            )+            out[f"{hf}.self_attn.k_layernorm.weight"] = take(+                f"{mcore}.self_attention.k_layernorm.weight"+            )+        else:+            out[f"{hf}.conv.in_proj.weight"] = take(+                f"{mcore}.self_attention.in_proj.weight"+            )+            out[f"{hf}.conv.conv.weight"] = take(f"{mcore}.self_attention.conv.weight")+            out[f"{hf}.conv.out_proj.weight"] = take(+                f"{mcore}.self_attention.out_proj.weight"+            )+            if arch.conv_bias:+                out[f"{hf}.conv.conv.bias"] = take(f"{mcore}.self_attention.conv.bias")++    return out+++def read_safetensors(path: Path) -> Dict[str, torch.Tensor]:+    """Load every tensor of a safetensors file onto the host."""+    from safetensors.torch import load_file++    return load_file(str(path), device="cpu")+++def write_safetensors(path: Path, weights: Dict[str, torch.Tensor]) -> None:+    """Write tensors to a safetensors file without sharing storage.++    Tensors produced by splitting a fused parameter are views onto the same+    storage, which safetensors rejects, so each tensor is materialized as its+    own contiguous copy.  Copying preserves the exact bit pattern.+    """+    from safetensors.torch import save_file++    detached = {+        key: value.detach().contiguous().clone() for key, value in weights.items()+    }+    save_file(detached, str(path), metadata={"format": "pt"})+++def mcore_checkpoint_path(directory: Path, iteration: int) -> Path:+    """Path of the single-rank (TP=PP=1) MCore checkpoint file."""+    return directory / f"iter_{iteration:07d}" / "mp_rank_00" / "model_optim_rng.pt"+++def read_tracker(directory: Path) -> int:+    """Read the iteration recorded by an MCore checkpoint tracker file."""+    tracker = directory / TRACKER_FILE+    if not tracker.is_file():+        raise FileNotFoundError(f"missing checkpoint tracker: {tracker}")+    raw = tracker.read_text(encoding="utf-8").strip()+    if raw == "release":+        raise ValueError("release checkpoints are not supported by this converter")+    return int(raw)+++def write_mcore_checkpoint(+    directory: Path, weights: Dict[str, torch.Tensor], iteration: int+) -> Path:+    """Write an MCore ``torch``-format checkpoint plus its tracker file.++    The checkpoint intentionally carries no ``args``, optimizer or RNG state:+    it is an initial-weights checkpoint, loaded with ``--finetune``, and+    omitting ``args`` keeps it free of any run-specific configuration.+    """+    target = mcore_checkpoint_path(directory, iteration)+    target.parent.mkdir(parents=True, exist_ok=True)+    state = {+        "model": weights,+        "checkpoint_version": CHECKPOINT_VERSION,+        "iteration": iteration,+    }+    torch.save(state, target)+    (directory / TRACKER_FILE).write_text(f"{iteration}\n", encoding="utf-8")+    return target+++def read_mcore_model(directory: Path) -> Tuple[Dict[str, torch.Tensor], int]:+    """Load the model tensors of a single-rank MCore checkpoint."""+    iteration = read_tracker(directory)+    path = mcore_checkpoint_path(directory, iteration)+    if not path.is_file():+        raise FileNotFoundError(f"missing MCore checkpoint: {path}")+    state = torch.load(path, map_location="cpu", weights_only=False)+    if "model" not in state:+        raise KeyError(f"checkpoint has no model state: {path}")+    return state["model"], iteration+++def filter_model_tensors(model: Dict[str, Any]) -> Dict[str, torch.Tensor]:+    """Drop non-tensor bookkeeping entries such as ``*_extra_state``."""+    return {+        key: value+        for key, value in model.items()+        if isinstance(value, torch.Tensor)+    }+++def copy_config_files(source: Path, destination: Path) -> List[str]:+    """Copy the HF config/tokenizer files that accompany exported weights."""+    copied: List[str] = []+    for name in CONFIG_FILES:+        candidate = source / name+        if candidate.is_file():+            shutil.copyfile(candidate, destination / name)+            copied.append(name)+    return copied+++def convert_hf_to_mcore(load_dir: Path, save_dir: Path, iteration: int) -> None:+    """Convert an HF LFM2 directory into an MCore ``torch`` checkpoint."""+    config = load_hf_config(load_dir)+    arch = Lfm2Architecture(config)+    weights = read_safetensors(load_dir / WEIGHTS_FILE)+    converted = hf_to_mcore_state_dict(weights, arch)+    save_dir.mkdir(parents=True, exist_ok=True)+    target = write_mcore_checkpoint(save_dir, converted, iteration)+    print(+        f"hf-to-mcore: {len(weights)} HF tensors -> {len(converted)} MCore tensors "+        f"({arch.num_layers} layers, "+        f"{sum(1 for item in arch.layer_types if is_attention_layer(item))} attention) "+        f"-> {target}"+    )+++def convert_mcore_to_hf(load_dir: Path, save_dir: Path, config_dir: Path) -> None:+    """Convert an MCore ``torch`` checkpoint back into HF LFM2 layout."""+    config = load_hf_config(config_dir)+    arch = Lfm2Architecture(config)+    model, iteration = read_mcore_model(load_dir)+    converted = mcore_to_hf_state_dict(filter_model_tensors(model), arch)+    save_dir.mkdir(parents=True, exist_ok=True)+    write_safetensors(save_dir / WEIGHTS_FILE, converted)+    copied = copy_config_files(config_dir, save_dir)+    print(+        f"mcore-to-hf: iteration {iteration} -> {len(converted)} HF tensors, "+        f"{len(copied)} config files -> {save_dir / WEIGHTS_FILE}"+    )+++def build_parser() -> argparse.ArgumentParser:+    """Command-line interface of the LFM2 checkpoint converter."""+    parser = argparse.ArgumentParser(+        prog="lfm2_convert",+        description="Convert LFM2 checkpoints between HF and MCore layouts.",+    )+    commands = parser.add_subparsers(dest="command", required=True)++    to_mcore = commands.add_parser(+        "hf-to-mcore", help="convert an HF LFM2 directory into an MCore checkpoint"+    )+    to_mcore.add_argument("--load-dir", required=True, help="HF model directory")+    to_mcore.add_argument("--save-dir", required=True, help="MCore output directory")+    to_mcore.add_argument(+        "--iteration",+        type=int,+        default=DEFAULT_ITERATION,+        help=f"iteration recorded in the checkpoint (default: {DEFAULT_ITERATION})",+    )++    to_hf = commands.add_parser(+        "mcore-to-hf", help="convert an MCore checkpoint back into HF layout"+    )+    to_hf.add_argument("--load-dir", required=True, help="MCore checkpoint directory")+    to_hf.add_argument("--save-dir", required=True, help="HF output directory")+    to_hf.add_argument(+        "--config-dir",+        required=True,+        help="HF directory supplying config.json and tokenizer files",+    )+    return parser+++def main(argv: List[str] | None = None) -> int:+    args = build_parser().parse_args(argv)+    if args.command == "hf-to-mcore":+        if args.iteration < 1:+            raise ValueError("iteration must be positive")+        convert_hf_to_mcore(+            Path(args.load_dir).resolve(),+            Path(args.save_dir).resolve(),+            args.iteration,+        )+    else:+        convert_mcore_to_hf(+            Path(args.load_dir).resolve(),+            Path(args.save_dir).resolve(),+            Path(args.config_dir).resolve(),+        )+    return 0+++if __name__ == "__main__":+    raise SystemExit(main())diff --git a/mindspeed_llm/tasks/models/spec/lfm2_spec.py b/mindspeed_llm/tasks/models/spec/lfm2_spec.pynew file mode 100644index 0000000000000000000000000000000000000000..836a094cc6a5e84c100f9d690cae48c8a5cddcd3--- /dev/null+++ b/mindspeed_llm/tasks/models/spec/lfm2_spec.py@@ -0,0 +1,130 @@+# Copyright (c) 2025, HUAWEI CORPORATION.  All rights reserved.+"""Native MCore layer specification for the LFM2 hybrid architecture.++LFM2 interleaves two kinds of blocks.  Both share the same outer shape - a+pre-operator RMSNorm, the operator, a residual add, then a pre-FFN RMSNorm and a+SwiGLU MLP - but the operator itself is either grouped-query self-attention or a+gated causal short convolution.++``TransformerBlock`` accepts a ``TransformerBlockSubmodules`` with one spec per+block, so this module exposes ``layer_spec`` as such a per-block list instead of+a single fanned-out layer spec.+"""++from megatron.core.fusions.fused_bias_dropout import get_bias_dropout_add+from megatron.core.tensor_parallel import ColumnParallelLinear, RowParallelLinear+from megatron.core.transformer import ModuleSpec, TransformerLayer, TransformerLayerSubmodules+from megatron.core.transformer.attention import SelfAttention, SelfAttentionSubmodules+from megatron.core.transformer.dot_product_attention import DotProductAttention+from megatron.core.transformer.enums import AttnMaskType+from megatron.core.transformer.identity_op import IdentityOp+from megatron.core.transformer.mlp import MLP, MLPSubmodules+from megatron.core.transformer.transformer_block import TransformerBlockSubmodules+from megatron.training import get_args++from mindspeed_llm.core.models.lfm2.architecture import (+    LFM2_CONV_KERNEL,+    get_layer_types,+    is_attention_layer,+)+from mindspeed_llm.core.models.lfm2.short_conv import (+    Lfm2ShortConv,+    Lfm2ShortConvSubmodules,+)+from mindspeed_llm.core.transformer.custom_layers.transformer_engine import PTNorm+++def _mlp_spec() -> ModuleSpec:+    """SwiGLU feed-forward network shared by every LFM2 block."""+    return ModuleSpec(+        module=MLP,+        submodules=MLPSubmodules(+            linear_fc1=ColumnParallelLinear,+            linear_fc2=RowParallelLinear,+        ),+    )+++def _attention_spec(qk_layernorm: bool) -> ModuleSpec:+    """Grouped-query self-attention operator with per-head QK norms."""+    return ModuleSpec(+        module=SelfAttention,+        params={"attn_mask_type": AttnMaskType.causal},+        submodules=SelfAttentionSubmodules(+            linear_qkv=ColumnParallelLinear,+            core_attention=DotProductAttention,+            linear_proj=RowParallelLinear,+            q_layernorm=PTNorm if qk_layernorm else IdentityOp,+            k_layernorm=PTNorm if qk_layernorm else IdentityOp,+        ),+    )+++def _short_conv_spec(conv_kernel: int) -> ModuleSpec:+    """Gated causal short-convolution operator."""+    return ModuleSpec(+        module=Lfm2ShortConv,+        params={"conv_kernel": conv_kernel, "conv_bias": False},+        submodules=Lfm2ShortConvSubmodules(+            in_proj=ColumnParallelLinear,+            out_proj=RowParallelLinear,+        ),+    )+++def _block_spec(operator_spec: ModuleSpec) -> ModuleSpec:+    """Wrap an operator into the common LFM2 block shape."""+    return ModuleSpec(+        module=TransformerLayer,+        submodules=TransformerLayerSubmodules(+            # HF ``operator_norm``: RMSNorm in front of the block operator.+            input_layernorm=PTNorm,+            self_attention=operator_spec,+            self_attn_bda=get_bias_dropout_add,+            # HF ``ffn_norm``: RMSNorm in front of the feed-forward network.+            pre_mlp_layernorm=PTNorm,+            mlp=_mlp_spec(),+            mlp_bda=get_bias_dropout_add,+        ),+    )+++def get_lfm2_block_spec(+    num_layers: int,+    layer_types=None,+    qk_layernorm: bool = True,+    conv_kernel: int = LFM2_CONV_KERNEL,+) -> TransformerBlockSubmodules:+    """Build the per-block specification list for an LFM2 stack.++    Args:+        num_layers: number of blocks in the stack.+        layer_types: explicit ``conv`` / ``full_attention`` pattern; defaults to+            the published pattern for ``num_layers`` blocks.+        qk_layernorm: whether attention blocks normalize queries and keys.+        conv_kernel: short-convolution kernel width.++    Returns:+        ``TransformerBlockSubmodules`` with one layer spec per block and the+        final RMSNorm (HF ``embedding_norm``).+    """+    resolved = get_layer_types(num_layers, layer_types)+    attention_spec = _attention_spec(qk_layernorm)+    conv_spec = _short_conv_spec(conv_kernel)+    return TransformerBlockSubmodules(+        layer_specs=[+            _block_spec(attention_spec if is_attention_layer(item) else conv_spec)+            for item in resolved+        ],+        layer_norm=PTNorm,+    )+++args = get_args()++layer_spec = get_lfm2_block_spec(+    num_layers=args.num_layers,+    layer_types=getattr(args, "lfm2_layer_types", None),+    qk_layernorm=bool(args.qk_layernorm),+    conv_kernel=int(getattr(args, "lfm2_conv_kernel", LFM2_CONV_KERNEL)),+)diff --git a/mindspeed_llm/training/fast_exit.py b/mindspeed_llm/training/fast_exit.pynew file mode 100644index 0000000000000000000000000000000000000000..6e9275abb29f31a1212dff81f3e8223c3eec32e7--- /dev/null+++ b/mindspeed_llm/training/fast_exit.py@@ -0,0 +1,73 @@+# Copyright (c) 2026, HUAWEI CORPORATION.  All rights reserved.+"""Fast process teardown after all training work has completed.++Once the training loop has returned, every semantically required action has+already happened: the requested optimizer updates were applied and logged,+and any requested checkpoint was written and fsynced by ``save_checkpoint``.+What remains before the interpreter exits is pure teardown -- releasing tens+of gigabytes of device memory, running module/tensor finalizers, tearing down+the accelerator context and destroying the process group.  On Ascend that+teardown costs several seconds and contributes nothing to the training result.++This module ends the process immediately after the streams carrying the+training record have been flushed, so the teardown cost is not paid.  The OS+reclaims device memory, the device context and every file descriptor when the+process dies, which is the same reclamation the slow path relies on anyway.+"""++import os+import sys++__all__ = ["exit_after_training", "run_and_exit"]+++def _flush_streams():+    """Flush the streams that carry the training record.++    ``os._exit`` bypasses interpreter shutdown, and therefore bypasses the+    implicit flush of buffered streams.  Megatron already prints every+    iteration line with ``flush=True``, but flushing explicitly here keeps the+    fast path safe for any buffered writer, and keeps a partially buffered+    traceback from being lost on the failure path.+    """+    for stream in (sys.stdout, sys.stderr):+        try:+            stream.flush()+        except Exception:+            # A broken or already-closed stream must not mask the exit code.+            pass+++def exit_after_training(exit_code=0):+    """End the process now, skipping interpreter and accelerator teardown."""+    _flush_streams()+    os._exit(exit_code)+++def run_and_exit(entrypoint, *args, **kwargs):+    """Run ``entrypoint`` and take the fast exit once it has finished.++    Only completed work takes the fast path:++    * a normal return means the training loop finished and ``pretrain`` already+      ran its own finalization (async checkpoint finalize, one-logger finish);+    * ``SystemExit`` is how Megatron leaves the loop when ``--exit-interval``+      fires, and it is raised *after* ``save_checkpoint`` has written and+      fsynced the checkpoint, so the checkpoint is complete on disk.++    Any other exception is left to propagate so the traceback is reported and+    the interpreter exits through the ordinary failure path.+    """+    try:+        entrypoint(*args, **kwargs)+    except SystemExit as stop:+        code = stop.code+        if code is None:+            code = 0+        elif not isinstance(code, int):+            # A string payload is a message, which conventionally means failure.+            _flush_streams()+            raise+        exit_after_training(code)+    else:+        exit_after_training(0)diff --git a/pretrain_gpt.py b/pretrain_gpt.pyindex 5a8506bb3f73e23ca5e1c1e2562d0a861c433cfb..ab3fb390217c435714efc1bf9118a6c9b45c5167 100644--- a/pretrain_gpt.py+++ b/pretrain_gpt.py@@ -36,6 +36,7 @@ from megatron.core.models.gpt.gpt_layer_specs import (     get_gpt_mtp_block_spec, ) from mindspeed_llm.training.utils import set_mtp_batch_list, get_mtp_batch_list, auto_coverage+from mindspeed_llm.training.fast_exit import run_and_exit from mindspeed_llm.core.transformer.multi_token_prediction import generate_mtp_batch_list_on_this_tp_rank  @@ -306,4 +307,7 @@ def main():   if __name__ == "__main__":-    main()+    # ``main`` returns only after the training loop has finished and every+    # requested checkpoint has been written, so the remaining interpreter and+    # device teardown is pure cost. See mindspeed_llm/training/fast_exit.py.+    run_and_exit(main)