Support poolside/Laguna-S-2.1-NVFP4, and fix serving from source on Windows - #298
Open
Eng-Ahmd wants to merge 2 commits into
Open
Support poolside/Laguna-S-2.1-NVFP4, and fix serving from source on Windows#298Eng-Ahmd wants to merge 2 commits into
Eng-Ahmd wants to merge 2 commits into
Conversation
Laguna S 2.1 is a 48-layer, 117.6B/8.5B-active MoE with several traits no existing model module covers: * Per-layer attention width: 48 heads on the 12 full-attention layers, 72 on the 36 sliding ones (window 512), with KV fixed at 8 heads. * Two RoPE configs nested under `rope_parameters` by layer type -- YaRN (theta 500k, partial_rotary_factor 0.5) for full, default (theta 10k, full rotary) for sliding. There is no top-level `rope_theta`. * Softplus output gating applied per head before o_proj, and unconditional QK-RMSNorm with no config flag. * Sigmoid router with a selection-only correction bias, `norm_topk_prob`, a routed scaling factor of 2.5, and one always-on shared expert. Layer 0 is dense. * Mixed-precision experts: layers 1-39 ship compressed-tensors NVFP4 (`weight_packed` / `weight_scale` / `weight_global_scale`, group 16), while 40-47 ship plain bf16. `ModelConfig.num_qo_heads` is set to the maximum per-layer head count rather than the nominal one: the Triton backend sizes its decode scratch and CUDA-graph capture buffers from that single value and never resizes them on replay, so the nominal 48 would let the 72-head layers write out of bounds under graph replay. The bf16 expert layers are quantized to NVFP4 at conversion so one bank layout and one kernel path covers all 47 MoE layers. `Nvfp4ExpertSourceSpec` gains three optional hooks to keep this on the shared loader (with its completion tracking, pin-after-fill and FTW streaming) instead of a private one: `kind_map` for compressed-tensors key names, `global_transform` for its quant-side scale convention, and `synthesize_layer` for bank layers absent from the checkpoint. Existing specs leave all three None and are unaffected. Verified against the checkpoint and its reference implementation: converted banks dequantize bit-exactly for the packed layers; the synthesized layers land at 9.51% relative RMS against a 9.41% floor measured with ideal fp32 scales; RoPE matches `modeling_laguna.py` to ~5e-07 for both layer types; router expert ids are identical and weights match once the reference's bf16 cast is applied. Reasoning and tool-call parsers resolve automatically: Laguna's think tags are `<think>`/`</think>` with the opening tag pre-filled by the chat template, and its tool envelope is GLM-4.7's grammar without the inter-tag newlines.
Five separate POSIX-only assumptions each stop `python -m freetoken` before it can answer a request on Windows. None affect POSIX behaviour. * ZMQ IPC. libzmq is built without the `ipc://` transport on Windows, so all five inter-process sockets fail to bind with "Protocol not supported". The addresses now come from one helper on SchedulerConfig that keeps `ipc://` wherever the ZMQ build supports it and otherwise uses a contiguous localhost TCP block. The base port is reserved once in the parent and travels to the workers in the config they are already handed, since separate processes cannot negotiate it at runtime. * Event loop. pyzmq's asyncio sockets need `add_reader`, which the Windows Proactor loop does not implement. The frontend's ZMQ listener died at startup and every request then hung until it timed out while the scheduler logged the prefill as normal. Setting the loop policy alone is not enough because uvicorn's loop factory hardcodes ProactorEventLoop on win32, so the server now runs on a selector loop we create and pass in via `loop="none"`. * `os.posix_fadvise`, `mmap.PROT_READ` and `mmap.madvise` are absent on Windows; the first raised AttributeError past the OSError guard, and the second is spelled `access=ACCESS_READ` there. The parallel O_DIRECT reader was already gated behind a platform check, so page-cache dropping simply becomes a no-op and host memory pressure during a large conversion is correspondingly higher. Checked by converting and serving a 93 GiB NVFP4 checkpoint from a source checkout: prompts answer in ~2s, thinking and tool calls parse, and a runtime cache rebuild followed by further generation works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for poolside/Laguna-S-2.1-NVFP4, and fixes the Windows issues that prevented serving from a source checkout.
Laguna S 2.1
A 48-layer, 117.6B/8.5B-active MoE. Five traits sit outside what the existing model modules cover:
rope_parametersby layer type: YaRN (theta 500k,partial_rotary_factor0.5) for full attention, default (theta 10k, full rotary) for sliding. There is no top-levelrope_theta.o_proj, and unconditional QK-RMSNorm with no config flag.Two details worth calling out for review:
ModelConfig.num_qo_headsis set to the maximum per-layer head count, not the nominal one. The Triton backend sizes its decode scratch and CUDA-graph capture buffers from that single value and never resizes them on replay, so the nominal 48 would let the 72-head layers write past their buffer. Per-layer counts drive the projections.The bf16 expert layers are quantized to NVFP4 during conversion so one bank layout and one kernel path serves all 47 MoE layers. To keep that on the shared loader rather than a private one,
Nvfp4ExpertSourceSpecgains three optional hooks:kind_map(compressed-tensors key names),global_transform(its quant-side scale convention), andsynthesize_layer(bank layers absent from the checkpoint). Existing specs leave all threeNoneand are unchanged.Verification
Checked against the checkpoint and its reference
modeling_laguna.py:Then end to end: coherent generation, thinking and tool calls parsed, batched CUDA-graph replay, generation past the sliding window, and a runtime cache rebuild followed by further generation.
Reasoning and tool parsers resolve automatically. Laguna's think tags are
<think>/</think>with the opening tag pre-filled by the chat template, so the model emits only the closing tag; its tool envelope is GLM-4.7's grammar without the inter-tag newlines, whichGlm47Detectoralready tolerates.Windows
Five POSIX-only assumptions each stop
python -m freetokenbefore it can answer a request. None change POSIX behaviour.ipc://transport on Windows, so all five inter-process sockets fail to bind. Addresses now come from one helper that keepsipc://where the build supports it and otherwise uses a contiguous localhost TCP block, reserved once in the parent and inherited by the workers through the config.add_reader, absent from the Proactor loop. The frontend's ZMQ listener died at startup and requests hung until timeout while the scheduler logged the prefill normally. Setting the loop policy is not sufficient — uvicorn's loop factory hardcodesProactorEventLoopon win32 — so the server runs on a selector loop passed in vialoop="none".os.posix_fadvise,mmap.PROT_READ,mmap.madviseare unavailable. The first raisedAttributeErrorpast theOSErrorguard; the second isaccess=ACCESS_READon Windows. The parallel O_DIRECT reader was already platform-gated, so page-cache dropping becomes a no-op and host memory pressure during a large conversion is higher.Verified by converting and serving the 93 GiB checkpoint from a source checkout on Windows 11: prompts answer in ~2s, and a cache rebuild followed by further generation works.
Notes for reviewers
kernel/aot_models.pygains a Laguna entry; both KV groups share 8x128 geometry, so one store variant covers them (same as gpt-oss). Experts keep the native 6-banknvfp4layout becauseI=1024resolvesselect_nvfp4_backendto the Triton kernels.