Skip to content

[Perf] engram: Read host-table rows in address order on GPUs without host page tables - #45879

Merged
hnyls2002 merged 1 commit into
mainfrom
lsyin/engram-sorted-host-reads
Oct 22, 2026
Merged

hnyls2002 merged 1 commit into
mainfrom
lsyin/engram-sorted-host-reads

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
  • engram_gather takes sort_ids: it sorts the ids, reads the rows in address order and stores each row at its original position. Output is bitwise identical.
  • EngramEmbedding turns it on for host tables only when CU_DEVICE_ATTRIBUTE_PAGEABLE_MEMORY_ACCESS_USES_HOST_PAGE_TABLES is 0, i.e. the GPU maps pinned host memory in its own page tables (PCIe hosts). On NVLink-C2C hosts the attribute is 1, reads go through the host page tables, sorting only adds work, and the path is unchanged. Device tables and HIP are unchanged. No new flag.
  • Why: random rows spread over a host table far larger than the GPU's address-translation reach miss on nearly every row; the same rows read in address order share pages, which makes the host-table lookup several times faster on PCIe hosts.

No behavior change except the order of host-table reads on GPUs without host page tables.

Verification: bitwise-equal gather output; DeepSeek-V4.1-Flash DEP4 with host Engram tables on a PCIe host is faster in prefill, and on an NVLink-C2C host the path is not taken (throughput unchanged); GSM8K unchanged.


CI States

Latest PR Test (Base): 🚫 Run #39841033519
Latest PR Test (Extra): ❌ Run #39841032986
Latest PR Test (AMD ROCm 10): 🚫 Run #39841033377

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test test_engram_history.py test_deepseek_v41_flash_gb300_dp2ep2.py test_deepseek_v41_flash_gb300_tp2ep2.py

@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_engram_history.py

🚀 2-gpu-gb300 (2 tests): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_dp2ep2.py
cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_tp2ep2.py

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 22, 2026
@hnyls2002
hnyls2002 merged commit ba83415 into main Oct 22, 2026
220 of 290 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/engram-sorted-host-reads branch October 22, 2026 20:13
ll2088 added a commit to ll2088/sglang that referenced this pull request Nov 2, 2026
#2)

perf(engram): add optional sorted host-table reads to engram_gather (from sgl-project#45879)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant