GPT-6 Astra · Training

T05 · Training adapt

Valid

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

1.03×PERFORMANCE RATIO
204TOOL 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-6 Astra · 204 visible calls

InspectEditValidateExecuteBuildProfileRollbackOther
115Inspect
11Edit
36Validate
24Execute
11Profile
7Other

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 timeline168 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 and environment setup or inspection related to source & workspace.

    1 call · #0001–#0001

    pwdprintenv <vars>
  2. Inspect · Task requirements

    1 tool error

    Requested source searches and file and log inspection related to task requirements.

    2 calls · #0002–#0003

    rg --files -g <val> -g <path> <path> <path> <n> > <path>cat <path> <path>
  3. Inspect · Dependencies & build setup

    Requested repository inspection, source searches and file and log inspection related to dependencies & build setup.

    1 call · #0004–#0004

    git status --shortrg --files -g <val> -g <val> -g <val> -g <val> -g <val> <args>head -n <n>
  4. Inspect · Task requirements

    Requested tool activity related to task requirements.

    1 call · #0005–#0005

    <command> <args>
  5. Inspect · Dependencies & build setup

    Requested repository inspection, source searches and file and log inspection related to dependencies & build setup.

    1 call · #0006–#0006

    git status --shortrg --files -g <val> -g <val> -g <val> -g <val> -g <val> <args>head -n <n>
  6. Inspect · Task requirements

    Requested file and log inspection and source searches related to task requirements.

    2 calls · #0007–#0008

    cat <path> <path> <path> <path>cat <path> <path>rg --files <path> <path> <path>
  7. Inspect · Source & workspace

    Requested source searches related to source & workspace.

    1 call · #0009–#0009

    rg -n -i <val> <val> <path> <path> <path>
  8. Inspect · Benchmark & validation setup

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

    1 call · #0010–#0010

    cat <path> <path> <path> <path> <path> <path> <path> <path>
  9. Inspect · Convolution & sequence boundaries

    Requested source searches related to convolution & sequence boundaries.

    1 call · #0011–#0011

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

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

    1 call · #0012–#0012

    rg --files <path> <path>printenv <vars>
  11. Inspect · Checkpoints & weight state

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

    1 call · #0013–#0013

    ls <flag> <args>sed -n <val> <path>rg --files <path> <path>head -n <n>
  12. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0014–#0014

    bash <script>
  13. Validate · Benchmark & validation setup

    1 tool error

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

    1 call · #0015–#0015

    bash <script> > <path> <n> >& <path>env <vars>cp <path> <path><command> <args>cat <path>
  14. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    3 calls · #0016–#0018

    sed -n <val> <path>cat <path>
  15. Inspect · Checkpoints & weight state

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

    1 call · #0019–#0019

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

    Requested file and log inspection related to source & workspace.

    1 call · #0020–#0020

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

    Requested file and log inspection related to attention kernels.

    1 call · #0021–#0021

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

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

    3 calls · #0022–#0024

    printenv <vars>cat <path>python - <script>sed -n <val> <path>
  19. Inspect · Checkpoints & weight state

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

    1 call · #0025–#0025

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

    Requested file and log inspection related to source & workspace.

    1 call · #0026–#0026

    sed -n <val> <path>
  21. Inspect · Checkpoints & weight state

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

    1 call · #0027–#0027

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

    1 tool error

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

    1 call · #0028–#0028

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

    Requested file and log inspection related to parallelism & communication.

    1 call · #0029–#0029

    sed -n <val> <path>
  24. Inspect · Checkpoints & weight state

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

    1 call · #0030–#0030

    rg -n <val> <path> <path>sed -n <val> <path>
  25. Edit · Checkpoints & weight state

    Requested code edits related to checkpoints & weight state.

    1 call · #0031–#0031

    Apply patch <patch>
  26. Inspect · Checkpoints & weight state

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

    1 call · #0032–#0032

    python -m <module> -q <path> <script> <script>git diff --statgit status --short
  27. Inspect · Source & workspace

    Requested workspace inspection related to source & workspace.

    1 call · #0033–#0033

    ls -l <path><command> <args>
  28. Inspect · Attention kernels

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

    1 call · #0034–#0034

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

    1 tool error

    Requested tool activity related to source & workspace.

    1 call · #0035–#0035

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

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

    1 call · #0036–#0036

    ps <flag> <args>head -n <n>du <flag> <args>ls -l <path>
  31. Inspect · Optimizer & gradients

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

    1 call · #0037–#0037

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

    Requested workspace inspection related to source & workspace.

    1 call · #0038–#0038

    ls -l <path><command> <args>
  33. Validate · Checkpoints & weight state

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

    1 call · #0039–#0039

    rg --files <path>rg <val>head -n <n>cat <path>rg -n <val> <val> <path>python - <script>
  34. Inspect · Parallelism & communication

    Requested file and log inspection related to parallelism & communication.

    1 call · #0040–#0040

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

    1 tool error

    Requested workspace inspection and runtime inspection related to benchmark & validation setup.

    2 calls · #0041–#0042

    ls -l -h <path> <n> > <path>ps -p <n> -o <val><command> <args>
  36. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0043–#0043

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

    Requested workspace inspection related to benchmark & validation setup.

    1 call · #0044–#0044

    ls -l <path><command> <args>
  38. Edit · Checkpoints & weight state

    Requested code edits related to checkpoints & weight state.

    1 call · #0045–#0045

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

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

    2 calls · #0046–#0047

    <command> <args>tail -n <n> <path>
  40. Inspect · Source & workspace

    2 tool errors

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

    2 calls · #0048–#0049

    sed -n <val> <path>rg --files <path>rg <val>head -n <n>
  41. Validate · Benchmark & validation setup

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

    1 call · #0050–#0050

    tail -n <n> <path><command> <args>
  42. Validate · Checkpoints & weight state

    Requested environment setup or inspection related to checkpoints & weight state.

    1 call · #0051–#0051

    env <vars> python -m <module> -q <script> <flag> <args>
  43. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0052–#0052

    head -n <n> <path>tail -n <n> <path>
  44. Validate · Device memory

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

    1 call · #0053–#0053

    tail -n <n> <path>npu-smi info
  45. Inspect · Benchmark & validation setup

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

    1 call · #0054–#0054

    tail -n <n> <path>
  46. Inspect · Attention kernels

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

    1 call · #0055–#0055

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

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

    1 call · #0056–#0056

    tail -n <n> <path>ps <flag> <args>head -n <n>
  48. Validate · Checkpoints & weight state

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

    1 call · #0057–#0057

    tail -n <n> <path><command> <args>du <flag> <args>
  49. Inspect · Source & workspace

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

    1 call · #0058–#0058

    sed -n <val> <path>rg -n <val> <path> <path>head -n <n>
  50. Validate · Benchmark & validation setup

    Requested tool activity related to benchmark & validation setup.

    1 call · #0059–#0059

    <command> <args>
  51. Inspect · Optimizer & gradients

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

    1 call · #0060–#0060

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

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

    2 calls · #0061–#0062

    <command> <args>ls -l <path>tail -n <n>
  53. Inspect · Benchmark & validation setup

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

    1 call · #0063–#0063

    tail -n <n> <path>
  54. Inspect · Attention kernels

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

    1 call · #0064–#0064

    sed -n <val> <path>rg --files <path>rg <val>
  55. Validate · Benchmark & validation setup

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

    1 call · #0065–#0065

    tail -n <n> <path><command> <args>
  56. Other · Benchmark & validation setup

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

    1 call · #0066–#0066

    mkdir -p <path>env <vars> bash <script>
  57. Inspect · Benchmark & validation setup

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

    1 call · #0067–#0067

    cat <path> <path>git diff --checkgit status --short
  58. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0068–#0068

    sed -n <val> <path>
  59. Edit · Convolution & sequence boundaries

    Requested code edits related to convolution & sequence boundaries.

    1 call · #0069–#0069

    Apply patch <patch>
  60. Execute · Benchmark & validation setup

    Requested workspace inspection related to benchmark & validation setup.

    2 calls · #0070–#0071

    ls -l <path><command> <args>
  61. Inspect · Checkpoints & weight state

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

    1 call · #0072–#0072

    rg -n <val> <path> <path> <path>tail -n <n>sed -n <val> <path>git status --short
  62. Inspect · Benchmark & validation setup

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

    1 call · #0073–#0073

    tail -n <n> <path>
  63. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0074–#0074

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

    Requested source searches related to attention kernels.

    1 call · #0075–#0075

    rg -n <val> <path> <path> <path>
  65. Execute · Benchmark & validation setup

    Requested tool activity related to benchmark & validation setup.

    1 call · #0076–#0076

    <command> <args>
  66. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0077–#0077

    Apply patch <patch>
  67. Execute · Benchmark & validation setup

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

    1 call · #0078–#0078

    ls -l <path>tail -n <n><command> <args>
  68. Inspect · Benchmark & validation setup

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

    1 call · #0079–#0079

    tail -n <n> <path>
  69. Execute · Benchmark & validation setup

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

    3 calls · #0080–#0082

    <command> <args>mkdir -p <path>env <vars> bash <script>
  70. Profile · Source & workspace

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

    2 calls · #0083–#0084

    mkdir -p <path>env <vars> python - <script>head -n <n> <path>tail -n <n> <path>command -v <val>ls -l <path>
  71. Inspect · Runtime processes

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

    1 call · #0085–#0085

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

    Requested file and log inspection related to source & workspace.

    1 call · #0086–#0086

    head -n <n> <path>tail -n <n> <path>
  73. Validate · Convolution & sequence boundaries

    Requested environment setup or inspection related to convolution & sequence boundaries.

    1 call · #0087–#0087

    env <vars> python -m <module> -q <script> <flag> <args>
  74. Inspect · Source & workspace

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

    4 calls · #0088–#0091

    tail -n <n> <path>sed -n <val> <path>rg -n <val> <path>head -n <n>head -n <n> <path>
  75. Profile · Source & workspace

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

    4 calls · #0092–#0095

    tail -n <n> <path>rg --files <path> <n> > <path>head -n <n>python - <script>
  76. Profile · Checkpoints & weight state

    Requested environment setup or inspection related to checkpoints & weight state.

    1 call · #0096–#0096

    env <vars> python - <script>
  77. Profile · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0097–#0097

    python - <script>
  78. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0098–#0098

    tail -n <n> <path>cat <path>tail -n <n>sed -n <val> <path>
  79. Inspect · Runtime processes

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

    1 call · #0099–#0099

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

    Requested file and log inspection related to source & workspace.

    1 call · #0100–#0100

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

    Requested code edits related to source & workspace.

    1 call · #0101–#0101

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

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

    1 call · #0102–#0102

    rg -n <val> <path> <path> <path> <path> <path>sed -n <val> <path>cat <path>
  83. Profile · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0103–#0103

    python - <script>
  84. Validate · Parallelism & communication

    Requested file and log inspection related to parallelism & communication.

    1 call · #0104–#0104

    cat <path>sed -n <val> <path>tail -n <n> <path>tail -n <n> <path> <n> > <path>
  85. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0105–#0105

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

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

    1 call · #0106–#0106

    tail -n <n> <path><command> <args>
  87. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0107–#0107

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

    Requested tool activity related to benchmark & validation setup.

    1 call · #0108–#0108

    <command> <args>
  89. Other · Benchmark & validation setup

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

    1 call · #0109–#0109

    mkdir -p <path>env <vars> bash <script>
  90. Validate · Benchmark & validation setup

    1 tool error

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

    2 calls · #0110–#0111

    <command> <args>mkdir -p <path>env <vars> python -m <module> -q <script> <flag> <args>
  91. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0112–#0112

    head -n <n> <path>tail -n <n> <path>du <flag> <args>
  92. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0113–#0113

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

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0114–#0114

    env <vars> python -m <module> -q <script> <flag> <args>
  94. Inspect · Source & workspace

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

    2 calls · #0115–#0116

    head -n <n> <path>tail -n <n> <path>sed -n <val> <path>git diff <flag> <args>git diff --check
  95. Execute · Benchmark & validation setup

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

    2 calls · #0117–#0118

    ls -l <path>tail -n <n><command> <args>tail -n <n> <path>
  96. Other · Checkpoints & weight state

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

    1 call · #0119–#0119

    python - <script>
  97. Execute · Benchmark & validation setup

    Requested tool activity related to benchmark & validation setup.

    2 calls · #0120–#0121

    <command> <args>
  98. Inspect · Attention kernels

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

    1 call · #0122–#0122

    cat <path>git status --short
  99. Execute · Benchmark & validation setup

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

    2 calls · #0123–#0124

    mkdir -p <path>env <vars> bash <script><command> <args>
  100. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0125–#0125

    Apply patch <patch>
  101. Profile · Parallelism & communication

    1 tool error

    Requested workspace file updates and environment setup or inspection related to parallelism & communication.

    1 call · #0126–#0126

    mkdir -p <path>env <vars> python - <script>
  102. Execute · Benchmark & validation setup

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

    1 call · #0127–#0127

    tail -n <n> <path><command> <args>
  103. Inspect · Source & workspace

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

    1 call · #0128–#0128

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

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

    1 call · #0129–#0129

    tail -n <n> <path><command> <args>
  105. Profile · Parallelism & communication

    Requested workspace file updates and environment setup or inspection related to parallelism & communication.

    1 call · #0130–#0130

    mkdir -p <path>env <vars> python - <script>
  106. Execute · Benchmark & validation setup

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

    1 call · #0131–#0131

    tail -n <n> <path><command> <args>
  107. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0132–#0132

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

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

    1 call · #0133–#0133

    ls -l <path>tail -n <n><command> <args>
  109. Validate · Convolution & sequence boundaries

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

    1 call · #0134–#0134

    mkdir -p <path>cat > <path> <script><command> <args>
  110. Validate · Benchmark & validation setup

    Requested source searches related to benchmark & validation setup.

    1 call · #0135–#0135

    rg <path> <path><command> <args>
  111. Other · Benchmark & validation setup

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

    1 call · #0136–#0136

    mkdir -p <path>env <vars> bash <script>
  112. Validate · Benchmark & validation setup

    Requested tool activity related to benchmark & validation setup.

    1 call · #0137–#0137

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

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

    1 call · #0138–#0138

    tail -n <n> <path>cat <path>
  114. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0139–#0139

    cat <path> <path>
  115. Inspect · Benchmark & validation setup

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

    1 call · #0140–#0140

    cat <path>rg --files <path> <path>
  116. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0141–#0141

    git status --shortgit -C <path> <val> --short
  117. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0142–#0142

    cat <path> <path> <path>
  118. Inspect · Convolution & sequence boundaries

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

    1 call · #0143–#0143

    cat <path> <path>cat <path> <path> <path>
  119. Inspect · Checkpoints & weight state

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

    1 call · #0144–#0144

    cat <path> <path>git diff <flag> <args>
  120. Inspect · Attention kernels

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

    1 call · #0145–#0145

    sed -n <val> <path>rg -n <val> <path>
  121. Inspect · Checkpoints & weight state

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

    1 call · #0146–#0146

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

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

    1 call · #0147–#0147

    tail -n <n> <path>rg --files <path>
  123. Inspect · Attention kernels

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

    1 call · #0148–#0148

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

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

    3 calls · #0149–#0151

    cat <path>rg -n <val> <path>tail -n <n> <path>ps <flag> <args>rg <val>head -n <n>
  125. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0152–#0152

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

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

    1 call · #0153–#0153

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

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

    1 call · #0154–#0154

    rg -n <val> <path>tail -n <n>tail -n <n> <path>
  128. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0155–#0155

    sed -n <val> <path>
  129. Validate · Precision & numerical checks

    Requested script or workload execution related to precision & numerical checks.

    1 call · #0156–#0156

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

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

    3 calls · #0157–#0159

    tail -n <n> <path>rg --files <path>rg <val>du <flag> <args>
  131. Execute · Benchmark & validation setup

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

    3 calls · #0160–#0162

    mkdir -p <path>env <vars> bash <script> > <path> <n> >& <path>tail -n <n> <path>test <val> -f <path>cat <path>env <vars> python <script> > <path> <n> >& <path>
  132. Edit · Checkpoints & weight state

    Requested code edits related to checkpoints & weight state.

    1 call · #0163–#0163

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

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

    1 call · #0164–#0164

    tail -n <n> <path>
  134. Inspect · Attention kernels

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

    1 call · #0165–#0165

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

    Requested file and log inspection related to parallelism & communication.

    1 call · #0166–#0166

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

    Requested file and log inspection related to attention kernels.

    1 call · #0167–#0167

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

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

    1 call · #0168–#0168

    git diff --checkgit -C <path> <val> --checkpython - <script>
  138. Validate · Checkpoints & weight state

    Requested environment setup or inspection related to checkpoints & weight state.

    1 call · #0169–#0169

    env <vars> python -m <module> <flag> <args>
  139. Inspect · Attention kernels

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

    1 call · #0170–#0170

    tail -n <n> <path>git -C <path> <val> --shortgit status --short
  140. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0171–#0171

    env <vars> python -m <module> -q <script> > <path> <n> >& <path>
  141. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0172–#0172

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

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

    1 call · #0173–#0173

    rg --files <path>git diff --numstatsed -n <val> <path>rg -n <val> <path> <path> <path>
  143. Validate · Benchmark & validation setup

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

    2 calls · #0174–#0175

    python - <script>rg --files <path>tail -n <n> <path>test <val> -f <path>cat <path>
  144. Inspect · Benchmark & validation setup

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

    1 call · #0176–#0176

    rg -n <val> <path>tail -n <n>tail -n <n> <path>
  145. Execute · Benchmark & validation setup

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

    1 call · #0177–#0177

    python - <script>
  146. Validate · Benchmark & validation setup

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

    1 call · #0178–#0178

    mkdir -p <path>env <vars> bash <script> > <path> <n> >& <path>
  147. Inspect · Benchmark & validation setup

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

    2 calls · #0179–#0180

    cat <path>rg --files <path>tail -n <n> <path>
  148. Inspect · Source & workspace

    Requested source searches related to source & workspace.

    1 call · #0181–#0181

    rg --files <flag> <args>rg <path>sort -u
  149. Inspect · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0182–#0182

    python - <script>
  150. Inspect · Attention kernels

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

    1 call · #0183–#0183

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

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

    1 call · #0184–#0184

    rg --files <path>rg <val>tail -n <n> <path>
  152. Inspect · Attention kernels

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

    1 call · #0185–#0185

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

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

    1 call · #0186–#0186

    tail -n <n> <path>
  154. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0187–#0187

    python - <script>
  155. Inspect · Checkpoints & weight state

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

    1 call · #0188–#0188

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

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

    1 call · #0189–#0189

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

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

    2 calls · #0190–#0191

    tail -n <n> <path>rg --files <path>rg <val>rg --files <val> -g <val>rg <path>sed -n <val> <path>
  158. Validate · Benchmark & validation setup

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

    1 call · #0192–#0192

    mkdir -p <path>env <vars> bash <script> > <path> <n> >& <path>
  159. Inspect · Benchmark & validation setup

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

    1 call · #0193–#0193

    tail -n <n> <path>
  160. Execute · Benchmark & validation setup

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

    1 call · #0194–#0194

    python - <script>
  161. Validate · Benchmark & validation setup

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

    2 calls · #0195–#0196

    env <vars> python -B <script>python - <script>cat <path>
  162. Inspect · Benchmark & validation setup

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

    1 call · #0197–#0197

    tail -n <n> <path>
  163. Execute · Benchmark & validation setup

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

    1 call · #0198–#0198

    tail -n <n> <path>test <val> -f <path>
  164. Inspect · Benchmark & validation setup

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

    1 call · #0199–#0199

    tail -n <n> <path>
  165. Execute · Benchmark & validation setup

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

    2 calls · #0200–#0201

    bash <script> > <path> <n> >& <path>python - <script>
  166. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0202–#0202

    bash <script> > <path> <n> >& <path>
  167. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0203–#0203

    git diff --checkgit status --shortgit -C <path> <val> --checkgit -C <path> <val> --short
  168. Validate · Task requirements

    Requested file and log inspection and script or workload execution related to task requirements.

    1 call · #0204–#0204

    cat <path>python - <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 · 2 changed files

Base commit: df2ea7fad8e43016b0e2edbf7ce16026496df2ae

diff --git a/mindspeed/ops/npu_vocab_cross_entropy.py b/mindspeed/ops/npu_vocab_cross_entropy.pynew file mode 100644index 0000000000000000000000000000000000000000..636948f40307ad14bbaca330affc9f11d060b935--- /dev/null+++ b/mindspeed/ops/npu_vocab_cross_entropy.py@@ -0,0 +1,21 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""FP32 vocabulary loss for an unsharded language-model output."""++import torch_npu+++def npu_vocab_cross_entropy(logits, target):+    """Return FP32 per-token cross entropy for valid, unsharded vocabulary IDs.++    Keep the loss and its backward calculation in FP32 even when the model+    produces BF16 logits. Autograd casts the final logits gradient back to the+    model dtype. Sharded vocabularies and smoothing use MCore's distributed loss.+    """+    if logits.shape[:-1] != target.shape or logits.shape[-1] < 1:+        raise ValueError("Expected one target for every nonempty logit row")+    loss, _, _, _ = torch_npu.npu_cross_entropy_loss(+        logits.float().reshape(-1, logits.shape[-1]),+        target.reshape(-1),+        reduction="none",+    )+    return loss.view_as(target)diff --git a/mindspeed/ops/test_npu_vocab_cross_entropy.py b/mindspeed/ops/test_npu_vocab_cross_entropy.pynew file mode 100644index 0000000000000000000000000000000000000000..79a00e458c9688431f74ce549376c88c47a973a3--- /dev/null+++ b/mindspeed/ops/test_npu_vocab_cross_entropy.py@@ -0,0 +1,44 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""Loss and gradient checks for the unsharded fused vocabulary loss."""++import pytest+import torch+import torch.nn.functional as F+import torch_npu++from mindspeed.ops.npu_vocab_cross_entropy import npu_vocab_cross_entropy+++pytestmark = pytest.mark.skipif(not torch_npu.npu.is_available(), reason="Requires one Ascend device")+++@pytest.mark.parametrize("vocab", [123, 8193, 65536])+@pytest.mark.parametrize("dtype", [torch.float32, torch.bfloat16])+def test_loss_and_logits_gradient(vocab, dtype):+    torch.manual_seed(57)+    logits = (torch.randn(4, 2, vocab, device="npu") * 3).to(dtype).requires_grad_()+    original = logits.detach().clone()+    reference = logits.detach().float().requires_grad_()+    target = torch.randint(vocab, (4, 2), device="npu")+    target[0, 0] = 0+    target[0, 1] = vocab - 1+    expected = F.cross_entropy(reference.flatten(0, 1), target.flatten(), reduction="none").view_as(target)+    actual = npu_vocab_cross_entropy(logits, target)+    torch.testing.assert_close(actual, expected, rtol=2e-5, atol=2e-5)+    gradient = torch.randn_like(expected)+    expected.backward(gradient)+    actual.backward(gradient)+    torch.testing.assert_close(logits.grad, reference.grad.to(dtype), rtol=4e-3, atol=2e-5)+    torch.testing.assert_close(logits, original, rtol=0, atol=0)+++def test_noncontiguous_inputs():+    logits = torch.randn(2, 3, 257, device="npu").transpose(0, 1).requires_grad_()+    reference = logits.detach().clone().requires_grad_()+    target = torch.tensor([[0, 1, 256], [25, 37, 100]], device="npu").transpose(0, 1)+    expected = F.cross_entropy(reference.reshape(-1, 257), target.reshape(-1), reduction="none").view_as(target)+    actual = npu_vocab_cross_entropy(logits, target)+    torch.testing.assert_close(actual, expected, rtol=2e-5, atol=2e-5)+    expected.sum().backward()+    actual.sum().backward()+    torch.testing.assert_close(logits.grad, reference.grad, rtol=4e-4, atol=2e-5)
mindspeed_llm · 9 changed files

Base commit: 72c49a6260c73669678b8f39b1ba41a4789bb555

diff --git a/mindspeed_llm/core/models/lfm2/README.md b/mindspeed_llm/core/models/lfm2/README.mdnew file mode 100644index 0000000000000000000000000000000000000000..5799cc9ceda0c59e83e16cba67f931df33d1c5c1--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/README.md@@ -0,0 +1,53 @@+# LFM2.5 native MCore training++The `mindspeed_llm.tasks.models.spec.lfm2_spec:layer_spec` specification builds+the 16-layer LFM2.5-1.2B hybrid decoder with attention at zero-based layers+2, 5, 8, 10, 12, and 14. The other layers use `LFM2ShortConv`. Both layer types+use pre-operator RMSNorm, a residual connection, pre-MLP RMSNorm, and a SwiGLU+MLP. The final RMSNorm and tied embedding/output weights use the normal GPT+model interfaces. Full-layer activation recomputation and checkpointing are+provided by MCore.++The GPT pretraining entrypoint selects `LFM2GPTModel` for this specification.+It uses the native NPU fused cross-entropy operator for an unsharded output,+with FP32 loss arithmetic and the usual MCore loss mask and token reduction.+Other devices and explicitly selected MCore loss implementations retain the+base GPT loss path.++Training uses width 2048, 32 query heads, 8 KV heads, head width 64, MLP width+8192, a 65536-token vocabulary, and RoPE base 1000000. The HF intermediate+width of 12288 is adjusted to 8192 by its `block_auto_adjust_ff_dim` setting.+Use the local transformer implementation with RMSNorm, QK normalization,+SwiGLU, no linear bias, and tied embeddings. The supplied block specification+is for one pipeline stage; short convolution currently requires TP=CP=1 and+unpacked sequences. Incremental convolution inference is not implemented.++The convolution projection is ordered `[B, C, x]` and computes+`out_proj(C * causal_depthwise_conv(B * x))`. Gates have no activation. The+kernel's last weight multiplies the current token, and left history is zero+at each sequence boundary. The module consumes and returns MCore's+`[sequence, batch, hidden]` layout.++Convert the checkpoint from the MindSpeed-LLM source root:++```sh+python mindspeed_llm/tasks/checkpoint/lfm2_convert.py hf-to-mcore \+    --load-dir /path/to/hf --save-dir /path/to/mcore+python mindspeed_llm/tasks/checkpoint/lfm2_convert.py mcore-to-hf \+    --load-dir /path/to/mcore --save-dir /path/to/export --config-dir /path/to/hf+```++The converter writes iteration 1 in the standard `torch` MCore checkpoint+format. Load this initial checkpoint with `--finetune --no-load-optim+--no-load-rng`. Resume a training checkpoint using normal MCore loading,+including its optimizer, scheduler, consumed samples, and RNG state.+QKV is packed by query group; MLP gate and up projections are concatenated in+that order. Conversion preserves tensor dtypes and values and supports+exporting model weights from a normal training checkpoint.++Focused tests are in `test_short_conv.py` (one Ascend device) and+`mindspeed_llm/tasks/checkpoint/test_lfm2_convert.py` (CPU conversion and HF+loading). The fused loss and its gradients are covered by+`MindSpeed/mindspeed/ops/test_npu_vocab_cross_entropy.py` (one Ascend device).+Run them with `python -m pytest --import-mode=importlib` followed by the test+path.diff --git a/mindspeed_llm/core/models/lfm2/__init__.py b/mindspeed_llm/core/models/lfm2/__init__.pynew file mode 100644index 0000000000000000000000000000000000000000..09715cf423e2c2d0c0117f3c37338ea3d643cafa--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/__init__.py@@ -0,0 +1,2 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""Native Megatron Core building blocks for LFM2 hybrid language models."""diff --git a/mindspeed_llm/core/models/lfm2/gpt_model.py b/mindspeed_llm/core/models/lfm2/gpt_model.pynew file mode 100644index 0000000000000000000000000000000000000000..6d48938d1e137adde7b1415fcb0544845439d86b--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/gpt_model.py@@ -0,0 +1,20 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""LFM2's native MCore GPT model with a fused, unsharded NPU loss."""++from megatron.core.models.gpt import GPTModel+from mindspeed.ops.npu_vocab_cross_entropy import npu_vocab_cross_entropy+++class LFM2GPTModel(GPTModel):+    """Keep MCore model/checkpoint behavior while fusing FP32 vocabulary loss."""++    def compute_language_model_loss(self, labels, logits):+        if (+            logits.device.type == "npu"+            and self.config.tensor_model_parallel_size == 1+            and not self.config.cross_entropy_loss_fusion+        ):+            # MCore's loss mask and token reduction are applied by the caller.+            loss = npu_vocab_cross_entropy(logits, labels.transpose(0, 1))+            return loss.transpose(0, 1).contiguous()+        return super().compute_language_model_loss(labels, logits)diff --git a/mindspeed_llm/core/models/lfm2/short_conv.py b/mindspeed_llm/core/models/lfm2/short_conv.pynew file mode 100644index 0000000000000000000000000000000000000000..2c2076b6cd54e25d1154a9bf05e8bd3b4dbadc27--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/short_conv.py@@ -0,0 +1,77 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""LFM2's input-gated, depthwise causal convolution in MCore's SBH layout."""++import torch+from torch import nn++from megatron.core.tensor_parallel.layers import ColumnParallelLinear, RowParallelLinear+from megatron.core.transformer.module import MegatronModule+++class LFM2ShortConv(MegatronModule):+    """A short-convolution mixer with the same interface as MCore self-attention.++    The projection contains B, C, and x in that order. The mixer computes+    ``out_proj(C * causal_conv(B * x))``; neither gate has an activation.+    Convolution history is local to each training sequence.+    """++    def __init__(self, config, layer_number=1, kernel_size=3, bias=False):+        super().__init__(config=config)+        if config.tensor_model_parallel_size != 1 or config.context_parallel_size != 1:+            raise ValueError("LFM2 short convolution currently requires TP=CP=1")+        if config.sequence_parallel:+            raise ValueError("LFM2 short convolution does not support sequence parallelism")+        if kernel_size < 1:+            raise ValueError("The convolution kernel size must be positive")+        self.layer_number = layer_number+        self.kernel_size = kernel_size+        self.in_proj = ColumnParallelLinear(+            config.hidden_size,+            3 * config.hidden_size,+            config=config,+            init_method=config.init_method,+            gather_output=False,+            bias=bias,+            skip_bias_add=False,+        )+        self.conv = nn.Conv1d(+            config.hidden_size,+            config.hidden_size,+            kernel_size,+            groups=config.hidden_size,+            padding=kernel_size - 1,+            bias=bias,+            dtype=config.params_dtype,+            device="cpu" if config.use_cpu_initialization else torch.cuda.current_device(),+        )+        self.out_proj = RowParallelLinear(+            config.hidden_size,+            config.hidden_size,+            config=config,+            init_method=config.output_layer_init_method,+            input_is_parallel=True,+            bias=bias,+            skip_bias_add=True,+        )++    def forward(+        self,+        hidden_states,+        attention_mask=None,+        inference_context=None,+        packed_seq_params=None,+        *,+        inference_params=None,+        **kwargs,+    ):+        if inference_context is not None or inference_params is not None:+            raise NotImplementedError("Incremental LFM2 convolution inference is not supported")+        if packed_seq_params is not None:+            raise NotImplementedError("LFM2 convolution requires unpacked training sequences")+        projected, _ = self.in_proj(hidden_states)+        gate_b, gate_c, value = projected.chunk(3, dim=-1)+        gated_value = (gate_b * value).permute(1, 2, 0).contiguous()+        convolved = self.conv(gated_value)[..., :hidden_states.shape[0]]+        mixed = gate_c * convolved.permute(2, 0, 1)+        return self.out_proj(mixed.contiguous())diff --git a/mindspeed_llm/core/models/lfm2/test_short_conv.py b/mindspeed_llm/core/models/lfm2/test_short_conv.pynew file mode 100644index 0000000000000000000000000000000000000000..f41198fee44fe1ae287e29a9f088424902f6254d--- /dev/null+++ b/mindspeed_llm/core/models/lfm2/test_short_conv.py@@ -0,0 +1,79 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""One-device forward/backward parity with the public HF short-convolution block."""++import pytest+import torch+import torch.distributed as dist+import torch_npu++from mindspeed_llm import megatron_adaptor  # noqa: F401+from megatron.core import parallel_state+from megatron.core.tensor_parallel.random import model_parallel_cuda_manual_seed+from megatron.core.transformer.transformer_config import TransformerConfig+from megatron.training.arguments import parse_args+from megatron.training.global_vars import set_args+from transformers import Lfm2Config+from transformers.models.lfm2.modeling_lfm2 import Lfm2ShortConv as HFShortConv++from mindspeed_llm.core.models.lfm2.short_conv import LFM2ShortConv+++@pytest.fixture(scope="module", autouse=True)+def single_rank(tmp_path_factory):+    if not torch_npu.npu.is_available():+        pytest.skip("An Ascend device is required")+    args = parse_args(ignore_unknown_args=True)+    set_args(args)+    torch_npu.npu.set_device(0)+    rendezvous = tmp_path_factory.mktemp("lfm2-dist") / "store"+    dist.init_process_group("hccl", init_method=rendezvous.as_uri(), rank=0, world_size=1)+    parallel_state.initialize_model_parallel()+    model_parallel_cuda_manual_seed(101)+    yield+    torch_npu.npu.synchronize()+    parallel_state.destroy_model_parallel()+    dist.destroy_process_group()+++@pytest.mark.parametrize("dtype,sequence,batch,bias", [+    (torch.float32, 9, 2, True),+    (torch.bfloat16, 256, 1, False),+    (torch.bfloat16, 1, 2, False),+])+def test_hf_forward_and_gradients(dtype, sequence, batch, bias):+    config = TransformerConfig(+        num_layers=1, hidden_size=64, num_attention_heads=4,+        params_dtype=dtype, bf16=dtype == torch.bfloat16,+        gradient_accumulation_fusion=False,+    )+    reference = HFShortConv(Lfm2Config(hidden_size=64, conv_L_cache=3, conv_bias=bias), 0).npu().to(dtype)+    native = LFM2ShortConv(config, bias=bias).npu().to(dtype)+    native.load_state_dict(reference.state_dict())+    x = (torch.randn(batch, sequence, 64, device="npu", dtype=dtype) * 0.1).requires_grad_()+    x_native = x.detach().transpose(0, 1).contiguous().requires_grad_()+    expected = reference(x)+    output, output_bias = native(x_native)+    actual = (output if output_bias is None else output + output_bias).transpose(0, 1)+    tolerance = 2e-3 if dtype == torch.bfloat16 else 2e-5+    torch.testing.assert_close(actual, expected, rtol=tolerance, atol=tolerance)+    gradient = torch.randn_like(expected)+    expected.backward(gradient)+    actual.backward(gradient)+    torch.testing.assert_close(x_native.grad.transpose(0, 1), x.grad, rtol=tolerance, atol=tolerance)+    for name, param in native.named_parameters():+        torch.testing.assert_close(param.grad, dict(reference.named_parameters())[name].grad,+                                   rtol=tolerance, atol=tolerance)+++def test_no_future_or_cross_batch_leakage():+    config = TransformerConfig(num_layers=1, hidden_size=64, num_attention_heads=4,+                               gradient_accumulation_fusion=False)+    model = LFM2ShortConv(config).npu()+    x = torch.randn(13, 2, 64, device="npu")+    changed = x.clone()+    changed[7:, 0] += 1+    with torch.no_grad():+        original, _ = model(x)+        altered, _ = model(changed)+    torch.testing.assert_close(original[:7, 0], altered[:7, 0], rtol=0, atol=0)+    torch.testing.assert_close(original[:, 1], altered[:, 1], rtol=0, atol=0)diff --git a/mindspeed_llm/tasks/checkpoint/lfm2_convert.py b/mindspeed_llm/tasks/checkpoint/lfm2_convert.pynew file mode 100644index 0000000000000000000000000000000000000000..450d91a28a89670a8e78bd4911b4d163a3be81f1--- /dev/null+++ b/mindspeed_llm/tasks/checkpoint/lfm2_convert.py@@ -0,0 +1,230 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""Lossless HF <-> native MCore conversion for single-rank LFM2 checkpoints.++Example::++    python lfm2_convert.py hf-to-mcore --load-dir HF --save-dir MCORE+    python lfm2_convert.py mcore-to-hf --load-dir MCORE --save-dir HF_OUT --config-dir HF++Conversion operates on CPU tensors and does not initialize the training runtime.+Training checkpoints retain the normal MCore optimizer, scheduler, and RNG state.+"""++import argparse+import json+import shutil+from pathlib import Path++import torch+from safetensors.torch import load_file, save_file+++def _dimensions(config):+    if config.get("model_type") != "lfm2":+        raise ValueError("Expected an LFM2 Hugging Face configuration")+    width = config["hidden_size"]+    heads = config["num_attention_heads"]+    groups = config["num_key_value_heads"]+    head_dim = config.get("head_dim", width // heads)+    if heads % groups or width % heads:+        raise ValueError("LFM2 attention dimensions must divide evenly")+    kinds = config["layer_types"]+    if len(kinds) != config["num_hidden_layers"]:+        raise ValueError("layer_types does not match num_hidden_layers")+    if any(kind not in ("conv", "full_attention") for kind in kinds):+        raise ValueError("Unsupported LFM2 layer type")+    ffn = config["intermediate_size"]+    if config.get("block_auto_adjust_ff_dim", True):+        ffn = int(2 * ffn / 3)+        multiplier = config.get("block_ffn_dim_multiplier", 1.0)+        if multiplier is not None:+            ffn = int(multiplier * ffn)+            multiple = config.get("block_multiple_of", 256)+            ffn = multiple * ((ffn + multiple - 1) // multiple)+    return width, heads, groups, head_dim, ffn+++def _mapping(config):+    """Return one-to-one names and their expected shapes; fused weights are separate."""+    width, heads, groups, head_dim, ffn = _dimensions(config)+    result = {+        "model.embed_tokens.weight": ("embedding.word_embeddings.weight", (config["vocab_size"], width)),+        "model.embedding_norm.weight": ("decoder.final_layernorm.weight", (width,)),+    }+    for index, kind in enumerate(config["layer_types"]):+        hf = f"model.layers.{index}."+        mc = f"decoder.layers.{index}."+        result[hf + "operator_norm.weight"] = (mc + "input_layernorm.weight", (width,))+        result[hf + "ffn_norm.weight"] = (mc + "pre_mlp_layernorm.weight", (width,))+        result[hf + "feed_forward.w2.weight"] = (mc + "mlp.linear_fc2.weight", (width, ffn))+        if kind == "conv":+            for name, shape in (+                ("in_proj", (3 * width, width)),+                ("conv", (width, 1, config["conv_L_cache"])),+                ("out_proj", (width, width)),+            ):+                result[hf + f"conv.{name}.weight"] = (mc + f"self_attention.{name}.weight", shape)+                if config.get("conv_bias", False):+                    result[hf + f"conv.{name}.bias"] = (mc + f"self_attention.{name}.bias", (shape[0],))+        else:+            result[hf + "self_attn.out_proj.weight"] = (+                mc + "self_attention.linear_proj.weight", (width, heads * head_dim)+            )+            for name in ("q_layernorm", "k_layernorm"):+                result[hf + f"self_attn.{name}.weight"] = (mc + f"self_attention.{name}.weight", (head_dim,))+    return result+++def _tensor(state, name, shape):+    tensor = state[name]+    if not isinstance(tensor, torch.Tensor) or tuple(tensor.shape) != tuple(shape):+        raise ValueError(f"Invalid shape for {name}; expected {shape}")+    return tensor+++def hf_to_mcore_state(state, config):+    """Pack group-interleaved QKV and gate/up MLP projections without dtype changes."""+    width, heads, groups, head_dim, ffn = _dimensions(config)+    mapping = _mapping(config)+    result = {mc: _tensor(state, hf, shape) for hf, (mc, shape) in mapping.items()}+    used = set(mapping)+    for index, kind in enumerate(config["layer_types"]):+        hf = f"model.layers.{index}."+        mc = f"decoder.layers.{index}."+        names = [hf + f"feed_forward.{name}.weight" for name in ("w1", "w3")]+        result[mc + "mlp.linear_fc1.weight"] = torch.cat([_tensor(state, name, (ffn, width)) for name in names])+        used.update(names)+        if kind == "full_attention":+            names = [hf + f"self_attn.{name}_proj.weight" for name in ("q", "k", "v")]+            q = _tensor(state, names[0], (heads * head_dim, width)).reshape(groups, -1, width)+            k, v = [+                _tensor(state, name, (groups * head_dim, width)).reshape(groups, head_dim, width)+                for name in names[1:]+            ]+            result[mc + "self_attention.linear_qkv.weight"] = torch.cat((q, k, v), dim=1).reshape(-1, width)+            used.update(names)+    tied_embeddings = config.get("tie_word_embeddings", config.get("tie_embedding", True))+    if not tied_embeddings and "lm_head.weight" not in state:+        raise ValueError("Untied LFM2 checkpoint is missing lm_head.weight")+    if "lm_head.weight" in state:+        head = _tensor(state, "lm_head.weight", (config["vocab_size"], width))+        if tied_embeddings:+            if not torch.equal(head, state["model.embed_tokens.weight"]):+                raise ValueError("Tied LFM2 output and embedding weights differ")+        else:+            result["output_layer.weight"] = head+        used.add("lm_head.weight")+    if used != set(state):+        raise ValueError(f"Unmapped HF tensors: {sorted(set(state) - used)}")+    return result+++def mcore_to_hf_state(state, config, include_lm_head=False):+    """Unpack a native model state, including model states saved after training."""+    width, heads, groups, head_dim, ffn = _dimensions(config)+    result = {hf: _tensor(state, mc, shape).contiguous() for hf, (mc, shape) in _mapping(config).items()}+    for index, kind in enumerate(config["layer_types"]):+        hf = f"model.layers.{index}."+        mc = f"decoder.layers.{index}."+        fc1 = _tensor(state, mc + "mlp.linear_fc1.weight", (2 * ffn, width))+        for name, tensor in zip(("w1", "w3"), fc1.chunk(2, dim=0)):+            result[hf + f"feed_forward.{name}.weight"] = tensor.contiguous()+        if kind == "full_attention":+            qkv = _tensor(state, mc + "self_attention.linear_qkv.weight", ((heads + 2 * groups) * head_dim, width))+            qkv = qkv.reshape(groups, -1, width)+            q, k, v = qkv.split((heads // groups * head_dim, head_dim, head_dim), dim=1)+            for name, tensor in zip(("q", "k", "v"), (q, k, v)):+                result[hf + f"self_attn.{name}_proj.weight"] = tensor.reshape(-1, width).contiguous()+    tied_embeddings = config.get("tie_word_embeddings", config.get("tie_embedding", True))+    if not tied_embeddings and "output_layer.weight" not in state:+        raise ValueError("Untied LFM2 checkpoint is missing output_layer.weight")+    if "output_layer.weight" in state:+        result["lm_head.weight"] = _tensor(state, "output_layer.weight", (config["vocab_size"], width)).contiguous()+    elif include_lm_head:+        result["lm_head.weight"] = result["model.embed_tokens.weight"].clone()+    return result+++def _load_hf(directory):+    index = directory / "model.safetensors.index.json"+    if index.exists():+        files = sorted(set(json.loads(index.read_text())["weight_map"].values()))+    else:+        files = ["model.safetensors"]+    state = {}+    for filename in files:+        shard = load_file(str(directory / filename), device="cpu")+        if state.keys() & shard.keys():+            raise ValueError("Duplicate tensors in HF shards")+        state.update(shard)+    return state+++def convert_hf_to_mcore(load_dir, save_dir):+    config = json.loads((load_dir / "config.json").read_text())+    state = _load_hf(load_dir)+    model = hf_to_mcore_state(state, config)+    width, heads, groups, head_dim, ffn = _dimensions(config)+    checkpoint_args = argparse.Namespace(+        num_layers=config["num_hidden_layers"], hidden_size=width, ffn_hidden_size=ffn,+        num_attention_heads=heads, num_query_groups=groups, kv_channels=head_dim,+        padded_vocab_size=config["vocab_size"], tensor_model_parallel_size=1,+        pipeline_model_parallel_size=1, context_parallel_size=1,+        add_position_embedding=False, position_embedding_type="rope",+        normalization="RMSNorm", norm_epsilon=config.get("norm_eps", 1e-5),+        swiglu=True, add_bias_linear=False, qk_layernorm=True,+        untie_embeddings_and_output_weights="output_layer.weight" in model,+        consumed_train_samples=0, consumed_valid_samples=0,+    )+    path = save_dir / "iter_0000001" / "mp_rank_00" / "model_optim_rng.pt"+    path.parent.mkdir(parents=True, exist_ok=True)+    torch.save({+        "checkpoint_version": 3.0, "iteration": 1, "args": checkpoint_args,+        "model": model, "lfm2_config": config, "lfm2_hf_keys": sorted(state),+        "num_floating_point_operations_so_far": 0,+    }, path)+    (save_dir / "latest_checkpointed_iteration.txt").write_text("1\n")+++def convert_mcore_to_hf(load_dir, save_dir, config_dir):+    config = json.loads((config_dir / "config.json").read_text())+    iteration = (load_dir / "latest_checkpointed_iteration.txt").read_text().strip()+    dirname = "release" if iteration == "release" else f"iter_{int(iteration):07d}"+    path = load_dir / dirname / "mp_rank_00" / "model_optim_rng.pt"+    checkpoint = torch.load(path, map_location="cpu", weights_only=False)+    checkpoint_args = checkpoint.get("args")+    parallel_sizes = ("tensor_model_parallel_size", "pipeline_model_parallel_size")+    if any(getattr(checkpoint_args, name, 1) != 1 for name in parallel_sizes):+        raise ValueError("LFM2 conversion currently requires TP=PP=1 checkpoints")+    state = mcore_to_hf_state(checkpoint["model"], config, "lm_head.weight" in checkpoint.get("lfm2_hf_keys", ()))+    save_dir.mkdir(parents=True, exist_ok=True)+    save_file(state, str(save_dir / "model.safetensors"), metadata={"format": "pt"})+    metadata_files = (+        "config.json", "generation_config.json", "tokenizer.json",+        "tokenizer_config.json", "special_tokens_map.json",+    )+    for name in metadata_files:+        source = config_dir / name+        if source.is_file() and source.resolve() != (save_dir / name).resolve():+            shutil.copyfile(source, save_dir / name)+++def main():+    parser = argparse.ArgumentParser(description=__doc__)+    parser.add_argument("direction", choices=("hf-to-mcore", "mcore-to-hf"))+    parser.add_argument("--load-dir", type=Path, required=True)+    parser.add_argument("--save-dir", type=Path, required=True)+    parser.add_argument("--config-dir", type=Path)+    args = parser.parse_args()+    # Small concatenations should not start a full machine's worth of CPU threads.+    torch.set_num_threads(4)+    if args.direction == "hf-to-mcore":+        convert_hf_to_mcore(args.load_dir, args.save_dir)+    else:+        if args.config_dir is None:+            parser.error("mcore-to-hf requires --config-dir")+        convert_mcore_to_hf(args.load_dir, args.save_dir, args.config_dir)+++if __name__ == "__main__":+    main()diff --git a/mindspeed_llm/tasks/checkpoint/test_lfm2_convert.py b/mindspeed_llm/tasks/checkpoint/test_lfm2_convert.pynew file mode 100644index 0000000000000000000000000000000000000000..db767056fb023a0dea035578be8e9a30e8a4a079--- /dev/null+++ b/mindspeed_llm/tasks/checkpoint/test_lfm2_convert.py@@ -0,0 +1,108 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""CPU tests for the standalone checkpoint converter (no training runtime needed)."""++import importlib.util+from pathlib import Path++import pytest+import torch+import torch.nn.functional as F+from transformers import Lfm2Config, Lfm2ForCausalLM+++spec = importlib.util.spec_from_file_location("lfm2_convert", Path(__file__).with_name("lfm2_convert.py"))+converter = importlib.util.module_from_spec(spec)+spec.loader.exec_module(converter)+++@pytest.fixture+def hf_model():+    torch.manual_seed(29)+    config = Lfm2Config(+        hidden_size=32,+        intermediate_size=64,+        num_hidden_layers=2,+        num_attention_heads=4,+        num_key_value_heads=2,+        vocab_size=128,+        layer_types=["conv", "full_attention"],+        block_auto_adjust_ff_dim=False,+        conv_L_cache=3,+    )+    return Lfm2ForCausalLM(config)+++def test_all_weights_roundtrip(hf_model):+    state = hf_model.state_dict()+    config = hf_model.config.to_dict()+    native = converter.hf_to_mcore_state(state, config)+    restored = converter.mcore_to_hf_state(native, config, include_lm_head=True)+    assert state.keys() == restored.keys()+    for key in state:+        assert torch.equal(state[key], restored[key]), key+++def test_native_projections_match_hf(hf_model):+    native = converter.hf_to_mcore_state(hf_model.state_dict(), hf_model.config.to_dict())+    x = torch.randn(7, 2, 32)+    attn = hf_model.model.layers[1].self_attn+    qkv = F.linear(x, native["decoder.layers.1.self_attention.linear_qkv.weight"])+    # MCore consumes one [Q heads, K head, V head] group at a time.+    q, k, v = qkv.reshape(7, 2, 2, 32).split((16, 8, 8), dim=-1)+    for actual, expected in ((q.reshape(7, 2, 32), attn.q_proj(x)),+                             (k.reshape(7, 2, 16), attn.k_proj(x)),+                             (v.reshape(7, 2, 16), attn.v_proj(x))):+        torch.testing.assert_close(actual, expected)+    gate, up = F.linear(x, native["decoder.layers.1.mlp.linear_fc1.weight"]).chunk(2, dim=-1)+    output = F.linear(F.silu(gate) * up, native["decoder.layers.1.mlp.linear_fc2.weight"])+    torch.testing.assert_close(output, hf_model.model.layers[1].feed_forward(x))+++def test_bf16_biased_conv_and_untied_head(hf_model):+    config = hf_model.config.to_dict()+    config.update(conv_bias=True, tie_word_embeddings=False)+    model = Lfm2ForCausalLM(Lfm2Config(**config)).bfloat16()+    state = model.state_dict()+    native = converter.hf_to_mcore_state(state, config)+    restored = converter.mcore_to_hf_state(native, config)+    assert state.keys() == restored.keys()+    for key in state:+        assert restored[key].dtype == torch.bfloat16+        assert torch.equal(state[key], restored[key]), key+++def test_conversion_rejects_unmapped_or_invalid_weights(hf_model):+    config = hf_model.config.to_dict()+    state = hf_model.state_dict()+    with pytest.raises(ValueError, match="Unmapped HF"):+        converter.hf_to_mcore_state({**state, "unexpected.weight": torch.ones(1)}, config)+    state["model.layers.1.self_attn.k_proj.weight"] = torch.ones(8, 32)+    with pytest.raises(ValueError, match="Invalid shape"):+        converter.hf_to_mcore_state(state, config)+++def test_untied_checkpoint_requires_output_weights(hf_model):+    config = hf_model.config.to_dict()+    config["tie_word_embeddings"] = False+    state = dict(hf_model.state_dict())+    native = converter.hf_to_mcore_state(state, config)+    del state["lm_head.weight"]+    with pytest.raises(ValueError, match="missing lm_head.weight"):+        converter.hf_to_mcore_state(state, config)+    del native["output_layer.weight"]+    with pytest.raises(ValueError, match="missing output_layer.weight"):+        converter.mcore_to_hf_state(native, config)+++def test_checkpoint_files_are_loadable(hf_model, tmp_path):+    hf, mc, restored = (tmp_path / name for name in ("hf", "mcore", "restored"))+    hf_model.save_pretrained(hf)+    converter.convert_hf_to_mcore(hf, mc)+    assert (mc / "latest_checkpointed_iteration.txt").read_text().strip() == "1"+    checkpoint = torch.load(mc / "iter_0000001/mp_rank_00/model_optim_rng.pt", weights_only=False)+    assert checkpoint["iteration"] == 1+    assert checkpoint["checkpoint_version"] == 3.0+    converter.convert_mcore_to_hf(mc, restored, hf)+    loaded = Lfm2ForCausalLM.from_pretrained(restored)+    for key, value in hf_model.state_dict().items():+        assert torch.equal(value, loaded.state_dict()[key]), keydiff --git a/mindspeed_llm/tasks/models/spec/lfm2_spec.py b/mindspeed_llm/tasks/models/spec/lfm2_spec.pynew file mode 100644index 0000000000000000000000000000000000000000..e25661476c77b711f9e65f180df1c21a754c278c--- /dev/null+++ b/mindspeed_llm/tasks/models/spec/lfm2_spec.py@@ -0,0 +1,63 @@+# Copyright (c) 2026, Huawei Technologies Co., Ltd. All rights reserved.+"""Native MCore layer specification for LiquidAI/LFM2.5-1.2B-Base."""++from megatron.core.fusions.fused_bias_dropout import get_bias_dropout_add+from megatron.core.models.gpt.gpt_layer_specs import get_mlp_module_spec+from megatron.core.tensor_parallel.layers import ColumnParallelLinear, RowParallelLinear+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.spec_utils import ModuleSpec+from megatron.core.transformer.transformer_block import TransformerBlockSubmodules+from megatron.core.transformer.transformer_layer import TransformerLayer, TransformerLayerSubmodules++from mindspeed_llm.core.models.lfm2.short_conv import LFM2ShortConv+from mindspeed_llm.core.transformer.custom_layers.transformer_engine import PTNorm+++LFM2_LAYER_TYPES = (+    "conv", "conv", "full_attention", "conv",+    "conv", "full_attention", "conv", "conv",+    "full_attention", "conv", "full_attention", "conv",+    "full_attention", "conv", "full_attention", "conv",+)+++def get_lfm2_layer_spec(layer_type, kernel_size=3, conv_bias=False):+    """Build one pre-normalized LFM2 decoder layer using native MCore modules."""+    if layer_type == "full_attention":+        mixer = ModuleSpec(+            module=SelfAttention,+            params={"attn_mask_type": AttnMaskType.causal},+            submodules=SelfAttentionSubmodules(+                linear_qkv=ColumnParallelLinear,+                core_attention=DotProductAttention,+                linear_proj=RowParallelLinear,+                q_layernorm=PTNorm,+                k_layernorm=PTNorm,+            ),+        )+    elif layer_type == "conv":+        mixer = ModuleSpec(+            module=LFM2ShortConv,+            params={"kernel_size": kernel_size, "bias": conv_bias},+        )+    else:+        raise ValueError(f"Unsupported LFM2 layer type: {layer_type}")+    return ModuleSpec(+        module=TransformerLayer,+        submodules=TransformerLayerSubmodules(+            input_layernorm=PTNorm,+            self_attention=mixer,+            self_attn_bda=get_bias_dropout_add,+            pre_mlp_layernorm=PTNorm,+            mlp=get_mlp_module_spec(use_te=False),+            mlp_bda=get_bias_dropout_add,+        ),+    )+++layer_spec = TransformerBlockSubmodules(+    layer_specs=[get_lfm2_layer_spec(kind) for kind in LFM2_LAYER_TYPES],+    layer_norm=PTNorm,+)diff --git a/pretrain_gpt.py b/pretrain_gpt.pyindex 5a8506bb3f73e23ca5e1c1e2562d0a861c433cfb..64882dec4f9d33b20bc9c28905ff358244d65606 100644--- a/pretrain_gpt.py+++ b/pretrain_gpt.py@@ -74,7 +74,13 @@ def model_provider(pre_process=True, post_process=True) -> Union[GPTModel, megat         if args.mtp_num_layers is not None:             mtp_block_spec = get_gpt_mtp_block_spec(config, transformer_layer_spec, use_transformer_engine=use_te) -        model = GPTModel(+        model_class = GPTModel+        if args.spec is not None and args.spec[0] == "mindspeed_llm.tasks.models.spec.lfm2_spec":+            from mindspeed_llm.core.models.lfm2.gpt_model import LFM2GPTModel++            model_class = LFM2GPTModel++        model = model_class(             config=config,             transformer_layer_spec=transformer_layer_spec,             vocab_size=args.padded_vocab_size,