vllm.models.muse_spark.common.layers
¶
Platform-neutral MuseSpark1x building blocks shared by the NVIDIA and AMD stacks.
Classes:
-
MulTanhSoftCap–Computes
soft_cap_temp * tanh(x * multiplier / soft_cap_temp)in fp32. -
MuseSpark1xNormPreservingResidualConnection–Gated residual sum with norm-preserving weights:
alpha*a + beta*b. -
MuseSpark1xQKVOGateParallelLinear–Fused [Q, K, V, O-gate] projection with head-aware TP sharding.
-
MuseSpark1xRMSNorm–RMSNorm in fp32, rounded once at the store to
out_dtype. -
MuseSpark1xRMSNormWithInputScale–Weight-first RMSNorm variant:
rms_norm(x * weight). -
MuseSpark1xResidualConnection–Vanilla residual sum:
stream + branch. -
MuseSpark1xResidualStream–A residual stream whose last blend is deferred to fuse with the next norm.
Functions:
-
calculate_gain_center–Gain center for the given type and residual ID (1-based indices).
-
materialize_residual_path_constants–Precompute parameter-only constants after weight loading; idempotent.
-
norm_then_gated_residual–alpha * stream + beta * norm(branch), in one kernel where possible.
MulTanhSoftCap
¶
Bases: Module
Computes soft_cap_temp * tanh(x * multiplier / soft_cap_temp) in fp32.
Source code in vllm/models/muse_spark/common/layers.py
MuseSpark1xNormPreservingResidualConnection
¶
Bases: MuseSpark1xResidualConnection
Gated residual sum with norm-preserving weights: alpha*a + beta*b.
With a the stream and b the branch, and gate parameter w:
beta = sigmoid(w / temperature)
alpha = sqrt(max(eps, sigmoid(-w) * (1 + beta))) # = sqrt(1 - beta^2)
The sum is computed in fp32 and cast back to the stream dtype.
Methods:
-
coefficients–Compute post-activation coefficients for the stream and branch.
-
materialize_coefficients–Cache alpha/beta as fp32 buffers. Call once, after weight loading.
Source code in vllm/models/muse_spark/common/layers.py
coefficients(w)
¶
Compute post-activation coefficients for the stream and branch.
Source code in vllm/models/muse_spark/common/layers.py
materialize_coefficients()
¶
Cache alpha/beta as fp32 buffers. Call once, after weight loading.
Source code in vllm/models/muse_spark/common/layers.py
MuseSpark1xQKVOGateParallelLinear
¶
Bases: ColumnParallelLinear
Fused [Q, K, V, O-gate] projection with head-aware TP sharding.
Per-rank rows are [q, k, v, o_gate], so checkpoint tensors are sliced by head group. KV-head padding is not supported.
Source code in vllm/models/muse_spark/common/layers.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
MuseSpark1xRMSNorm
¶
Bases: Module
RMSNorm in fp32, rounded once at the store to out_dtype.
Deliberately not F.rms_norm: that path can flip greedy token selection.
Methods:
-
supports_fused_kernel–Whether the Triton kernel can serve this norm for input
x.
Attributes:
-
fused_gain_center(float) –gain_centeras the fused kernels take it: 0.0 when unused.
Source code in vllm/models/muse_spark/common/layers.py
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 | |
MuseSpark1xRMSNormWithInputScale
¶
Bases: MuseSpark1xRMSNorm
Weight-first RMSNorm variant: rms_norm(x * weight).
Source code in vllm/models/muse_spark/common/layers.py
MuseSpark1xResidualConnection
¶
Bases: Module
Vanilla residual sum: stream + branch.
Source code in vllm/models/muse_spark/common/layers.py
MuseSpark1xResidualStream
dataclass
¶
A residual stream whose last blend is deferred to fuse with the next norm.
Source code in vllm/models/muse_spark/common/layers.py
calculate_gain_center(gain_center_type, residual_id, n_layers=None)
¶
Gain center for the given type and residual ID (1-based indices).
Source code in vllm/models/muse_spark/common/layers.py
materialize_residual_path_constants(model)
¶
Precompute parameter-only constants after weight loading; idempotent.
Source code in vllm/models/muse_spark/common/layers.py
norm_then_gated_residual(x)
¶
alpha * stream + beta * norm(branch), in one kernel where possible.