Inspect · Source & workspace
Requested workspace inspection and file and log inspection related to source & workspace.
2 calls · #0001–#0002
echo <val>ls -l -a <path> <n> > <path>head -n <n>ls <path>GLM-5.3 · RL
LFM2-1.2B model adapt GRPO 2dev · Model Adaptation
01 / PROCESS MAP
Each row shows one agent’s tool events in its own recorded order. Colors show broad activities; bar widths do not represent duration.
Main agentGLM-5.3 · 201 visible calls
02 / EVENT SEQUENCE
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.
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>.
Requested workspace inspection and file and log inspection related to source & workspace.
2 calls · #0001–#0002
echo <val>ls -l -a <path> <n> > <path>head -n <n>ls <path>Requested file and log inspection and workspace inspection related to task requirements.
3 calls · #0003–#0005
Read <path>find <path> -type <val>sortecho <flag>wc -c <path> <path> <path> <path>Requested file and log inspection related to reward & policy updates.
1 call · #0006–#0006
cd <path><command> <args>cat <val>Requested file and log inspection, environment setup or inspection and source searches related to source & workspace.
10 calls · #0007–#0016
Read <path>envgrep -i <val>head -n <n>echo <flag>ls <path>headgrep -r -n <val> <path> --include <path> -i -lls -l -a <path>cat <path>python3 -c <script> <n> >& <path>tail -n <n>wc -l <path>grep -n <val> <path>Requested script or workload execution related to source & workspace.
1 call · #0017–#0017
date -uecho <val>python3 -c <script>Requested file and log inspection related to source & workspace.
1 call · #0018–#0018
Read <path>Requested runtime inspection and file and log inspection related to device memory.
1 call · #0019–#0019
npu-smi info <n> >& <path>head -n <n>free -gRequested file and log inspection and environment setup or inspection related to attention kernels.
3 calls · #0020–#0022
cd <path>cat > <path> <script>env <vars> timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested workspace file updates, script or workload execution and execution waits related to benchmark & validation setup.
2 calls · #0023–#0024
mkdir -p <path>cd <path>nohup <val> <path> > <path> <n> >& <path>echo <val>sleep <n>tail -n <n> <path>ls <path>tail -c <n> <path>Requested repository inspection, workspace inspection and source searches related to source & workspace.
1 call · #0025–#0025
cd <path>git log --oneline <flag>ls <path>echo <flag>grep -r -n <val> <path>head -n <n>wc -l <path> <n> > <path>Requested workspace inspection and file and log inspection related to rollout generation.
1 call · #0026–#0026
cd <path>find <val> -name <path>xargs <val> -lsort <flag>head -n <n>echo <flag>ls <path> <path> <n> > <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0027–#0027
tail -c <n> <path>echo <val>Requested workspace inspection, runtime inspection and source searches related to device memory.
1 call · #0028–#0028
ls -l -a <path>echo <flag>ps <flag>grep -c <val>date -unpu-smi info <n> >& <path>tail -n <n>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0029–#0029
sleep <n>ls -l -a <path>echo <val>tail -c <n> <path>Requested source searches and file and log inspection related to source & workspace.
1 call · #0030–#0030
cd <path>grep -r -n <val> --include <path> <path>grep -i -v <val>head -n <n>Requested file and log inspection related to benchmark & validation setup.
1 call · #0031–#0031
tail -c <n> <path>echo <val>date -uRequested source searches and file and log inspection related to convolution & sequence boundaries.
1 call · #0032–#0032
cd <path>grep -r -n <val> --include <path> <path>head -n <n>Requested file and log inspection related to benchmark & validation setup.
1 call · #0033–#0033
tail -c <n> <path>sed <path>echo <val>date -uRequested file and log inspection related to convolution & sequence boundaries.
2 calls · #0034–#0035
sed -n <val> <path>echo <val>Requested source searches and file and log inspection related to source & workspace.
1 call · #0036–#0036
grep -n <val> <path>head -n <n>echo <val>sed -n <val> <path>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0037–#0037
grep -n <val> <path>head -n <n>echo <val>date -utail -c <n> <path>sed <path>Requested workspace inspection and file and log inspection related to source & workspace.
2 calls · #0038–#0039
ls -t <path> <n> > <path>headls <path> -d <n> > <path>find <path> -name <val> <flag> <args>head -n <n>ls -t <path>echo <val><command> <args>head <flag>tail -c <n> <val>sed <path>Requested file and log inspection and execution waits related to rollout generation.
2 calls · #0040–#0041
tail -c <n> <path>sed <path>echo <val>sleep <n>date -u<command> <args>head <flag>tail -c <n> <val>Requested script or workload execution, file and log inspection and source searches related to convolution & sequence boundaries.
3 calls · #0042–#0044
python3 -c <script> <n> >& <path>tail -n <n>echo <val>grep -r -n <val> <path>headgrep -r -n <val> -A <n> <path>grep -n <val>cd <path>grep -r -l -n <val> --include <path> <path> <path> <n> > <path>head -n <n>ls <path>sed -n <val> <path>echo <path>grep -n <val> <path>wc -l <path>Requested file and log inspection related to source & workspace.
1 call · #0045–#0045
cd <path>wc -l <path>echo <val>cat <path>Requested file and log inspection related to rollout generation.
1 call · #0046–#0046
cat <path>echo <val>date -utail -c <n> <path>sed <path>Requested source searches, file and log inspection and script or workload execution related to source & workspace.
4 calls · #0047–#0050
grep -n <val> <path>head -n <n>grep -r -n <val> <path>headgrep -r -n <val> <path> <path> <n> > <path>sed -n <val> <path>echo <val>python3 -c <script> <n> >& <path>tail -n <n>date -utail -c <n> <path>sed <path>ls <path>Requested script or workload execution and file and log inspection related to benchmark & validation setup.
1 call · #0051–#0051
cd <path>python3 -c <script>echo <val>head -c <n> <val>echotail -c <n> <val>sed <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0052–#0054
grep -r -n <val> <path> <path>headcat <path>echo <val>grep -r -n <val> <path> --include <path>grep -v <val>sed -n <val> <path>Requested file and log inspection related to attention kernels.
1 call · #0055–#0055
sed -n <val> <path>Requested file and log inspection and source searches related to source & workspace.
3 calls · #0056–#0058
sed -n <val> <path>echo <val>grep -r -n <val> <path> <path>headgrep -r -n <val> <path> --include <path>head -n <n>Requested file and log inspection related to convolution & sequence boundaries.
1 call · #0059–#0059
sed -n <val> <path>echo <val>Requested file and log inspection related to source & workspace.
3 calls · #0060–#0062
sed -n <val> <path>echo <val>cat <path>Requested source searches and file and log inspection related to kv-cache management.
1 call · #0063–#0063
grep -n <val> -A <n> <path>head -n <n>Requested source searches and file and log inspection related to convolution & sequence boundaries.
1 call · #0064–#0064
grep -n <val> -A <n> <path>head -n <n>Requested workspace file updates, file and log inspection and environment setup or inspection related to prefix caching.
1 call · #0065–#0065
mkdir -p <path>cat > <path> <script>cd <path>env <vars> timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested source searches, file and log inspection and workspace inspection related to attention kernels.
2 calls · #0066–#0067
grep -r -n <val> -A <n> <path> <n> > <path>head -n <n>ls <path>grep -r -n <val> -A <n> <path>echo <val>Requested file and log inspection related to source & workspace.
1 call · #0068–#0068
Read <path>Requested code edits related to source & workspace.
1 call · #0069–#0069
Edit <path>Requested environment setup or inspection, source searches and file and log inspection related to source & workspace.
7 calls · #0070–#0076
cd <path>env <vars> timeout <n> <path> <path> <n> >& <path>grep -v <val>tail -n <n>grep -i -E <val>head -n <n>env <vars> timeout <n> <path> <path> > <path> <n> >& <path>echo <val>grep -n <val> <path>sleep <n>tail -n <n> <path>ls -l -a <path>awk <path> <path>sed -n <val> <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0077–#0077
cd <path>nohup <val> <path> > <path> <n> >& <path>echo <val> <val> <flag>Requested source searches and file and log inspection related to source & workspace.
2 calls · #0078–#0079
cd <path>grep -r -n <val> --include <path> <path>head -n <n>sed -n <val> <path>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0080–#0081
cd <path>grep -r -n <val> --include <path> <path>head -n <n>headRequested file and log inspection related to source & workspace.
1 call · #0082–#0082
sed -n <val> <path>Requested file and log inspection related to attention kernels.
1 call · #0083–#0083
sed -n <val> <path>Requested file and log inspection related to source & workspace.
1 call · #0084–#0084
sed -n <val> <path>Requested file and log inspection related to task requirements.
1 call · #0085–#0085
cat <path>echohead -n <n>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0086–#0086
date -uls -t <path> <n> > <path>head -n <n><command> <args>tail -c <n> <val>sed <path>ls <path>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
2 calls · #0087–#0088
sleep <n>date -uls -t <path> <n> > <path>head -n <n><command> <args>tail -c <n> <val>sed <path>tail -c <n> <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0089–#0091
cd <path>grep -r -n <val> --include <path> <path>head -n <n>sed -n <val> <path>echo <val>grep -r -n <val> -A <n> <path>grep -n <val>headgrep -r -n <val> <path> <path>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0092–#0093
cd <path>grep -r -n <val> <path>head -n <n>grep -r -n <val> <path> <path> <n> > <path>echo <val>sed -n <val> <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0094–#0094
date -utail -c <n> <path>sed <path>echo <val>Requested script or workload execution and file and log inspection related to attention kernels.
1 call · #0095–#0095
python3 -c <script> <n> >& <path>tail -n <n>Requested file and log inspection related to source & workspace.
1 call · #0096–#0096
sed -n <val> <path>Requested file and log inspection and workspace inspection related to benchmark & validation setup.
2 calls · #0097–#0098
date -utail -c <n> <path>sed <path>ls <path><command> <args>Requested script or workload execution and file and log inspection related to attention kernels.
1 call · #0099–#0099
cd <path>timeout <n> <path> -c <path> <n> >& <path>tail -n <n>Requested file and log inspection related to source & workspace.
1 call · #0100–#0100
Read <path>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0101–#0101
date -uls <path>tail -c <n> <path>sed <path>Requested source searches, file and log inspection and workspace inspection related to attention kernels.
4 calls · #0102–#0105
grep -n <val> <path>head -n <n>ls <path>grep -r -n <val> <path>sed -n <val> <path>echo <val>Requested workspace inspection, file and log inspection and execution waits related to benchmark & validation setup.
5 calls · #0106–#0110
date -uls <path>tail -c <n> <path>sed <path>sleep <n>cd <path>python3 -c <script>echo <val>tail -c <n> <val>Requested script or workload execution related to reward & policy updates.
1 call · #0111–#0111
cd <path>python3 -c <script>Requested file and log inspection and environment setup or inspection related to source & workspace.
1 call · #0112–#0112
cd <path>cat > <path> <script>env <vars> timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested file and log inspection and environment setup or inspection related to benchmark & validation setup.
1 call · #0113–#0113
cd <path>cat > <path> <script>env <vars> timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested file and log inspection and source searches related to runtime processes.
1 call · #0114–#0114
cat <path>echo <val>grep -n <val> -A <n> <path>head -n <n>Requested file and log inspection and environment setup or inspection related to prefix caching.
1 call · #0115–#0115
cat > <path> <script>cd <path>env <vars> timeout <n> <path> <path> > <path> <n> >& <path>tail -n <n> <path>Requested source searches and file and log inspection related to benchmark & validation setup.
2 calls · #0116–#0117
grep -E <path> <path>tail -n <n>grep -n <val> <path>head -n <n>sed -n <val> <path>sed <path>grep -v <val>Requested runtime inspection, file and log inspection and source searches related to device memory.
1 call · #0118–#0118
npu-smi info <n> >& <path>tail -n <n>ps <flag>grep -c <val>Requested source searches and file and log inspection related to source & workspace.
1 call · #0119–#0119
grep -n <val> <path>grep -i -E <val>head -n <n>echo <flag>sed -n <val> <path>sed <path>tail -n <n>Requested environment setup or inspection, execution waits and source searches related to benchmark & validation setup.
2 calls · #0120–#0121
cd <path>env <vars> nohup <val> <n> <path> <path> > <path> <n> >& <path>sleep <n>grep -E <val> <path>tail -n <n>date -utail -c <n> <path>sed <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0122–#0124
grep -n <val> <path>grep -v <val>head -n <n>sed -n <path> <path>grep -n <val>sed -n <val> <path>sed <path>tail -n <n>Requested source searches, file and log inspection and environment setup or inspection related to benchmark & validation setup.
1 call · #0125–#0125
grep -n <val> <path>tail -n <n>echo <val>cd <path>env <vars> nohup <val> <n> <path> <path> > <path> <n> >& <path>sleep <n>Requested file and log inspection related to convolution & sequence boundaries.
3 calls · #0126–#0128
sed -n <val> <path>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0129–#0129
date -ugrep -E <val> <path>tail -n <n>tail -c <n> <path>sed <path>Requested code edits related to convolution & sequence boundaries.
1 call · #0130–#0130
Edit <path>Requested execution waits, source searches and file and log inspection related to benchmark & validation setup.
1 call · #0131–#0131
sleep <n>date -ugrep -E <val> <path>tail -n <n>tail -c <n> <path>sed <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0132–#0132
cd <path>nohup <val> <path> > <path> <n> >& <path>echo <val> <val> <flag>Requested file and log inspection and source searches related to convolution & sequence boundaries.
1 call · #0133–#0133
cat > <path> <script>grep -n <val> -A <n> <path>head -n <n>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0134–#0135
sed -n <val> <path>echo <val>grep -n <val> -A <n> <path>head -n <n>sed -n <val>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0136–#0136
date -uls -t <path> <n> > <path>head -n <n><command> <args>sed <path>tail -c <n> <path> <n> > <path>Requested file and log inspection related to attention kernels.
1 call · #0137–#0137
cat > <path> <script>echo <val>Requested script or workload execution and source searches related to attention kernels.
2 calls · #0138–#0139
cd <path>python3 - <script><command> <args>grep -c <val> <val>Requested source searches and file and log inspection related to source & workspace.
1 call · #0140–#0140
grep -n <val> <path>head -n <n>Requested script or workload execution and source searches related to source & workspace.
1 call · #0141–#0141
cd <path>python3 - <script>grep -n <val> <path>Requested script or workload execution related to source & workspace.
1 call · #0142–#0142
cd <path>python3 - <script>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0143–#0143
date -uls -t <path> <n> > <path>head -n <n><command> <args>sed <path>ls <path> <n> > <path>Requested script or workload execution, source searches and file and log inspection related to convolution & sequence boundaries.
1 call · #0144–#0144
cd <path>python3 <script>grep -n <val> <path>headRequested file and log inspection and script or workload execution related to attention kernels.
1 call · #0145–#0145
cd <path>cat > <path> <script>timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested file and log inspection related to source & workspace.
2 calls · #0146–#0147
cd <path><command> <args>head -n <n>echo <flag>sed -n <val> <path>Requested script or workload execution and file and log inspection related to attention kernels.
1 call · #0148–#0148
python3 - <script>sed -n <val> <path>echo <val>python3 -c <script>Requested script or workload execution and file and log inspection related to source & workspace.
1 call · #0149–#0149
cd <path>timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0150–#0150
date -uls -t <path> <n> > <path>head -n <n><command> <args>tail -c <n> <val>sed <path>echo <val>tail -c <n> <path>Requested script or workload execution, file and log inspection and process termination related to convolution & sequence boundaries.
1 call · #0151–#0151
cd <path>timeout <n> <path> -c <val> <n> >& <path>tail -n <n>pkill -f <path> <n> > <path>sleep <n>bash <script> > <path> <n> >& <path>npu-smi info <n> >& <path>Requested script or workload execution, execution waits and workspace inspection related to benchmark & validation setup.
2 calls · #0152–#0153
cd <path>nohup <val> <path> > <path> <n> >& <path>sleep <n>echo <val> <val> <flag>ls <path>python3 -c <script>Requested workspace inspection, file and log inspection and source searches related to source & workspace.
2 calls · #0154–#0155
ls <path> <n> > <path>ls <path> <path> <n> > <path>head -n <n>find <path> -name <val>headgrep -n <val> <path>wc -l <path>Requested workspace inspection, file and log inspection and execution waits related to benchmark & validation setup.
2 calls · #0156–#0157
date -uls -t <path> <n> > <path>head -n <n><command> <args>sed <path>tail -c <n> <path>sleep <n>Requested repository inspection, file and log inspection and workspace file updates related to source & workspace.
3 calls · #0158–#0160
<command> <args>cd <val>git status <flag> <args>head -n <n>rm -rf <path> <n> > <path>cd <path>git diff <path>date -uls -t <path> <n> > <path>sed <path>ls <path> <n> > <path>Requested execution waits and file and log inspection related to benchmark & validation setup.
1 call · #0161–#0161
sleep <n>date -utail -c <n> <path>sed <path>tail -n <n>Requested repository inspection and file and log inspection related to source & workspace.
1 call · #0162–#0162
git diff --stat<command> <args>tail -n <n>echo <val>Requested execution waits, file and log inspection and workspace inspection related to benchmark & validation setup.
4 calls · #0163–#0166
sleep <n>date -utail -c <n> <path>sed <path>tail -n <n>ls <path> <n> > <path>grep -c <val> <path> <n> > <path>ls -l -a <path> <n> > <path>Requested script or workload execution related to checkpoints & weight state.
1 call · #0167–#0167
cd <path>python3 -c <script>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0168–#0168
sleep <n>date -uls <path>tr <val> <val>echotail -c <n> <path> <n> > <path>sed <path>tail -n <n>Requested script or workload execution and file and log inspection related to checkpoints & weight state.
1 call · #0169–#0169
cd <path>python3 -c <script> <n> >& <path>head -n <n>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
2 calls · #0170–#0171
sleep <n>date -uls -l -a <path>tail -c <n> <path> <n> > <path>sed <path>tail -n <n>Requested script or workload execution related to checkpoints & weight state.
1 call · #0172–#0172
cd <path>python3 -c <script>Requested file and log inspection, workspace inspection and execution waits related to benchmark & validation setup.
3 calls · #0173–#0175
cd <path>head -c <n> <val>echodate -uls -l -a <val>sleep <n>python3 -c <script> <n> > <path>ls -l -a <val> <val> <n> > <path>tail -c <n> <val>sed <path>tail -n <n>Requested script or workload execution related to checkpoints & weight state.
1 call · #0176–#0176
cd <path>python3 -c <script>Requested script or workload execution related to benchmark & validation setup.
1 call · #0177–#0177
cd <path>nohup <val> <path> > <path> <n> >& <path>echo <val> <val> <flag>Requested file and log inspection related to source & workspace.
1 call · #0178–#0178
cd <path>sed -n <val> <path>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
7 calls · #0179–#0185
sleep <n>date -uls <path> <n> > <path>echo <val>tail -c <n> <path> <n> > <path>sed <path>tail -n <n>ls -l -a <path>grep <val>python3 -c <script>ls <path>tr <val> <val>ls <path> <path> <n> > <path>cd <path>Requested script or workload execution and file and log inspection related to source & workspace.
1 call · #0186–#0186
cd <path>timeout <n> <val> <path> <n> >& <path>tail -n <n>date -uRequested runtime inspection and file and log inspection related to device memory.
1 call · #0187–#0187
npu-smi info <n> >& <path>tail -n <n><command> <args>echo <val>Requested workspace inspection, file and log inspection and workspace file updates related to source & workspace.
1 call · #0188–#0188
ls <path>head -n <n>rm -rf <path>echo <val>cd <path>git diff --statRequested script or workload execution, file and log inspection and source searches related to benchmark & validation setup.
3 calls · #0189–#0191
timeout <n> <path> -m <val> <path> -q -x <flag> <args>tail -n <n>timeout <n> <path> -m <val> <path> -q <flag> <args>grep -E <val>head -n <n>cd <path>python3 -c <script>Requested file and log inspection related to source & workspace.
1 call · #0192–#0192
cd <path>sed -n <val> <path>Requested code edits related to source & workspace.
1 call · #0193–#0193
Edit <path>Requested script or workload execution and repository inspection related to source & workspace.
1 call · #0194–#0194
cd <path>python3 -c <script>git diff --statRequested code edits related to reward & policy updates.
1 call · #0195–#0195
Write <path>Requested environment setup or inspection, workspace inspection and file and log inspection related to device memory.
1 call · #0196–#0196
env <vars>ls <val>cat <path> <n> > <path>headRequested code edits related to device memory.
1 call · #0197–#0197
Write <path>Requested script or workload execution related to checkpoints & weight state.
1 call · #0198–#0198
cd <path>python3 -c <script>date -uRequested repository inspection, environment setup or inspection and file and log inspection related to source & workspace.
2 calls · #0199–#0200
git diff <path>cd <path>env <vars> timeout <n> <path> <path> <n> >& <path>tail -n <n>Requested workspace inspection, file and log inspection and runtime inspection related to device memory.
1 call · #0201–#0201
date -uecho <flag>ls -l -a <path>awk <val>npu-smi info <n> >& <path>grep -c <val>03 / CANDIDATE ARTIFACT
Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.
Base commit: 76b3bd40ca74d26f0c2bffaf42ed01f422fc70f6
@@ -414,6 +414,25 @@ class Lfm2Attention(nn.Module): return output, attn_weights +def packed_sequence_ids(+ position_ids: torch.LongTensor | None, inputs_embeds: torch.Tensor+) -> torch.LongTensor | None:+ """Return which packed sub-sequence every token belongs to, or `None` when unpacked.++ Padding-free / sequence-packed inputs flatten several sequences into a single row and+ restart `position_ids` for each of them. The short-convolution layers are causal and+ depth-wise, so without this information they would read tokens of the previous+ sub-sequence for the first `L_cache - 1` positions of every packed sequence.+ """+ if position_ids is None or inputs_embeds.shape[0] != 1 or inputs_embeds.shape[1] <= 1:+ return None+ starts = torch.diff(position_ids, dim=-1) <= 0+ if not starts.any():+ return None+ ids = torch.cumsum(starts.long(), dim=-1)+ return torch.cat([torch.zeros_like(ids[..., :1]), ids], dim=-1)++ def apply_mask_to_padding_states(hidden_states, attention_mask): """ Tunes out the hidden states for padding tokens, see https://github.com/state-spaces/mamba/issues/66@@ -491,6 +510,7 @@ class Lfm2ShortConv(nn.Module): x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ sequence_ids: torch.LongTensor | None = None, ): seqlen = x.shape[1] @@ -524,22 +544,40 @@ class Lfm2ShortConv(nn.Module): conv_state = nn.functional.pad(Bx, (self.L_cache - Bx.shape[-1], 0)) past_key_values.conv_cache[self.layer_idx].copy_(conv_state) - conv_out = self.conv(Bx)[..., :seqlen]+ if sequence_ids is not None:+ conv_out = self.packed_conv_forward(Bx, sequence_ids)+ else:+ conv_out = self.conv(Bx)[..., :seqlen] y = C * conv_out y = y.transpose(-1, -2).contiguous() y = self.out_proj(y) return y + def packed_conv_forward(self, Bx: torch.Tensor, sequence_ids: torch.LongTensor) -> torch.Tensor:+ """Causal depth-wise convolution that never reads across packed sub-sequences."""+ seqlen = Bx.shape[-1]+ conv_weights = self.conv.weight[:, 0, :]+ conv_out = Bx * conv_weights[:, self.L_cache - 1].unsqueeze(-1)+ for lag in range(1, self.L_cache):+ shifted = nn.functional.pad(Bx, (lag, 0))[..., :seqlen]+ previous = nn.functional.pad(sequence_ids, (lag, 0), value=-1)[..., :seqlen]+ same_sequence = (sequence_ids == previous).to(Bx.dtype).unsqueeze(1)+ conv_out = conv_out + shifted * conv_weights[:, self.L_cache - 1 - lag].unsqueeze(-1) * same_sequence+ if self.bias:+ conv_out = conv_out + self.conv.bias.unsqueeze(-1).to(conv_out.dtype)+ return conv_out+ def forward( self, hidden_states: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ sequence_ids: torch.LongTensor | None = None, ): if is_fast_path_available and "cuda" in hidden_states.device.type and not is_torchdynamo_compiling(): return self.cuda_kernels_forward(hidden_states, past_key_values, attention_mask)- return self.slow_forward(hidden_states, past_key_values, attention_mask)+ return self.slow_forward(hidden_states, past_key_values, attention_mask, sequence_ids) class Lfm2DecoderLayer(GradientCheckpointingLayer):@@ -562,6 +600,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Lfm2HybridConvCache | None = None,+ sequence_ids: torch.LongTensor | None = None, **kwargs, ) -> torch.Tensor: residual = hidden_states@@ -579,6 +618,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): hidden_states=self.operator_norm(hidden_states), past_key_values=past_key_values, attention_mask=attention_mask,+ sequence_ids=sequence_ids, ) hidden_states = hidden_states + residual hidden_states = hidden_states + self.feed_forward(self.ffn_norm(hidden_states))@@ -661,6 +701,8 @@ class Lfm2Model(Lfm2PreTrainedModel): ) # Skip masking for decoding stage. We check shape here to be compile-friendly linear_attention = attention_mask if inputs_embeds.shape[1] != 1 else None+ # Packed (padding-free) inputs must not leak into the short-convolution windows.+ conv_sequence_ids = packed_sequence_ids(position_ids, inputs_embeds) hidden_states = inputs_embeds position_embeddings = self.rotary_emb(hidden_states, position_ids=position_ids)@@ -674,6 +716,7 @@ class Lfm2Model(Lfm2PreTrainedModel): position_embeddings=position_embeddings, position_ids=position_ids, past_key_values=past_key_values,+ sequence_ids=conv_sequence_ids, **kwargs, ) @@ -265,6 +265,25 @@ class Lfm2Attention(LlamaAttention): return output, attn_weights +def packed_sequence_ids(+ position_ids: torch.LongTensor | None, inputs_embeds: torch.Tensor+) -> torch.LongTensor | None:+ """Return which packed sub-sequence every token belongs to, or `None` when unpacked.++ Padding-free / sequence-packed inputs flatten several sequences into a single row and+ restart `position_ids` for each of them. The short-convolution layers are causal and+ depth-wise, so without this information they would read tokens of the previous+ sub-sequence for the first `L_cache - 1` positions of every packed sequence.+ """+ if position_ids is None or inputs_embeds.shape[0] != 1 or inputs_embeds.shape[1] <= 1:+ return None+ starts = torch.diff(position_ids, dim=-1) <= 0+ if not starts.any():+ return None+ ids = torch.cumsum(starts.long(), dim=-1)+ return torch.cat([torch.zeros_like(ids[..., :1]), ids], dim=-1)++ class Lfm2ShortConv(nn.Module): def __init__( self,@@ -326,6 +345,7 @@ class Lfm2ShortConv(nn.Module): x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ sequence_ids: torch.LongTensor | None = None, ): seqlen = x.shape[1] @@ -359,22 +379,40 @@ class Lfm2ShortConv(nn.Module): conv_state = nn.functional.pad(Bx, (self.L_cache - Bx.shape[-1], 0)) past_key_values.conv_cache[self.layer_idx].copy_(conv_state) - conv_out = self.conv(Bx)[..., :seqlen]+ if sequence_ids is not None:+ conv_out = self.packed_conv_forward(Bx, sequence_ids)+ else:+ conv_out = self.conv(Bx)[..., :seqlen] y = C * conv_out y = y.transpose(-1, -2).contiguous() y = self.out_proj(y) return y + def packed_conv_forward(self, Bx: torch.Tensor, sequence_ids: torch.LongTensor) -> torch.Tensor:+ """Causal depth-wise convolution that never reads across packed sub-sequences."""+ seqlen = Bx.shape[-1]+ conv_weights = self.conv.weight[:, 0, :]+ conv_out = Bx * conv_weights[:, self.L_cache - 1].unsqueeze(-1)+ for lag in range(1, self.L_cache):+ shifted = nn.functional.pad(Bx, (lag, 0))[..., :seqlen]+ previous = nn.functional.pad(sequence_ids, (lag, 0), value=-1)[..., :seqlen]+ same_sequence = (sequence_ids == previous).to(Bx.dtype).unsqueeze(1)+ conv_out = conv_out + shifted * conv_weights[:, self.L_cache - 1 - lag].unsqueeze(-1) * same_sequence+ if self.bias:+ conv_out = conv_out + self.conv.bias.unsqueeze(-1).to(conv_out.dtype)+ return conv_out+ def forward( self, hidden_states: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ sequence_ids: torch.LongTensor | None = None, ): if is_fast_path_available and "cuda" in hidden_states.device.type and not is_torchdynamo_compiling(): return self.cuda_kernels_forward(hidden_states, past_key_values, attention_mask)- return self.slow_forward(hidden_states, past_key_values, attention_mask)+ return self.slow_forward(hidden_states, past_key_values, attention_mask, sequence_ids) class Lfm2DecoderLayer(GradientCheckpointingLayer):@@ -397,6 +435,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, past_key_values: Lfm2HybridConvCache | None = None,+ sequence_ids: torch.LongTensor | None = None, **kwargs, ) -> torch.Tensor: residual = hidden_states@@ -414,6 +453,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): hidden_states=self.operator_norm(hidden_states), past_key_values=past_key_values, attention_mask=attention_mask,+ sequence_ids=sequence_ids, ) hidden_states = hidden_states + residual hidden_states = hidden_states + self.feed_forward(self.ffn_norm(hidden_states))@@ -467,6 +507,8 @@ class Lfm2Model(LlamaModel): ) # Skip masking for decoding stage. We check shape here to be compile-friendly linear_attention = attention_mask if inputs_embeds.shape[1] != 1 else None+ # Packed (padding-free) inputs must not leak into the short-convolution windows.+ conv_sequence_ids = packed_sequence_ids(position_ids, inputs_embeds) hidden_states = inputs_embeds position_embeddings = self.rotary_emb(hidden_states, position_ids=position_ids)@@ -480,6 +522,7 @@ class Lfm2Model(LlamaModel): position_embeddings=position_embeddings, position_ids=position_ids, past_key_values=past_key_values,+ sequence_ids=conv_sequence_ids, **kwargs, ) Base commit: f649187194c44d86415d1ddfa49359e824932c9a
@@ -578,7 +578,12 @@ def causal_conv1d_update_npu( out: (batch, dim) or (batch, dim, seqlen) or (num_tokens, dim), same shape as `x` """ weight = weight.transpose(0, 1).contiguous()- conv_state = conv_state.transpose(1, 2).contiguous()+ conv_state = conv_state.transpose(1, 2)+ if conv_state.stride(-1) != 1:+ # The kernel indexes the state through its strides, so only materialize+ # a contiguous copy when the last dimension is not already unit stride.+ # Copying here would duplicate the whole (num_cache_lines, ...) cache.+ conv_state = conv_state.contiguous() if validate_data: assert pad_slot_id is not None assert x.stride(1) == 1@@ -49,6 +49,11 @@ # block size is set to 16 in vLLM which is not supported by Ascend. # How: # Set block size to 128 on npu.+# Hybrid models whose linear-attention state is smaller than one+# attention kernel block (e.g. the short-convolution cache of Lfm2)+# keep the 128-token attention block and pad the mamba page up to the+# attention page instead, which is the layout `_allocate_kv_cache_tensors`+# expects. # Related PR (if no, explain why): # we'll fix this in vLLM soon. # Future Plan:@@ -56,7 +56,12 @@ def verify_and_update_config(cls, vllm_config) -> None: # all cache tensors contiguous, so we align the page size of ssm_block # and single attn_block attn_block_size = kernel_block_size * cdiv(ssm_block_page_size, kernel_block_size * attn_single_token_k_page_size)- assert attn_single_token_k_page_size * attn_block_size == ssm_block_page_size, (+ # Hybrid models whose linear-attention state is smaller than a single+ # attention kernel block (e.g. the short-convolution cache of Lfm2)+ # cannot shrink the attention block below `kernel_block_size`; their+ # mamba page is padded up to the attention page instead.+ attn_block_size = max(attn_block_size, kernel_block_size)+ assert attn_single_token_k_page_size * attn_block_size >= ssm_block_page_size, ( "Cannot align ssm_page_size and attn_page_size." )