Skip to content

[job] Per-request host-memory growth: attribute and stop it #73

Closed

Description

@AzeezIsh

Kind

Feature for a model we already support

Model

all targets (seen on Qwen3.8-Flash-Next and 27B BFCL runs)

What's the job?

Attribute the per-request host-memory growth. A Flash-Next BFCL run (job 245, GB10) lost MemAvailable 9 → 5 GB over the first 242 requests (~27 MB/request early, ~8 MB/request later); earlier 27B runs showed ~4 MB/request. On a unified-memory box this caps how many requests a gate can run and can kill a server mid-run. Teardown reports thousands of allocations with no owner (teardown swept 1279 allocation(s) that no ModelResource released). Done = allocation tagging names the growth by owner, and a 995-request BFCL run is flat after warm-up.

Impact radius

Shared code, other models could change

What else could it touch?

spark-runtime allocator / ModelResource ownership, per-request buffers, prefix-cache tiers.

Who's waiting or willing to test?

@AzeezIsh (GB10)

Activity

  1. added
    job
    on Sep 25, 2026
  2. changed the title [-][job] Qwen3.8-27B on Strix Halo: prefill 2.4x gap + DP4A verify tiers for K=5..9[/-] [+][job] Per-request host-memory growth: attribute and stop it[/+] on Sep 25, 2026
  3. AzeezIsh commented on Sep 25, 2026

    @AzeezIsh
    ContributorAuthor

    In flight (reiner job 254): per-request host-memory slope, 300 varied tool-bearing requests, Flash-Next recipe-like serve (MTP on, prefix caching on, util 0.93). First arm (main66): ~1.8 MB/request after warm-up (6,842 → 6,636 MB over requests 100-225). Second arm: #68's campaign binary — answers whether the ~7-27 MB/request seen in its BFCL run is a regression or the workload.

  4. AzeezIsh commented on Sep 25, 2026

    @AzeezIsh
    ContributorAuthor

    Result (reiner job 254). Per-request host-memory slope, 300 varied tool-bearing requests on the Flash-Next recipe (MTP on, prefix caching on), measured after warm-up (req 25..300):

    build slope total drop over 300 req
    main66 1.41 MB/req 484 MB
    #68 campaign 1.71 MB/req 899 MB

    #68 does not regress host memory. The steady leak is ~1.5 MB/req on both builds; it is pre-existing and still open under this issue.

    The ~13 MB/req seen in #68's earlier BFCL run (job 245) is therefore not a campaign regression. It is specific to the BFCL workload, or to the harness running on the same box.

    Next:

  5. AzeezIsh commented on Sep 25, 2026

    @AzeezIsh
    ContributorAuthor

    BFCL-shaped traffic leaks ~16x faster (reiner job 261).

    Leading suspect: the prefix-cache snapshot path.

    • BFCL runs through the recipe with prefix caching ON (radix tree + Marconi SSM snapshots).
    • Each request saves ~3 SSM snapshots: 91 prefill snapshots, 90 finish-leaf snapshots and 71 intermediate checkpoints over ~90 requests.
    • It also logs 25 × "prefix cache hit … but no SSM snapshot — recomputing all KV".
    • If a snapshot, or a radix node that owns one, is not released on eviction, the loss scales with requests.

    Next: job 265. main66 serving the same BFCL client with prefix caching on vs off, 22 min per arm, memory traced against the completed-request count (least-squares MB/request).

    • If P0 is flat and P1 falls, the leak is in the prefix-cache / Marconi snapshot lifecycle.
    • If both fall, it is in request handling (tool parsing, templating) and prefix caching is cleared.
  6. AzeezIsh commented on Sep 25, 2026

    @AzeezIsh
    ContributorAuthor

    Correction: prefix caching is not the BFCL memory loss (job 265).

    Setup: main66 serving the real BFCL client (spark benchmark run bfcl-subset --url), util 0.90, 22 min per arm. Slope is least squares over completed requests, excluding the first 10.

    arm MB lost / request requests MemAvailable
    prefix caching on 4.22 11..181 7,366 → 6,236 MB
    prefix caching off 8.79 13..155 7,751 → 6,125 MB

    It is worse without prefix caching, so my Marconi-snapshot hypothesis was wrong.

    Two open points:

    1. Leak or bounded warm-up. ~170 requests cannot tell the two apart. Job 225 completed a full 995-question BFCL on this model, which argues for a plateau.
    2. Is qwen4_exp: land the 2026-08-31 long-context TTFT campaign (QSA tensor cores, mHC grid fix, MoE CTA striding) #68 worse? The 27 MB/request I reported for qwen4_exp: land the 2026-08-31 long-context TTFT campaign (QSA tensor cores, mHC grid fix, MoE CTA striding) #68 (job 261) came from the benchmark harness's own serve recipe, not this harness, so it is not comparable yet.

    Job 268 runs #68's binary in this exact harness for 40 min, prefix caching on, to measure both the slope and whether it flattens.

  7. AzeezIsh commented on Sep 25, 2026

    @AzeezIsh
    ContributorAuthor

    #68 does not regress memory (job 268). Same harness as job 265: #68 head, BFCL traffic, prefix caching on, 40 min.

    build MB lost / request
    main66 (265) 4.22
    #68 (268) 4.18 (req 10..362)

    The 27 MB/request from job 261 came from the benchmark harness's own serve recipe, not from #68.

    The pre-existing loss is real and has not plateaued. MemAvailable fell 5,854 → 4,968 MB between requests 77 and 362, about 3.1 MB/request past warm-up. It does not come from prefix caching (job 265: 8.8 MB/req with it off).

    At util 0.90 on this 119.6 GB box, a full 995-question BFCL ends close to a 2.5 GB watchdog, which matches the runs that were stopped.

    • Workaround for gating: util 0.88.
    • Actual fix: find what grows per request. Next is a heap/allocation profile over ~200 BFCL requests: host allocations (jemalloc stats or heaptrack) vs device allocations (the tracked-alloc counter).
  8. AzeezIsh commented on Sep 26, 2026

    @AzeezIsh
    ContributorAuthor

    Root cause found. Fix in #82.

    Measured with a jemalloc heap profile on reiner (job 273): the shipped recipe profile with thinking on, MTP and prefix caching, driven by BFCL traffic.

    The growth only shows under the recipe. In job 271 the server's RssAnon grew +20.6 (main66), +24.6 (#68) and +28.0 (main66 without MTP) MB per request. The client stayed flat. Jobs 265/268 ran with thinking off and saw only ~4 MB/req, which is why they understated it.

    Two leaks explain it.

    1. xgrammar. Every compiled tool grammar held a deep copy of TokenizerInfo, about 20 MB on the 248k vocab. The grammar cache's LRU budget does not count that copy, and BFCL sends a distinct tool schema per request.
    2. Kernel audit. kernel_audit::record appended a row with two Strings on every GpuBackend::kernel() call. qwen4_exp: land the 2026-08-31 long-context TTFT campaign (QSA tensor cores, mHC grid fix, MoE CTA striding) #68's mHC split dispatcher looks kernels up on every decode step, so this grew continuously.

    How the growth split across call sites:

    share call site
    51 % kernel audit (hc_pre_split)
    32 % grammar compile, half of it the TokenizerInfo clone
    11 % QSA snapshot aux, bounded by the slot pool
    6 % grammar masks, bounded by the LRU

    What #82 changes. TokenizerInfo becomes an Arc handle, and the audit keeps one row per (module, func, loaded).

    Next. Job 274 measures the slope on the merge-train tree before the gates run.

  9. added 2 commits that reference this issue on Sep 26, 2026
  10. AzeezIsh commented on Sep 26, 2026

    @AzeezIsh
    ContributorAuthor

    Fixed by #82 (merged in the GB10 train). Per-request host growth under the recipe profile fell from +24.6 MB/request to +1.86 MB/request (job 274). The full 995-request ST-995 run (job 280) kept server RssAnon flat at ~1.76 GB from request ~500 on, and the 1007-turn agentic leg (job 298) added only ~0.5 MB per turn after warm-up. A follow-up that makes the dedupe exact is #92.

  11. added a commit that references this issue on Sep 26, 2026
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

    job

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions