Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
| encoder.final_layernorm = nn.Identity() | ||
|
|
||
| output = encoder( | ||
| torch.ones(7, 4, device="meta"), |
Contributor
There was a problem hiding this comment.
what is the device of "meta" ?
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.
Summary
forward, then reuse them across all 27 encoder layers
max_seqlenbefore moving sequence metadatato CUDA
The current implementation converts Q/K to FP32 complex tensors, performs a
complex multiply, and copies the result back to the activation dtype in every
MoonViT layer. The fused in-place kernel removes those temporaries and launches.
Performance
Measured on NVIDIA H200 with BF16 MoonViT tensors (4 heads, head dim 72):
The maximum BF16 absolute difference against the portable path was 0.0078125.
Same-seed Kimi-K2.7-Code TP8 torch-profiler comparison on 8 requests with 4
random-sized images each:
Moving the host max-sequence calculation before the metadata H2D copy also
removed exactly one synchronization per MoonViT forward in a follow-up paired
trace:
cudaStreamSynchronizeMemcpy DtoH (Device -> Pinned)aten::itemCPU timebench_servingis neutral at this workload size, as expected for a roughly6 ms optimization inside a much larger prefill. Across three seeds, burst
throughput changed -0.65%, mean TTFT +0.21%, and median TTFT -0.02%; rate=4
results were also within run-to-run noise. This PR claims the isolated and
profiled MoonViT reduction, not a material end-to-end serving speedup alone.
Validation
pre-commit run --files python/sglang/srt/models/kimi_k25.py test/registered/unit/layers/attention/test_vision_max_seqlen.pypython3 -m pytest -q test/registered/unit/layers/attention/test_vision_max_seqlen.py(9 passed)CI States
Latest PR Test (Base): ❌ Run #29627829432
Latest PR Test (Extra): ❌ Run #29627829372