Repository navigation
Adding RAG tracing & eval cookbook using Parea - #390
Merged
Merged
Conversation
merrymercy
requested changes
Apr 27, 2024
|
|
||
| def _run_worker_in_context(): | ||
| self._thread_worker_func() | ||
| self.worker = threading.Thread(target=contextvars.copy_context().run, args=(_run_worker_in_context, )) |
Collaborator
There was a problem hiding this comment.
Could you tell me why this is required?
Contributor
Author
There was a problem hiding this comment.
This is required to make tracing of the pipeline possible with Parea AI. The tracing mechanism relies on contextvars to create a hierarchy of function/LLM calls. By creating a new Thread, this context is otherwise lost.
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 2, 2026
Broadcasting SIGUSR2 across a matched process set to flush a sgl-project#390 dump killed the frontend process, which never installs the handler (no MoE layers there, so no collector) and therefore takes the signal's fatal default. The scheduler ranks went down with it before flushing. The sgl-project#390 signal trigger is installed PER-PROCESS. "The server" is not one process, and a signal with a fatal default must never be aimed at a set on the assumption that a handler exists everywhere. Both measured boots switched to SGLANG_EXPERT_STATS_INTERVAL_SEC, which needs no signal at all.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 5, 2026
…umber
planner/rejected.py gains cpu_expert_lane_per_event_dequant (BLOCKED), so the
next attempt starts from the measurement instead of from zero.
The three lines the register asks for:
gain -- activations cross the link, not weights: ~800:1 less traffic per
expert event in decode, worth ~2.3x on compute
cost -- 6.177 ms/expert of dequant against 0.36 ms of headroom (17x)
why -- half precision on this CPU is a 400x cliff (~1.0 GFLOP/s bf16 AND
fp16 vs 23-432 fp32), so the lane must compute in fp32; fp32
masters need 129 GB against 98 GB with no swap, so they cannot be
held; which forces the dequant per event, where it costs more than
the transfer. The three only conflict TOGETHER -- each alone looks
survivable, which is why this took a measurement to settle.
Evidence names both hermetic measurements and their date, and states that the
verdict is robust to kernel quality (even a 5x faster dequant leaves it 3.4x
over budget) so a future reader does not re-open it on "but a better kernel".
The note carries the two routes that remain, because a rejection that closes
the whole topic would be wrong here:
- INTEGER CPU KERNELS (no dequant step at all) are the natural route for the
DSV4F/K3 vehicle and stay OPEN; nothing measured here argues either way.
- a PRE-DEQUANTISED PARTIAL fp32 TIER is arithmetically alive (~31 % of
experts in ~40 GB, no dequant in the path) but is a DIFFERENT feature -- a
second host tier plus an admission policy, sgl-project#407 being the right home -- and
it is gated on how skewed cold-expert routing actually is. That measurement
is task sgl-project#390 (expert-heat statistics), recorded as the crossing so no new
task is invented: it is answerable from existing instrumentation without a
line of CPU-lane code, and it is the FIRST question on any revisit rather
than a CPU-GEMM question at all.
scope="rig": both the 98 GB ceiling and the half-precision cliff are properties
of this box, so the entry must not travel as a hardware truth.
Tests (CUDA_VISIBLE_DEVICES=99, hermetic):
PYTHONPATH=python pytest test/registered/unit/planner -q
-> 2 failed, 2213 passed, 123 skipped, 148 subtests passed in 69.99s
The 2 failures are planner/test_webui.py and are PRE-EXISTING (reproduced
earlier in a detached worktree at the branch point, untouched).
The register's own ratchet caught an over-long `gain` line on the first
attempt (120-char limit, RejectedRegister::test_the_three_lines_stay_short) and
it was shortened rather than the limit raised -- which is the rule that keeps
this register readable.
ruff check + format: clean. codespell: clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 16, 2026
… current stream, its spill experts prefetched while this block computes (SGLANG_MOE_EXPERT_LOOKAHEAD, default off) slotstream 0.2.16 measured 1.11x decode on Qwen3.8-Flash-Next from this (the router of the block ahead picks its experts early and they are read into cache slots before that block asks). Same shape here on the resident+spill offload cache: - Qwen2MoeSparseMoeBlock.lookahead_next (link_moe_lookahead, chained in the Qwen3.5 backbone at SGLANG_MOE_EXPERT_LOOKAHEAD distance 1 or 2): after its own top-k, a block runs the LATER block's gate + top-k on its MLP input (eager only), remaps to this rank's local ids under the expert-index shard, and hands (later FusedMoE, predicted ids) to its experts. - FusedMoE.set_lookahead/_take_lookahead: consumed by exactly one forward; the breakable and capturable routes drop it and count the drop. - MoEExpertOffloadCache.run_waves(lookahead=...): the prediction crosses the SAME D2H rendezvous as this forward's routing (one tolist for both); on a single-wave forward the later cache's prefetch is issued right after this layer's own fetch, on the copy stream WITHOUT joining compute (join=False), so the H2D overlaps this layer's GEMM. The later cache's next fetch joins. - Sticky scratch: every fetch (all routes) records slot -> expert in _scratch_holds (cleared on hot-set freeze / heat swap); with the switch on, the single-wave resolve keeps held experts in their slots and fetches only the misses (planner.resolve_sticky); off, resolve() and its pure-function layout are untouched. Slot choice decides where the grouped GEMM reads an expert's weights, not what it computes. - ResidencyStats: lookahead_prefetched / hits / misses / dropped (land in the sgl-project#390 dump). Tests (hermetic): tests/moe_offload/test_expert_lookahead_wp8.py (10) + cold_tier_fetch, build_lut, expert_stats, breakable_route_462, awq_presplit, ct_wna16_presplit, expert_index_shard_generic: 126 passed, 9 skipped. arm_fn1.sh: LOOKAHEAD=<0|1|2>.
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.
No description provided.