Inspect · Task requirements
Requested environment setup or inspection and file and log inspection related to task requirements.
1 call · #0001–#0001
printenv <vars>sed -n <val> <path>GPT-5.6 Sol · 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 agentGPT-5.6 Sol · 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 environment setup or inspection and file and log inspection related to task requirements.
1 call · #0001–#0001
printenv <vars>sed -n <val> <path>Requested environment setup or inspection and source searches related to source & workspace.
1 call · #0002–#0002
envrg <val>sortRequested file and log inspection related to reward & policy updates.
1 call · #0003–#0003
sed -n <val> <path>Requested repository inspection, source searches and file and log inspection related to source & workspace.
4 calls · #0004–#0007
git status --shortgit rev-parse <flag> <args>rg -n <val> <path> <path> -g <path>head -n <n>rg -n <val> <val> -g <path>rg -n <val> <val> <val> -g <path> -g <val> -g <val>Requested file and log inspection related to benchmark & validation setup.
1 call · #0008–#0008
sed -n <val> <path>Requested workspace inspection, file and log inspection and environment setup or inspection related to source & workspace.
1 call · #0009–#0009
find <val> -maxdepth <n> -type <val> <flag> <args>sortfind <path> -maxdepth <n> -type <val> <flag> <args>head -n <n>envrg <val>Requested workspace inspection, runtime inspection and file and log inspection related to device memory.
1 call · #0010–#0010
find <val> -maxdepth <n> -type <val> <flag> <args>sortps <flag> <args>head -n <n>npu-smi info <n> > <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0011–#0011
tail -n <n> <path>Requested source searches and file and log inspection related to checkpoints & weight state.
1 call · #0012–#0012
rg -n <val> <path>sed -n <val>Requested file and log inspection and script or workload execution related to source & workspace.
1 call · #0013–#0013
jq <path> <path>python3 - <script>Requested file and log inspection and workspace inspection related to benchmark & validation setup.
1 call · #0014–#0014
tail -n <n> <path>find <val> -path <path> -type <val> <flag> <args>sort <flag>head -n <n>Requested file and log inspection related to source & workspace.
2 calls · #0015–#0016
sed -n <val> <path>Requested file and log inspection related to attention kernels.
1 call · #0017–#0017
sed -n <val> <path>Requested source searches and file and log inspection related to convolution & sequence boundaries.
1 call · #0018–#0018
rg -n <val> <val> <val> -g <path> -g <val> -g <val> -g <val>sed -n <val>Requested repository inspection related to source & workspace.
3 calls · #0019–#0021
git log <flag> <args>Requested repository inspection related to attention kernels.
1 call · #0022–#0022
git log <flag> <args>Requested file and log inspection and runtime inspection related to device memory.
1 call · #0023–#0023
tail -n <n> <path>npu-smi info <n> > <path>tail -n <n>Requested file and log inspection, runtime inspection and workspace inspection related to benchmark & validation setup.
2 calls · #0024–#0025
tail -n <n> <path>sed -n <path>ps <flag> <args>head -n <n>stat -c <val> <path>rg -v <val>tail -n <n>Requested script or workload execution related to benchmark & validation setup.
1 call · #0026–#0026
bash <script>Requested file and log inspection and source searches related to kv-cache management.
4 calls · #0027–#0030
sed -n <val> <path>rg -n <val> <path> <path> -g <path>head -n <n>rg -n <val> <path>rg -n <val> <path> -g <path> <path> -g <path>Requested source searches, file and log inspection and workspace inspection related to attention kernels.
1 call · #0031–#0031
rg -n <val> <val> -g <path>head -n <n>find <val> -iname <val> -o -iname <val>sortRequested code edits related to source & workspace.
1 call · #0032–#0032
Apply patch <patch>Requested runtime inspection, source searches and repository inspection related to source & workspace.
2 calls · #0033–#0034
ps <flag> <args>rg <val>rg -v <val>git diff <flag> <args><command> <args>head -n <n>Requested runtime inspection, file and log inspection and repository inspection related to device memory.
1 call · #0035–#0035
ps -p <n> -o <val>truenpu-smi info <n> > <path>tail -n <n>git status --shortRequested script or workload execution related to prefix caching.
1 call · #0036–#0036
python3 - <script>Requested execution waits and runtime inspection related to source & workspace.
1 call · #0037–#0037
<command> <args>sleep <n>ps -p <n> -o <val>trueRequested workspace inspection, file and log inspection and source searches related to benchmark & validation setup.
1 call · #0038–#0038
stat -c <val> <path>tail -n <n> <path>rg -v <val>tail -n <n>Requested file and log inspection related to convolution & sequence boundaries.
1 call · #0039–#0039
sed -n <val> <path>Requested file and log inspection, source searches and workspace inspection related to device memory.
1 call · #0040–#0040
tail -n <n> <path>rg -v <val>tail -n <n>stat -c <val> <path>npu-smi info <n> > <path>Requested file and log inspection, source searches and workspace inspection related to benchmark & validation setup.
1 call · #0041–#0041
tail -n <n> <path>rg -v <val>tail -n <n>stat -c <val> <path>Requested file and log inspection, source searches and workspace inspection related to device memory.
3 calls · #0042–#0044
tail -n <n> <path>rg <val>tail -n <n>stat -c <val> <path>ps <flag> <args>head -n <n>Requested file and log inspection, source searches and workspace inspection related to device memory.
1 call · #0045–#0045
tail -n <n> <path>rg <val>tail -n <n>stat -c <val> <path>npu-smi info <n> > <path>Requested file and log inspection and workspace inspection related to benchmark & validation setup.
1 call · #0046–#0046
tail -n <n> <path>stat -c <val> <path>Requested runtime inspection, file and log inspection and workspace inspection related to device memory.
1 call · #0047–#0047
ps <flag> <args>head -n <n>npu-smi info <n> > <path>stat -c <val> <path>Requested file and log inspection, runtime inspection and source searches related to benchmark & validation setup.
1 call · #0048–#0048
tail -n <n> <path>ps <flag> <args>rg <val>head -n <n>Requested file and log inspection, workspace inspection and runtime inspection related to benchmark & validation setup.
1 call · #0049–#0049
tail -n <n> <path>stat -c <val> <path>ps -p <n> -o <val>trueRequested file and log inspection, source searches and workspace inspection related to checkpoints & weight state.
1 call · #0050–#0050
tail -n <n> <path>rg <val>tail -n <n>stat -c <val> <path>find <path> -maxdepth <n> -type <val> <flag> <args>head -n <n>Requested script or workload execution related to benchmark & validation setup.
1 call · #0051–#0051
bash <script>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0052–#0052
ls -l -h <val>jq <path> <path>sed -n <val> <path>Requested script or workload execution, source searches and file and log inspection related to reward & policy updates.
1 call · #0053–#0053
python - <script>rg -n <val> <path> <path> <path>head -n <n>Requested script or workload execution, workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0054–#0054
python - <script>find <path> -maxdepth <n> -type <val> <val> -iname <path> -o -iname <path> <args>sorthead -n <n>rg -n <val> <path> <path>Requested script or workload execution, file and log inspection and source searches related to reward & policy updates.
2 calls · #0055–#0056
python - <script>sed -n <val> <path>rg -n <val> <path> -g <path>head -n <n>find <path> -type <val> -path <val>sortRequested file and log inspection related to task requirements.
1 call · #0057–#0057
sed -n <val> <path>Requested source searches and file and log inspection related to reward & policy updates.
1 call · #0058–#0058
rg -n <val> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> -g <path>Requested file and log inspection and source searches related to source & workspace.
3 calls · #0059–#0061
sed -n <val> <path>rg -n <val> <path> <path> -g <path>head -n <n>rg -n <val> <path>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0062–#0063
rg -n <val> <path> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> <path> -g <path>rg -n <val> <path>tail -n <n>Requested file and log inspection and source searches related to source & workspace.
1 call · #0064–#0064
sed -n <val> <path>rg -n <val> <path> -g <path>rg -n <val> <path>head -n <n>Requested file and log inspection and source searches related to runtime processes.
1 call · #0065–#0065
sed -n <val> <path>sed -n <val> <path> <n> > <path>head -n <n>rg -n <val> <path> -g <path>rg -n <val> <path>Requested source searches and file and log inspection related to source & workspace.
5 calls · #0066–#0070
rg -n <val> <path> -g <path>sed -n <val> <path> <n> > <path>sed -n <val> <path>rg -n <val> <path> -C <n>rg -n <val> <path>rg -n <val> <path> <path> -g <path>head -n <n>Requested file and log inspection, source searches and script or workload execution related to reward & policy updates.
2 calls · #0071–#0072
jq <val> <path>rg -n <val> <path> <path>python - <script>sed -n <val> <path>rg -n <val> <path> <path> <path> -g <val> -g <path>head -n <n>Requested source searches and file and log inspection related to reward & policy updates.
2 calls · #0073–#0074
rg -n <val> <path> <path> -g <path>head -n <n>sed -n <val> <path>rg -n <val> <path> -g <val>Requested file and log inspection and source searches related to source & workspace.
1 call · #0075–#0075
head -n <n> <path>rg -n <val> <path> <path> <path> <path> -g <path> -g <val>head -n <n>Requested code edits related to reward & policy updates.
1 call · #0076–#0076
Apply patch <patch>Requested repository inspection and file and log inspection related to reward & policy updates.
1 call · #0077–#0077
git -C <path> <val> <flag> <args>sed -n <val> <path>Requested code edits related to source & workspace.
1 call · #0078–#0078
Apply patch <patch>Requested source searches and file and log inspection related to source & workspace.
1 call · #0079–#0079
rg -n <val> <val> <val> -g <path> -g <val>head -n <n>rg -n <val> <path>sed -n <val> <val>Requested script or workload execution related to source & workspace.
1 call · #0080–#0080
python <script> --files <script> <flag>Requested script or workload execution, workspace inspection and file and log inspection related to dependencies & build setup.
1 call · #0081–#0081
command -v <val>python -V<command> <args>truefind <path> -type <val> -name <val> <n> > <path>head -n <n>python -m <module> <val> <val> <n> > <path>Requested script or workload execution related to dependencies & build setup.
1 call · #0082–#0082
python -m <module> <val> <val>Requested repository inspection, file and log inspection and source searches related to convolution & sequence boundaries.
1 call · #0083–#0083
git status --shortgit diff --statgit diff <flag> <args>head -n <n>rg -n <val> <path> <path>Requested script or workload execution related to source & workspace.
2 calls · #0084–#0085
python <script> --files <script> <flag><command> <args>Requested repository inspection, source searches and workspace inspection related to convolution & sequence boundaries.
1 call · #0086–#0086
git status --shortgit diff --statrg -n <val> <path> <path>find <path> -maxdepth <n> -name <val> <flag>Requested workspace inspection, file and log inspection and runtime inspection related to source & workspace.
3 calls · #0087–#0089
ls -l <path>head -n <n> <path>ps <flag>rg <val>rg -v <val>truepython <script> --helpsed -n <val> <path>find <path> -maxdepth <n> -type <val> -name <val> -o -name <val>head -n <n>command -v <val><command> <args>find <path> -maxdepth <n> -type <val> -name <val> <flag>Requested source searches and file and log inspection related to dependencies & build setup.
1 call · #0090–#0090
rg -n <val> <val> <path> <val>head -n <n>rg -n <val> <path> <val> <val>Requested script or workload execution related to dependencies & build setup.
1 call · #0091–#0091
python -m <module> <val> <val>Requested code edits related to source & workspace.
1 call · #0092–#0092
Apply patch <patch>Requested script or workload execution related to source & workspace.
1 call · #0093–#0093
python <script> --files <script> <flag> <args>Requested repository inspection and file and log inspection related to source & workspace.
2 calls · #0094–#0095
git status --shortgit diff --statgit diff <flag> <args>sed -n <val>sed -n <val> <path>Requested environment setup or inspection related to attention kernels.
1 call · #0096–#0096
env <vars> python - <script>env <vars> python <script> --files <script> <flag> <args>Requested repository inspection, file and log inspection and source searches related to source & workspace.
1 call · #0097–#0097
git -C <path> <val> <flag> <args>sed -n <val> <path>rg -n <val> <path> <path> -g <path>head -n <n>Requested source searches and file and log inspection related to attention kernels.
1 call · #0098–#0098
rg -n <val> <path> -g <path>head -n <n>sed -n <val> <path>Requested file and log inspection, source searches and repository inspection related to kv-cache management.
2 calls · #0099–#0100
sed -n <val> <path>rg -n <val> <flag> <args>git -C <path> <val> --oneline <flag> <args>git -C <path> <val> -p <flag> <args>head -n <n>rg -n <val> <path>Requested file and log inspection related to attention kernels.
1 call · #0101–#0101
sed -n <val> <path>jq <val> <path>Requested environment setup or inspection related to reward & policy updates.
1 call · #0102–#0102
env <vars> python -m <module> -q <script>Requested environment setup or inspection related to reward & policy updates.
1 call · #0103–#0103
env <vars> python - <script>Requested runtime inspection and source searches related to source & workspace.
1 call · #0104–#0104
ps <flag>rg <val>rg -v <val>trueRequested file and log inspection and workspace inspection related to task requirements.
3 calls · #0105–#0107
sed -n <val> <path>find <path> -name <val> -o -name <val>head -n <n>wc -l <path> <path> <path>Requested script or workload execution related to source & workspace.
1 call · #0108–#0108
bash <script>Requested repository inspection, file and log inspection and workspace inspection related to source & workspace.
2 calls · #0109–#0110
git status --shortgit diff --statgit diff <flag> <args>head -n <n>git diff --checkfind <path> -maxdepth <n> -type <val> <flag> <args>find <path> -maxdepth <n> -type <val> <flag>find <path> <path> <path> -maxdepth <n> -type <val> -name <val> <flag>Requested repository inspection and file and log inspection related to reward & policy updates.
1 call · #0111–#0111
git diff <flag> <args>tail -n <n>sed -n <val> <path>Requested code edits related to source & workspace.
1 call · #0112–#0112
Apply patch <patch>Requested workspace inspection and file and log inspection related to source & workspace.
1 call · #0113–#0113
ls -l -t <val>head -n <n>find <val> -maxdepth <n> -type <val> <flag> <args>sortRequested file and log inspection, source searches and workspace inspection related to benchmark & validation setup.
8 calls · #0114–#0121
tail -n <n> <path>sed -n <path>printf <val>rg -c <val> <path>ls -l -t <val>head -n <n>find <val> -maxdepth <n> -type <val> <flag> <args>sortRequested file and log inspection related to source & workspace.
3 calls · #0122–#0124
tail -n <n> <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0125–#0125
bash <script>Requested file and log inspection related to checkpoints & weight state.
1 call · #0126–#0126
jq -r <path> <path>jq <val> <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0127–#0127
python - <script>Requested file and log inspection related to task requirements.
1 call · #0128–#0128
printf <val> <val> <val>sed -n <val> <path>Requested source searches and file and log inspection related to checkpoints & weight state.
1 call · #0129–#0129
rg -n <val> <path> <path> <path>head -n <n>Requested file and log inspection related to source & workspace.
1 call · #0130–#0130
sed -n <val> <path>Requested source searches and file and log inspection related to checkpoints & weight state.
3 calls · #0131–#0133
rg -n <val> <path> <path> <path> <path>head -n <n>sed -n <val> <path>grep -v -E <val>Requested file and log inspection related to rollout generation.
1 call · #0134–#0134
sed -n <val> <path>Requested source searches and file and log inspection related to device memory.
2 calls · #0135–#0136
rg -n <val> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> <path> <path>Requested workspace inspection and file and log inspection related to source & workspace.
1 call · #0137–#0137
find <val> -maxdepth <n> -type <val> <flag> <args>sorttail -n <n>find <path> -maxdepth <n> -type <val> <val> -name <val> -o -name <val> <args>Requested source searches and file and log inspection related to kv-cache management.
1 call · #0138–#0138
rg -n <val> <path> <path>head -n <n>Requested file and log inspection related to benchmark & validation setup.
1 call · #0139–#0139
sed -n <val> <path>sed -r <path>Requested source searches and file and log inspection related to runtime processes.
1 call · #0140–#0140
rg -n <val> <path>head -n <n>Requested file and log inspection and source searches related to rollout generation.
5 calls · #0141–#0145
sed -n <val> <path>rg -n <val> <path> --glob <path>rg -n <val> <path> <path> -g <path>rg -n <val> <path> <path> --glob <path>head -n <n>Requested source searches and file and log inspection related to runtime processes.
1 call · #0146–#0146
rg -n <val> <path> --glob <path>head -n <n>Requested source searches and file and log inspection related to convolution & sequence boundaries.
1 call · #0147–#0147
rg -n <val> <path>head -n <n>sed -n <val> <path>Requested code edits related to rollout generation.
1 call · #0148–#0148
Apply patch <patch>Requested repository inspection related to rollout generation.
1 call · #0149–#0149
git diff <flag> <args>git -C <path> <val> <flag> <args>Requested script or workload execution related to source & workspace.
1 call · #0150–#0150
python <script> --files <script> <flag> <args>Requested file and log inspection and source searches related to kv-cache management.
3 calls · #0151–#0153
sed -n <val> <path>rg -n <val> <path> <path> --glob <path>head -n <n>Requested source searches and file and log inspection related to rollout generation.
2 calls · #0154–#0155
rg -n <val> <path> <path> --glob <path>head -n <n>rg -n <val> <path> -g <path>sed -n <val> <path>Requested source searches and file and log inspection related to kv-cache management.
1 call · #0156–#0156
rg -n <val> <path> <path> --glob <path>head -n <n>Requested code edits related to kv-cache management.
1 call · #0157–#0157
Apply patch <patch>Requested script or workload execution and environment setup or inspection related to rollout generation.
1 call · #0158–#0158
python -m <module> <script> <script> <script> <script> <script>env <vars> python - <script>Requested file and log inspection related to source & workspace.
1 call · #0159–#0159
sed -n <val> <path>Requested tool activity related to rollout generation.
1 call · #0160–#0160
<command> <args>Requested script or workload execution related to kv-cache management.
1 call · #0161–#0161
python -m <module> -q <script>Requested environment setup or inspection related to reward & policy updates.
1 call · #0162–#0162
env <vars> python -m <module> -q <script>Requested environment setup or inspection and script or workload execution related to attention kernels.
1 call · #0163–#0163
env <vars> python - <script>python <script> --files <script> <flag> <args>Requested script or workload execution related to dependencies & build setup.
1 call · #0164–#0164
python -m <module> <val> <val>Requested script or workload execution related to kv-cache management.
1 call · #0165–#0165
python -m <module> -q <script>Requested file and log inspection and source searches related to source & workspace.
1 call · #0166–#0166
sed -n <val> <path>rg -n <val> <path> -g <path>Requested file and log inspection and source searches related to kv-cache management.
1 call · #0167–#0167
sed -n <val> <path>rg -n <val> <path> <path>Requested workspace inspection, file and log inspection and script or workload execution related to benchmark & validation setup.
2 calls · #0168–#0169
find <val> -maxdepth <n> -type <val> -name <val> <flag> <args>sort<command> <args>sed -r <path>cut <flag>bash <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0170–#0170
tail -n <n> <path>sed -r <path>cut <flag>Requested script or workload execution, source searches and file and log inspection related to benchmark & validation setup.
1 call · #0171–#0171
python - <script>rg -n <val> <path> <path>tail -n <n>Requested script or workload execution related to reward & policy updates.
2 calls · #0172–#0173
python - <script>Requested file and log inspection and script or workload execution related to task requirements.
1 call · #0174–#0174
sed -n <val> <path>python - <script>Requested script or workload execution related to reward & policy updates.
1 call · #0175–#0175
python - <script>Requested file and log inspection related to rollout generation.
1 call · #0176–#0176
sed -n <val> <path>Requested code edits related to rollout generation.
1 call · #0177–#0177
Apply patch <patch>Requested script or workload execution and environment setup or inspection related to rollout generation.
2 calls · #0178–#0179
<command> <args>python -m <module> <script> <script> <script>env <vars> python - <script>Requested script or workload execution related to source & workspace.
1 call · #0180–#0180
bash <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0181–#0181
tail -n <n> <path> <n> > <path>sed -r <path>cut <flag>Requested file and log inspection related to benchmark & validation setup.
2 calls · #0182–#0183
tail -n <n> <path>sed -r <path>cut <flag>Requested script or workload execution related to benchmark & validation setup.
1 call · #0184–#0184
bash <script>Requested script or workload execution, source searches and file and log inspection related to reward & policy updates.
1 call · #0185–#0185
python - <script>rg -n <val> <path>tail -n <n>Requested file and log inspection related to rollout generation.
1 call · #0186–#0186
sed -n <val> <path>sed -r <path>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0187–#0188
sed -n <val> <path>rg -n <val> <path> <path> <path> <path>head -n <n><command> <args>sed -n <val> <val>Requested code edits related to rollout generation.
1 call · #0189–#0189
Apply patch <patch>Requested repository inspection and file and log inspection related to reward & policy updates.
1 call · #0190–#0190
git status --shortgit diff --checkgit diff --statgit diff <flag> <args>sed -n <val>git -C <path> <val> --shortgit -C <path> <val> --checkgit -C <path> <val> --statgit -C <path> <val> <flag> <args>Requested source searches, file and log inspection and environment setup or inspection related to source & workspace.
1 call · #0191–#0191
rg -n <val> <val> <path>head -n <n>envrg <val>trueRequested script or workload execution, repository inspection and file and log inspection related to rollout generation.
2 calls · #0192–#0193
<command> <args>python -m <module> <script> <script>git diff --checksed -n <val> <path>git status --shortgit diff --statRequested file and log inspection related to benchmark & validation setup.
1 call · #0194–#0194
<command> <args>sed -r <path>cut <flag>Requested file and log inspection related to benchmark & validation setup.
4 calls · #0195–#0198
tail -n <n> <path>sed -r <path>cut <flag>Requested file and log inspection related to source & workspace.
2 calls · #0199–#0200
<command> <args>sed -r <path>cut <flag>tail -n <n> <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0201–#0201
bash <script>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
@@ -453,11 +453,41 @@ class Lfm2ShortConv(nn.Module): self.in_proj = nn.Linear(config.hidden_size, 3 * config.hidden_size, bias=self.bias) self.out_proj = nn.Linear(config.hidden_size, config.hidden_size, bias=self.bias) + def _remove_packed_sequence_leakage(+ self,+ conv_input: torch.Tensor,+ conv_output: torch.Tensor,+ position_ids: torch.LongTensor | None,+ ) -> torch.Tensor:+ """Remove convolution terms that cross packed-sequence boundaries.++ Padding-free training packs multiple examples into a single sequence and+ resets ``position_ids`` for every example. Attention kernels use those+ resets as sequence boundaries, but a regular depthwise convolution does+ not. Subtract the preceding-token terms for the first ``kernel_size - 1``+ positions of every packed example so the result matches independent+ causal convolutions.+ """+ if position_ids is None:+ return conv_output++ position_ids = position_ids.reshape(-1, position_ids.shape[-1])+ if position_ids.shape[0] == 1 and conv_input.shape[0] != 1:+ position_ids = position_ids.expand(conv_input.shape[0], -1)+ kernel_size = self.conv.weight.shape[-1]+ for lag in range(1, kernel_size):+ shifted_input = nn.functional.pad(conv_input, (lag, 0))[..., : conv_input.shape[-1]]+ crosses_boundary = position_ids.lt(lag).unsqueeze(1)+ kernel_weight = self.conv.weight[:, 0, kernel_size - lag - 1].view(1, -1, 1)+ conv_output = conv_output - shifted_input * crosses_boundary * kernel_weight+ return conv_output+ def cuda_kernels_forward( self, x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_ids: torch.LongTensor | None = None, ): x = apply_mask_to_padding_states(x, attention_mask) BCx = self.in_proj(x).transpose(-1, -2)@@ -481,6 +511,7 @@ class Lfm2ShortConv(nn.Module): past_key_values.conv_cache[self.layer_idx].copy_(conv_state) conv_out = causal_conv1d_fn(Bx, conv_weights, self.conv.bias, activation=None)+ conv_out = self._remove_packed_sequence_leakage(Bx, conv_out, position_ids) y = C * conv_out y = self.out_proj(y.transpose(-1, -2).contiguous())@@ -491,6 +522,7 @@ class Lfm2ShortConv(nn.Module): x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_ids: torch.LongTensor | None = None, ): seqlen = x.shape[1] @@ -525,6 +557,7 @@ class Lfm2ShortConv(nn.Module): past_key_values.conv_cache[self.layer_idx].copy_(conv_state) conv_out = self.conv(Bx)[..., :seqlen]+ conv_out = self._remove_packed_sequence_leakage(Bx, conv_out, position_ids) y = C * conv_out y = y.transpose(-1, -2).contiguous()@@ -536,10 +569,11 @@ class Lfm2ShortConv(nn.Module): hidden_states: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_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.cuda_kernels_forward(hidden_states, past_key_values, attention_mask, position_ids)+ return self.slow_forward(hidden_states, past_key_values, attention_mask, position_ids) class Lfm2DecoderLayer(GradientCheckpointingLayer):@@ -579,6 +613,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): hidden_states=self.operator_norm(hidden_states), past_key_values=past_key_values, attention_mask=attention_mask,+ position_ids=position_ids, ) hidden_states = hidden_states + residual hidden_states = hidden_states + self.feed_forward(self.ffn_norm(hidden_states))@@ -288,11 +288,41 @@ class Lfm2ShortConv(nn.Module): self.in_proj = nn.Linear(config.hidden_size, 3 * config.hidden_size, bias=self.bias) self.out_proj = nn.Linear(config.hidden_size, config.hidden_size, bias=self.bias) + def _remove_packed_sequence_leakage(+ self,+ conv_input: torch.Tensor,+ conv_output: torch.Tensor,+ position_ids: torch.LongTensor | None,+ ) -> torch.Tensor:+ """Remove convolution terms that cross packed-sequence boundaries.++ Padding-free training packs multiple examples into a single sequence and+ resets ``position_ids`` for every example. Attention kernels use those+ resets as sequence boundaries, but a regular depthwise convolution does+ not. Subtract the preceding-token terms for the first ``kernel_size - 1``+ positions of every packed example so the result matches independent+ causal convolutions.+ """+ if position_ids is None:+ return conv_output++ position_ids = position_ids.reshape(-1, position_ids.shape[-1])+ if position_ids.shape[0] == 1 and conv_input.shape[0] != 1:+ position_ids = position_ids.expand(conv_input.shape[0], -1)+ kernel_size = self.conv.weight.shape[-1]+ for lag in range(1, kernel_size):+ shifted_input = nn.functional.pad(conv_input, (lag, 0))[..., : conv_input.shape[-1]]+ crosses_boundary = position_ids.lt(lag).unsqueeze(1)+ kernel_weight = self.conv.weight[:, 0, kernel_size - lag - 1].view(1, -1, 1)+ conv_output = conv_output - shifted_input * crosses_boundary * kernel_weight+ return conv_output+ def cuda_kernels_forward( self, x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_ids: torch.LongTensor | None = None, ): x = apply_mask_to_padding_states(x, attention_mask) BCx = self.in_proj(x).transpose(-1, -2)@@ -316,6 +346,7 @@ class Lfm2ShortConv(nn.Module): past_key_values.conv_cache[self.layer_idx].copy_(conv_state) conv_out = causal_conv1d_fn(Bx, conv_weights, self.conv.bias, activation=None)+ conv_out = self._remove_packed_sequence_leakage(Bx, conv_out, position_ids) y = C * conv_out y = self.out_proj(y.transpose(-1, -2).contiguous())@@ -326,6 +357,7 @@ class Lfm2ShortConv(nn.Module): x: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_ids: torch.LongTensor | None = None, ): seqlen = x.shape[1] @@ -360,6 +392,7 @@ class Lfm2ShortConv(nn.Module): past_key_values.conv_cache[self.layer_idx].copy_(conv_state) conv_out = self.conv(Bx)[..., :seqlen]+ conv_out = self._remove_packed_sequence_leakage(Bx, conv_out, position_ids) y = C * conv_out y = y.transpose(-1, -2).contiguous()@@ -371,10 +404,11 @@ class Lfm2ShortConv(nn.Module): hidden_states: torch.Tensor, past_key_values: Lfm2HybridConvCache | None = None, attention_mask: torch.Tensor | None = None,+ position_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.cuda_kernels_forward(hidden_states, past_key_values, attention_mask, position_ids)+ return self.slow_forward(hidden_states, past_key_values, attention_mask, position_ids) class Lfm2DecoderLayer(GradientCheckpointingLayer):@@ -414,6 +448,7 @@ class Lfm2DecoderLayer(GradientCheckpointingLayer): hidden_states=self.operator_norm(hidden_states), past_key_values=past_key_values, attention_mask=attention_mask,+ position_ids=position_ids, ) hidden_states = hidden_states + residual hidden_states = hidden_states + self.feed_forward(self.ffn_norm(hidden_states))Base commit: 0b2151ec61de5d99e0811b01c09e43a99a23e69d
@@ -0,0 +1,95 @@+# Copyright 2024 Bytedance Ltd. and/or its affiliates+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+"""Dependency-light global request routing for rollout servers."""++import logging+import os++import ray+from cachetools import LRUCache++logger = logging.getLogger(__file__)+logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN"))++DEFAULT_ROUTING_CACHE_SIZE = 10000+++@ray.remote+class GlobalRequestLoadBalancer:+ """Global sticky-session and in-flight load balancer.++ Keeping this actor in a small module prevents each router process from+ importing the rollout engines and their accelerator plugins.+ """++ def __init__(self, servers: dict[str, ray.actor.ActorHandle], max_cache_size: int = DEFAULT_ROUTING_CACHE_SIZE):+ if not servers:+ raise ValueError("servers must be non-empty")++ self._servers: dict[str, ray.actor.ActorHandle] = dict(servers)+ self._inflight_requests: dict[str, int] = {sid: 0 for sid in servers}+ self._request_id_to_server: LRUCache = LRUCache(maxsize=max_cache_size)++ def acquire_server(self, request_id: str) -> tuple[str, ray.actor.ActorHandle]:+ """Acquire a server for a request using sticky, least-loaded routing."""+ if request_id in self._request_id_to_server:+ server_id = self._request_id_to_server[request_id]+ if server_id in self._inflight_requests:+ self._inflight_requests[server_id] += 1+ return server_id, self._servers[server_id]+ del self._request_id_to_server[request_id]++ if not self._inflight_requests:+ raise RuntimeError("No available servers in load balancer")++ server_id = min(self._inflight_requests, key=self._inflight_requests.get)+ self._request_id_to_server[request_id] = server_id+ self._inflight_requests[server_id] += 1+ return server_id, self._servers[server_id]++ def release_server(self, server_id: str) -> None:+ """Release a server after a request completes."""+ if server_id in self._inflight_requests and self._inflight_requests[server_id] > 0:+ self._inflight_requests[server_id] -= 1++ def add_servers(self, servers: dict[str, ray.actor.ActorHandle]) -> None:+ """Atomically add multiple servers to the routing pool."""+ for server_id, handle in servers.items():+ self._inflight_requests[server_id] = 0+ self._servers[server_id] = handle+ logger.info("[GlobalLoadBalancer] added %d servers", len(servers))++ def remove_servers(self, server_ids: list[str]) -> None:+ """Atomically remove multiple servers from the routing pool."""+ for server_id in server_ids:+ self._inflight_requests.pop(server_id, None)+ self._servers.pop(server_id, None)+ logger.info("[GlobalLoadBalancer] removed %d servers", len(server_ids))++ def get_inflight_count(self, server_id: str) -> int:+ """Return the number of requests currently routed to a server."""+ return self._inflight_requests.get(server_id, 0)++ def get_all_servers(self) -> list[str]:+ """Return all active server identifiers."""+ return list(self._inflight_requests)++ def get_status(self) -> dict:+ """Return current load-balancer state for readiness and debugging."""+ return {+ "servers": dict(self._inflight_requests),+ "total_inflight": sum(self._inflight_requests.values()),+ "active_servers": len(self._inflight_requests),+ "registered_handles": list(self._servers),+ }@@ -99,7 +99,7 @@ actor_rollout_ref: clip_cov_ub: 5.0 kl_cov_ratio: 0.0002 ppo_kl_coef: 0.1- clip_ratio_c: 3.0+ clip_ratio_c: null loss_agg_mode: token-mean loss_scale_factor: null entropy_coeff: 0@@ -69,7 +69,7 @@ actor_rollout_ref: clip_cov_ub: 5.0 kl_cov_ratio: 0.0002 ppo_kl_coef: 0.1- clip_ratio_c: 3.0+ clip_ratio_c: null loss_agg_mode: token-mean loss_scale_factor: null entropy_coeff: 0@@ -78,7 +78,7 @@ actor_rollout_ref: clip_cov_ub: 5.0 kl_cov_ratio: 0.0002 ppo_kl_coef: 0.1- clip_ratio_c: 3.0+ clip_ratio_c: null loss_agg_mode: token-mean loss_scale_factor: null entropy_coeff: 0@@ -76,7 +76,7 @@ actor_rollout_ref: clip_cov_ub: 5.0 kl_cov_ratio: 0.0002 ppo_kl_coef: 0.1- clip_ratio_c: 3.0+ clip_ratio_c: null loss_agg_mode: token-mean loss_scale_factor: null entropy_coeff: 0@@ -75,8 +75,8 @@ policy_loss: # KL divergence penalty coefficient ppo_kl_coef: 0.1 -# Constant C in Dual-clip PPO; clips when advantage < 0 and ratio > C-clip_ratio_c: 3.0+# Optional constant C in Dual-clip PPO; clips when advantage < 0 and ratio > C+clip_ratio_c: null # Loss aggregation mode: "token-mean", "seq-mean-token-sum", "seq-mean-token-mean", or "seq-mean-token-sum-norm" loss_agg_mode: token-mean@@ -317,4 +317,3 @@ qat: # Path to vLLM quantization config JSON file quantization_config_path: null-@@ -1208,7 +1208,7 @@ def compute_policy_loss( cliprange=None, cliprange_low=None, cliprange_high=None,- clip_ratio_c=3.0,+ clip_ratio_c=None, loss_agg_mode: str = "token-mean", ): """@@ -1234,15 +1234,16 @@ def compute_policy_loss( cliprange_high (float, optional): Upper clip range for dual-clip PPO. Defaults to same as `cliprange`. clip_ratio_c (float, optional):- Lower bound of the ratio for dual-clip PPO. See https://arxiv.org/pdf/1912.09729.- Defaults to 3.0.+ Upper bound of the ratio for dual-clip PPO. See https://arxiv.org/pdf/1912.09729.+ Dual clipping is disabled when this is `None`. loss_agg_mode (str, optional): Aggregation mode for `agg_loss`. Defaults to "token-mean". """- assert clip_ratio_c > 1.0, (- "The lower bound of the clip_ratio_c for dual-clip PPO should be greater than 1.0,"- + f" but get the value: {clip_ratio_c}."- )+ if clip_ratio_c is not None:+ assert clip_ratio_c > 1.0, (+ "The upper bound of the clip_ratio_c for dual-clip PPO should be greater than 1.0,"+ + f" but get the value: {clip_ratio_c}."+ ) negative_approx_kl = log_prob - old_log_prob # Clamp negative_approx_kl for stability@@ -1263,13 +1264,16 @@ def compute_policy_loss( ) # max(-ratio * A, -clip(ratio, 1-cliprange, 1+cliprange) * A) pg_clipfrac = verl_F.masked_mean(torch.gt(pg_losses2, pg_losses1).float(), response_mask) - pg_losses3 = -advantages * clip_ratio_c- clip_pg_losses2 = torch.min(pg_losses3, clip_pg_losses1)- pg_clipfrac_lower = verl_F.masked_mean(- torch.gt(clip_pg_losses1, pg_losses3) * (advantages < 0).float(), response_mask- )-- pg_losses = torch.where(advantages < 0, clip_pg_losses2, clip_pg_losses1)+ if clip_ratio_c is None:+ pg_losses = clip_pg_losses1+ pg_clipfrac_lower = torch.zeros((), device=pg_losses.device)+ else:+ pg_losses3 = -advantages * clip_ratio_c+ clip_pg_losses2 = torch.min(pg_losses3, clip_pg_losses1)+ pg_clipfrac_lower = verl_F.masked_mean(+ torch.gt(clip_pg_losses1, pg_losses3) * (advantages < 0).float(), response_mask+ )+ pg_losses = torch.where(advantages < 0, clip_pg_losses2, clip_pg_losses1) pg_loss = agg_loss(loss_mat=pg_losses, loss_mask=response_mask, loss_agg_mode=loss_agg_mode) return pg_loss, pg_clipfrac, ppo_kl, pg_clipfrac_lower@@ -1313,18 +1317,17 @@ def compute_policy_loss_vanilla( clip_ratio = config.clip_ratio # Clipping parameter ε for standard PPO. See https://arxiv.org/abs/1707.06347. clip_ratio_low = config.clip_ratio_low if config.clip_ratio_low is not None else clip_ratio clip_ratio_high = config.clip_ratio_high if config.clip_ratio_high is not None else clip_ratio- clip_ratio_c = config.get( # Lower bound of the ratio for dual-clip PPO. See https://arxiv.org/pdf/1912.09729.- "clip_ratio_c", 3.0- )+ clip_ratio_c = config.get("clip_ratio_c", None) cliprange = clip_ratio cliprange_low = clip_ratio_low cliprange_high = clip_ratio_high - assert clip_ratio_c > 1.0, (- "The lower bound of the clip_ratio_c for dual-clip PPO should be greater than 1.0,"- + f" but get the value: {clip_ratio_c}."- )+ if clip_ratio_c is not None:+ assert clip_ratio_c > 1.0, (+ "The upper bound of the clip_ratio_c for dual-clip PPO should be greater than 1.0,"+ + f" but get the value: {clip_ratio_c}."+ ) negative_approx_kl = log_prob - old_log_prob # Clamp negative_approx_kl for stability@@ -1345,13 +1348,16 @@ def compute_policy_loss_vanilla( ) # max(-ratio * A, -clip(ratio, 1-cliprange, 1+cliprange) * A) pg_clipfrac = verl_F.masked_mean(torch.gt(pg_losses2, pg_losses1).float(), response_mask) - pg_losses3 = -advantages * clip_ratio_c- clip_pg_losses2 = torch.min(pg_losses3, clip_pg_losses1)- pg_clipfrac_lower = verl_F.masked_mean(- torch.gt(clip_pg_losses1, pg_losses3) * (advantages < 0).float(), response_mask- )-- pg_losses = torch.where(advantages < 0, clip_pg_losses2, clip_pg_losses1)+ if clip_ratio_c is None:+ pg_losses = clip_pg_losses1+ pg_clipfrac_lower = torch.zeros((), device=pg_losses.device)+ else:+ pg_losses3 = -advantages * clip_ratio_c+ clip_pg_losses2 = torch.min(pg_losses3, clip_pg_losses1)+ pg_clipfrac_lower = verl_F.masked_mean(+ torch.gt(clip_pg_losses1, pg_losses3) * (advantages < 0).float(), response_mask+ )+ pg_losses = torch.where(advantages < 0, clip_pg_losses2, clip_pg_losses1) # Apply rollout correction weights if provided if rollout_is_weights is not None:@@ -117,7 +117,7 @@ class ActorConfig(BaseConfig): clip_ratio_low (float): Lower bound for PPO clipping ratio. clip_ratio_high (float): Upper bound for PPO clipping ratio. policy_loss (PolicyLossConfig): Configuration for policy loss computation.- clip_ratio_c (float): Clipping ratio for critic loss.+ clip_ratio_c (float, optional): Constant C for opt-in dual-clip PPO. loss_agg_mode (str): Loss aggregation mode. Options: 'token-mean', 'sample-mean'. loss_scale_factor (Optional[int]): Scale factor for 'seq-mean-token-sum-norm' loss aggregation mode. If None, uses response_length. Set to a constant to ensure consistent normalization.@@ -159,7 +159,9 @@ class ActorConfig(BaseConfig): clip_ratio_high: float = 0.2 freeze_vision_tower: bool = False policy_loss: PolicyLossConfig = field(default_factory=PolicyLossConfig)- clip_ratio_c: float = 3.0+ # Dual-clip PPO is opt-in. ``None`` keeps the vanilla policy loss equal to+ # the standard clipped PPO objective.+ clip_ratio_c: Optional[float] = None loss_agg_mode: str = "token-mean" loss_scale_factor: Optional[int] = None entropy_coeff: float = 0@@ -25,9 +25,9 @@ from typing import Any, Optional from uuid import uuid4 import ray-from cachetools import LRUCache from omegaconf import DictConfig +from verl.rollout_load_balancer import DEFAULT_ROUTING_CACHE_SIZE, GlobalRequestLoadBalancer from verl.single_controller.ray.base import RayResourcePool, RayWorkerGroup from verl.utils.ray_utils import auto_await from verl.utils.rollout_trace import rollout_trace_op@@ -37,111 +37,6 @@ from verl.workers.rollout.utils import update_prometheus_config logger = logging.getLogger(__file__) logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN")) -DEFAULT_ROUTING_CACHE_SIZE = 10000---@ray.remote-class GlobalRequestLoadBalancer:- """Global sticky-session + in-flight load balancer shared by all AgentLoopWorkers.-- When a sticky session points to a removed server, the cache entry is- automatically invalidated and a new server is selected.-- Key features:- - **Atomic acquire**: ``acquire_server()`` returns ``(server_id, handle)``- - **Sticky Session**: Uses LRUCache to map request_id → server_id, ensuring- multi-turn conversations route to the same server.- - **Least-loaded Selection**: When no sticky session exists, selects the- server with the fewest in-flight requests.- - **Dynamic Server Management**: Supports add/remove servers at runtime- for hybrid scaling.- """-- def __init__(self, servers: dict[str, ray.actor.ActorHandle], max_cache_size: int = DEFAULT_ROUTING_CACHE_SIZE):- if not servers:- raise ValueError("servers must be non-empty")-- self._servers: dict[str, ray.actor.ActorHandle] = dict(servers)- self._inflight_requests: dict[str, int] = {sid: 0 for sid in servers}- self._request_id_to_server: LRUCache = LRUCache(maxsize=max_cache_size)-- def acquire_server(self, request_id: str) -> tuple[str, ray.actor.ActorHandle]:- """Acquire a server for the given request (sticky + least-loaded).-- Returns:- A tuple of ``(server_id, actor_handle)`` in a single atomic call.- """- # Try sticky session first- if request_id in self._request_id_to_server:- server_id = self._request_id_to_server[request_id]- # Check if server is still in the active pool- if server_id in self._inflight_requests:- self._inflight_requests[server_id] += 1- return server_id, self._servers[server_id]- # Server was removed, clear stale cache entry and re-select- del self._request_id_to_server[request_id]-- # Select new server (least-loaded among available)- if not self._inflight_requests:- raise RuntimeError("No available servers in load balancer")-- server_id = min(self._inflight_requests, key=self._inflight_requests.get)- self._request_id_to_server[request_id] = server_id- self._inflight_requests[server_id] += 1- return server_id, self._servers[server_id]-- def release_server(self, server_id: str) -> None:- """Release a server after a request completes."""- if server_id not in self._inflight_requests:- return- if self._inflight_requests[server_id] > 0:- self._inflight_requests[server_id] -= 1-- def add_servers(self, servers: dict[str, ray.actor.ActorHandle]) -> None:- """Atomically add multiple servers to the load balancer pool.-- This is more efficient than calling :meth:`add_server` in a loop- because it performs a single bulk update on the internal state.-- Args:- servers: Dict mapping server_id → actor_handle for all servers- to register.- """- for sid, handle in servers.items():- self._inflight_requests[sid] = 0- self._servers[sid] = handle- logger.info(f"[GlobalLoadBalancer] added {len(servers)} servers")-- def remove_servers(self, server_ids: list[str]) -> None:- """Atomically remove multiple servers from the load balancer pool.-- More efficient than calling :meth:`remove_server` in a loop.-- Args:- server_ids: List of server identifiers to remove.- """- for sid in server_ids:- self._inflight_requests.pop(sid, None)- self._servers.pop(sid, None)- logger.info(f"[GlobalLoadBalancer] removed {len(server_ids)} servers")-- def get_inflight_count(self, server_id: str) -> int:- """Get number of in-flight requests for a server."""- return self._inflight_requests.get(server_id, 0)-- def get_all_servers(self) -> list[str]:- """Get list of all active server IDs."""- return list(self._inflight_requests.keys())-- def get_status(self) -> dict:- """Return current load balancer state for debugging."""- return {- "servers": dict(self._inflight_requests),- "total_inflight": sum(self._inflight_requests.values()),- "active_servers": len(self._inflight_requests),- "registered_handles": list(self._servers.keys()),- }- class LLMServerClient: """@@ -339,6 +234,9 @@ class LLMServerManager: servers=dict(zip(self.server_addresses, self.server_handles, strict=True)), max_cache_size=DEFAULT_ROUTING_CACHE_SIZE, )+ # Actor creation is asynchronous. Complete its lightweight startup as+ # part of manager initialization instead of delaying the first request.+ await self.global_load_balancer.get_status.remote() def get_client(self, client_cls=LLMServerClient, **kwargs) -> LLMServerClient: """Get the LLMServerClient to request LLM server replicas.Base commit: 5a0277de14789b245c781911b3119ed6af901b7b
@@ -817,6 +817,49 @@ def get_max_concurrency_for_kv_cache_config( return max_concurrency +def _cap_sleep_mode_num_blocks(+ vllm_config: VllmConfig,+ kv_cache_groups: list[KVCacheGroupSpec],+ num_blocks: int,+) -> int:+ """Bound disposable sleep-mode KV cache to the scheduler's working set.++ Sleep mode discards the KV cache at every phase boundary, so capacity far+ beyond what the scheduler can make resident cannot survive to benefit a+ later phase. Mapping and unmapping that excess capacity can dominate short+ colocated training phases. Keep room for the maximum active batch plus an+ equally sized prefix-cache working set.+ """+ if (+ not vllm_config.model_config.enable_sleep_mode+ or vllm_config.cache_config.num_gpu_blocks_override is not None+ or not kv_cache_groups+ ):+ return num_blocks++ num_layers_per_group = max(len(group.layer_names) for group in kv_cache_groups)+ max_memory_per_request = num_layers_per_group * max_memory_usage_bytes(+ vllm_config, (group.kv_cache_spec for group in kv_cache_groups)+ )+ memory_per_block = (+ kv_cache_groups[0].kv_cache_spec.page_size_bytes * num_layers_per_group+ )+ blocks_per_request = cdiv(max_memory_per_request, memory_per_block)+ working_set_blocks = (+ 2 * vllm_config.scheduler_config.max_num_seqs * blocks_per_request+ )+ if num_blocks > working_set_blocks:+ logger.info(+ "Capping sleep-mode KV cache from %d to %d blocks "+ "(%d active sequences plus prefix-cache headroom)",+ num_blocks,+ working_set_blocks,+ vllm_config.scheduler_config.max_num_seqs,+ )+ return working_set_blocks+ return num_blocks++ def may_override_num_blocks(vllm_config: VllmConfig, num_blocks: int) -> int: """ Override the number of kv cache blocks if `num_gpu_blocks_override` is set.@@ -1111,6 +1154,9 @@ def get_kv_cache_config_from_groups( available_memory // kv_cache_groups[0].kv_cache_spec.page_size_bytes ) num_blocks = may_override_num_blocks(vllm_config, num_blocks)+ num_blocks = _cap_sleep_mode_num_blocks(+ vllm_config, kv_cache_groups, num_blocks+ ) per_layer_specs = kv_cache_groups[0].kv_cache_spec.kv_cache_specs kv_cache_tensors = [ KVCacheTensor(@@ -1137,6 +1183,9 @@ def get_kv_cache_config_from_groups( num_blocks = get_num_blocks( vllm_config, group_size, available_memory, page_size )+ num_blocks = _cap_sleep_mode_num_blocks(+ vllm_config, kv_cache_groups, num_blocks+ ) kv_cache_tensors = [] for i in range(group_size): shared_by = []Base commit: f649187194c44d86415d1ddfa49359e824932c9a
@@ -50,15 +50,33 @@ def verify_and_update_config(cls, vllm_config) -> None: mamba_sizes = [] for shape, dtype in zip(mamba_shapes, mamba_dtypes): mamba_sizes.append(math.prod(shape) * get_dtype_size(dtype))- ssm_block_page_size, conv_block_page_size = max(mamba_sizes), min(mamba_sizes)+ # Most Mamba models have separate convolution and SSM states. Short+ # convolution models such as LFM2 only have a convolution state, however,+ # and must be aligned directly with a complete attention (K + V) page.+ # Treating that sole state as both the SSM and convolution state makes the+ # exact SSM/K-page check below impossible and double-counts the state in+ # ``mamba_page_size_padded``.+ single_state_cache = len(mamba_sizes) == 1+ ssm_block_page_size = max(mamba_sizes)+ conv_block_page_size = 0 if single_state_cache else min(mamba_sizes) # NOTE(zxr): because of the limit of Ascend Hardware, we need to keep # 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, (- "Cannot align ssm_page_size and attn_page_size."- )+ if single_state_cache:+ attn_single_token_page_size = 2 * attn_single_token_k_page_size+ attn_block_size = kernel_block_size * cdiv(+ ssm_block_page_size,+ kernel_block_size * attn_single_token_page_size,+ )+ else:+ 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, (+ "Cannot align ssm_page_size and attn_page_size."+ ) # override attention block size if either (a) the # user has not set it or (b) the user has set it@@ -79,7 +97,8 @@ def verify_and_update_config(cls, vllm_config) -> None: or cache_config.mamba_page_size_padded != attn_page_size + conv_block_page_size ): cache_config.mamba_page_size_padded = attn_page_size + conv_block_page_size- mamba_padding_pct = 100 * conv_block_page_size / cache_config.mamba_page_size_padded+ mamba_page_size = sum(mamba_sizes)+ mamba_padding_pct = 100 * (cache_config.mamba_page_size_padded - mamba_page_size) / mamba_page_size logger.info( "Padding mamba page size by %.2f%% to ensure " "that mamba page size and attention page size are "