Repository navigation
Commit 3b45e02
Fix Linux wheel C++ runtime loading (#1566)
Summary:
Pull Request resolved: #1566
Linux PyPI wheels bundle a renamed private libstdc++ because conda-forge
runtime dependencies require newer GLIBCXX symbols than manylinux_2_28's
system libstdc++ provides.
The original import failure was caused by loading that private C++ runtime before
PyTorch under Python's default RTLD_LOCAL mode:
import pymomentum.geometry
import torch
That lets a second libstdc++ instance exist in the process before torch._C is
loaded, and torch can segfault during import.
A scoped RTLD_GLOBAL loader makes that order pass, but it is not a correct fix:
it exposes PyMomentum's private libstdc++ symbols to the whole process. In the
opposite order, that can poison later native library loads. In particular,
Triton's compiler fails in ConvertTritonGPUToLLVM after this order:
import torch
import pymomentum.geometry
import pymomentum.quaternion # backend=\"triton\"
Fix this by changing the Linux wheel repair shim to import torch, when torch is
available, immediately before loading any PyMomentum native extension. The
extension still loads with Python's normal RTLD_LOCAL behavior, so PyMomentum's
private libstdc++ remains hidden from later native extensions such as Triton,
while torch owns the process-global C++ runtime state before PyMomentum's private
runtime is loaded.
The generated pymomentum/__init__.py is added only during Linux wheel repair.
This keeps macOS and Windows behavior unchanged for now because the known bug is
in Linux ELF/dlopen/libstdc++ interaction. If we later want one package shape on
all platforms, we can move a no-op-on-non-Linux __init__.py into the source tree,
but that should be a separate deliberate package-shape change.
Also expand wheel smoke tests so every wheel variant installs torch and checks
the pymomentum.geometry-before-torch order. The strict GPU wheel test continues
to require CUDA and Triton.
Reviewed By: cstollmeta
Differential Revision: D110929696
fbshipit-source-id: c46695726d1ecd76e04ff10cff5c1080b82e22b61 parent 31d0933 commit 3b45e02
2 files changed
Lines changed: 145 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
367 | | - | |
368 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
369 | 371 | | |
370 | 372 | | |
371 | 373 | | |
| |||
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
380 | 456 | | |
381 | 457 | | |
382 | 458 | | |
| |||
392 | 468 | | |
393 | 469 | | |
394 | 470 | | |
395 | | - | |
396 | 471 | | |
397 | 472 | | |
398 | 473 | | |
| |||
462 | 537 | | |
463 | 538 | | |
464 | 539 | | |
465 | | - | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
466 | 544 | | |
467 | 545 | | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
473 | 554 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | 555 | | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | 556 | | |
485 | 557 | | |
486 | | - | |
487 | 558 | | |
488 | 559 | | |
489 | 560 | | |
490 | | - | |
| 561 | + | |
491 | 562 | | |
492 | 563 | | |
493 | | - | |
494 | 564 | | |
495 | 565 | | |
496 | 566 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | 134 | | |
137 | 135 | | |
138 | 136 | | |
| |||
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
290 | 305 | | |
291 | 306 | | |
292 | 307 | | |
| |||
305 | 320 | | |
306 | 321 | | |
307 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
308 | 338 | | |
309 | 339 | | |
310 | 340 | | |
| |||
374 | 404 | | |
375 | 405 | | |
376 | 406 | | |
377 | | - | |
| 407 | + | |
378 | 408 | | |
379 | 409 | | |
380 | 410 | | |
| |||
385 | 415 | | |
386 | 416 | | |
387 | 417 | | |
| 418 | + | |
388 | 419 | | |
389 | 420 | | |
390 | 421 | | |
| |||
395 | 426 | | |
396 | 427 | | |
397 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
398 | 444 | | |
399 | 445 | | |
400 | 446 | | |
| |||
465 | 511 | | |
466 | 512 | | |
467 | 513 | | |
468 | | - | |
| 514 | + | |
469 | 515 | | |
470 | 516 | | |
471 | 517 | | |
| |||
0 commit comments