Skip to content

Serving Qwen3.8-Flash-Next's 1M-token window on one 24 GB card #568

Open

Description

@YevheniiKotyrlo

Before you start

  • I have read the Roadmap and this is not already planned there.
  • I have read the FAQ.
  • I have searched existing issues and found no duplicate.

Applies to

Engine

What problem does this solve

Qwen3.8-Flash-Next's model card extends its 262,144 trained positions to 1,048,576 by static YaRN. FreeToken's offload design is what makes this model fit a consumer card at all, and the same design can reach the card's full context on one 24 GB GPU, but four things stand in the way on main:

  1. Rope table (Yarn support for Qwen 3.8 Next Flash #508): the cos/sin table stops at max_position_embeddings, and there is no way to pass the card's rope_parameters without editing the checkpoint.
  2. K/V memory: 24 KiB of K/V per token is 24 GiB at 1M - more than the card, beside ~9 GiB of dense weights and the expert cache.
  3. An unpriced prefill peak: --moe-cache-auto budgets weights and caches, but a max-length chunk's activations come on top and the allocator keeps them. At a 64k window the first 22.6k-token prompt left 430 MiB free and decode fell from 23-27 to 10-14 t/s, and stayed there.
  4. A top-k cliff past a 512k window: the QSA block top-k falls back to one program per row (QSA block top-k runs a 1M-token window on one program per row #566).

Proposed solution

One change each, all measured on the hardware below:

  1. feat(rotary): size the rope table for YaRN and add --hf-overrides #573 - size the rope table to the YaRN-extended context, and --hf-overrides with vLLM's semantics to pass the card's rope_parameters.
  2. Host-placed K/V (--kv-placement host): decode reads the host K/V in place over PCIe, and a prefill stages its pages into a 131,072-token device window, folded by log2-sum-exp. feat(kvcache): host-RAM KV tier for sparse-attention models (--kv-host-pages) #499 reaches for the same capacity another way, so I described mine there (feat(kvcache): host-RAM KV tier for sparse-attention models (--kv-host-pages) #499 (comment)) rather than open a competing PR.
  3. feat(engine): add --vram-reserve-mb to keep VRAM free at the largest prefill #574 - --vram-reserve-mb: measure a max-length prefill at start and shrink the expert cache until the reserve stays free.
  4. perf(qsa): reduce block top-k candidates in levels past 16 splits #571 - reduction levels in the block top-k.

With all four, on an RTX 3090 Ti 24 GB (driver 616.92), AMD Ryzen 9 9950X3D, 256 GB DDR5, PCIe 4.0 x16, RadixArk/Qwen3.8-Flash-Next-NVFP4, one server at --num-tokens 1048576 --kv-placement host --vram-reserve-mb 2000 with the card's YaRN through --hf-overrides:

measurement value
start, to the API answering, checkpoint in the file cache 119-120 s
decode, ~500-token prompt 25.0-28.0 t/s
prefill, 31.5k / 125.8k-token prompt 1,246 / 1,204 t/s
299,105-token prompt 1,095-1,119 t/s prefill; three planted codes retrieved, one 290,132 tokens before the question
985,577-985,621-token prompt 1,126-1,215 s to the first token (811-875 t/s); three codes retrieved, one 975,765 tokens before the question
a follow-up turn over the cached 985k-token prompt 5.3-7.9 s to the first token
decode 985k deep, greedy answers 23.49-23.76 t/s on short answers, 33.65 t/s through 511 tokens
sparse attend per QSA layer, K/V read in place over PCIe 166 us at every depth; 2.08-2.49 ms per token across 12 layers
VRAM free after a 985k-token prefill, --vram-reserve-mb 2000 2,273-2,275 MiB
memory held 138.4-138.6 GiB of host RAM across the process tree; 20.4-20.7 GiB of the card

Alternatives considered

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions