Skip to content

Port Kunlun adaptations to kunlun_v2#7

Merged
erichudev merged 3 commits into
kunlun_v2from
port-kunlun-commits-to-kunlun-v2
Jul 16, 2026
Merged

Port Kunlun adaptations to kunlun_v2#7
erichudev merged 3 commits into
kunlun_v2from
port-kunlun-commits-to-kunlun-v2

Conversation

@chaonanD

@chaonanD chaonanD commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Port the three Kunlun-specific commits from kunlun onto the clean kunlun_v2 branch based on current main.

This PR does not merge kunlun or include its previous main-sync history.

Ported commits

  • 1997b87feda56e78c6958179c05494fb534ac772 -> dad930b (changes for cosmos3 super inference)
  • c555de4f371954937993c576a5464fee45940d84 -> 9f04cd3 (Enable flashAttn2 varlen backend on Kunlun P800)
  • 4b037c5562bc743c0f3aba08a70986aad46d42fc -> a26345b (Replace NVML device affinity with XPUML)

The commits were cherry-picked in the requested order. The only cleanup was removal of trailing whitespace already present in the first source commit; it was folded into the corresponding ported commit.

Scope

  • Base branch: kunlun_v2
  • Base commit: 692c410583a2e1271cdc355ffe2ffe574c2ae625
  • Result: 3 commits, 14 changed files
  • Excluded: old sync commit 4923586 and all kunlun merge/revert history

Validation

  • All three cherry-picks completed without conflicts
  • git diff --check origin/kunlun_v2...HEAD: passed
  • python -m compileall -q conftest.py cosmos_framework: passed
  • GitHub pre-commit workflow: passed
  • Full pytest -q: stopped during collection because the local environment is missing omegaconf
  • Ruff: not run because ruff/uv is unavailable in the local environment

chaonanD added 3 commits July 16, 2026 15:09
- Remove the varlen ban in flash2 checks so the sequence-packed
  two_way attention path can select the flash2 backend
  (I4_ATTN_BACKENDS=flash2) instead of falling back to torch_sdpa.
- Normalize the varlen LSE layout: Kunlun's flash_attn_varlen_func
  returns [batch, H, max_seqlen] (padded per sample) whereas NVIDIA
  returns [H, total_tokens]. Un-pad using cu_seqlens_q so both builds
  produce [H, total_tokens].
- Add explicit `import torch` for the un-padding torch.cat.
* Replace NVML device affinity with XPUML
* Migrate remaining pynvml usages to XPUML

Replace NVML calls in conftest, device utils, inference args, and the
device monitor callback with torch_xmlir XPUML bindings.
@erichudev
erichudev merged commit 457f1bd into kunlun_v2 Jul 16, 2026
1 check passed
@chaonanD
chaonanD deleted the port-kunlun-commits-to-kunlun-v2 branch July 20, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants