vllm.models.glm5next.nvidia.mega_moe
¶
GLM-5.3-Flash adapter for the DeepGEMM MegaMoE kernel.
Classes:
-
Glm5NextMegaMoEExperts–MegaMoE experts loaded from a GLM-5.3 checkpoint.
Glm5NextMegaMoEExperts
¶
Bases: DeepGemmMegaMoEExperts
MegaMoE experts loaded from a GLM-5.3 checkpoint.
A BF16 checkpoint (weight_block_size None) runs the BF16 kernel and loads
as is. GLM-5.3-Flash's block-FP8 checkpoint stores E4M3 weights with one
float32 scale per weight_block_size block. Loading writes each weight
shard straight into the kernel layout and stages its block scale in
*_weight_scale_inv. Once a load is complete, the model's
process_weights_after_loading calls finalize_block_fp8_weights. On SM90
the kernel takes the block scales, which DeepGEMM lays out in place. On
SM100 the kernel takes power-of-two UE8M0 scales per 1x32, so
requantize_block_fp8 rounds every newly loaded shard to them in place.
The shared expert is fused the same way.
Methods:
-
finalize_block_fp8_weights–Build the kernel weights once a load is complete.
-
load_shared_expert_weight–Load one shared-expert checkpoint tensor; return the parameter name.
-
requantize_block_fp8–Round every shard loaded since the last call to UE8M0 1x32 scales,
Source code in vllm/models/glm5next/nvidia/mega_moe.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
_register_block_scale(name, shape)
¶
Stage the checkpoint's float32 block scales of name. The kernel's
{name}_weight_scale is derived from them and never loaded.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
_requantize_shards(tensors, shard_id)
¶
Requantize shard_id of each kernel-layout weight in place.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
_shard_rows(t, shard_id)
staticmethod
¶
Rows of t (gate rows, then up rows, for w13) that hold shard_id.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
_shard_tensors(local_expert_id, shard_id)
¶
Kernel weight, kernel scale and staged block scale of one routed
expert, or of the shared expert for local_expert_id None.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
finalize_block_fp8_weights()
¶
Build the kernel weights once a load is complete.
On SM90 the weights are already in the kernel layout and DeepGEMM lays
out the staged block scales of all experts in place; otherwise this
runs requantize_block_fp8.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
load_shared_expert_weight(name, loaded_weight)
¶
Load one shared-expert checkpoint tensor; return the parameter name.
Source code in vllm/models/glm5next/nvidia/mega_moe.py
requantize_block_fp8(chunk=8)
¶
Round every shard loaded since the last call to UE8M0 1x32 scales, in place.
Runs once a load is complete. A weight update may send a weight and its
block scale in separate load_weights calls, but both have to be in
by then.