Skip to content

[paddle-adapt] fix: find and load libcudart dynamically via /proc/self/maps#25

Open
BingooYang wants to merge 1 commit into
PFCCLab:0.6from
BingooYang:adapt/fix_cudart_loading
Open

[paddle-adapt] fix: find and load libcudart dynamically via /proc/self/maps#25
BingooYang wants to merge 1 commit into
PFCCLab:0.6from
BingooYang:adapt/fix_cudart_loading

Conversation

@BingooYang
Copy link
Copy Markdown

📌 Description

Fix loading cudart.so by dynamically discovering the already-loaded library path via /proc/self/maps before falling back to the hardcoded CUDA_LIB_PATH.

Problem: The hardcoded path ${CUDA_LIB_PATH}/libcudart.so.12 often does not exist in PaddlePaddle environments (different CUDA installation layout), causing flashinfer.jit to silently skip loading cudart and leading to downstream JIT compilation failures.

Fix: Added find_loaded_library(lib_name) that reads /proc/self/maps to locate the already-in-process cudart .so, using that path first. The hardcoded fallback is retained for backward compatibility.

Changes:

  • flashinfer/jit/__init__.py: +32/-1, add find_loaded_library() + update cudart loading order

Regression verified (fi_paddle env):

  • norm/test_fused_rmsnorm_silu: ✅ PASS
  • norm/test_fused_dit_layernorm: ✅ 35 passed
  • moe/test_fp8_block_scale_routed_activation_type_relu2_smoke: ✅ PASS

🔍 Related Issues

Backport of dedaff1 to the 0.6 branch.

🚀 Pull Request Checklist

✅ Pre-commit Checks

  • Installed pre-commit via pip install pre-commit
  • Installed hooks with pre-commit install
  • Ran pre-commit run --files flashinfer/jit/__init__.py — all hooks passed (ruff-format auto-fixed, ruff check ✅, mypy ✅)

🧪 Tests

  • No test files modified (pure bug fix in library loading)
  • Regression tests passing: norm/rmsnorm_silu, dit_layernorm (35 passed), moe smoke test

Reviewer Notes

Minimal, self-contained fix. Only flashinfer/jit/__init__.py is changed. The find_loaded_library function gracefully returns None when not found, fully preserving backward compatibility.

- Add find_loaded_library() to search /proc/self/maps for a loaded .so
- Use the found cudart path first before falling back to hardcoded path
- Fixes loading cudart.so issues when CUDA_LIB_PATH does not match
- Regression: norm/rmsnorm_silu PASS, dit_layernorm 35 PASS, moe smoke PASS

Refs: MISMATCH_EXPERIMENT §21
BingooYang added a commit that referenced this pull request May 19, 2026
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.

1 participant