Skip to content

[FEA]: Add SM arch detection to CUDA-Pathfinder for LLVM bitcode files #2200

Open

Description

@benhg

Is this a duplicate?

Area

cuda.pathfinder

Is your feature request related to a problem? Please describe.

Since 3.7.0, NVSHMEM must ship arch-specific bitcode files (libnvshmem_device_smXX.bc) instead of libnvshmem_device.bc. The reason for this is that libnvshmem_device.bc was silently an SM90-only file, and that's not really an acceptable solution.

We attempted to ship a libnvshmem_device.bc which is a symlink to SM90 file just for compatibility, but I was unaware that symlinks are not supported in wheels.

So this is really an NVSHMEM Bug, but I think longer-term, there is a valid use case for arch-specific bitcode files.

Note that this is not as much of an issue for LTOIR files as they can be built into Fatbins for many architectures.

Describe the solution you'd like

Add an optional "sm_arch" kwarg to find_bitcode_lib:

cuda.pathfinder.find_bitcode_lib(name: str, sm_arch: str="") → str

If sm_arch is not set, it will find the corresponding .bc file for the library only. If it is set, it will find {lib name}_{sm_arch}.bc

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. rwgk commented on Jun 11, 2026

    @rwgk
    Contributor

    Looks good to me, but a small API nit: I’d prefer sm_arch: str | None = None over sm_arch: str = "", since absence seems semantically cleaner than an empty architecture string.

    One thing worth thinking about before this becomes a public API: should sm_arch be validated/normalized, e.g. accept only sm_90/sm90/90 in a documented form? Deciding that now is easier than hardening the API later.

  2. benhg commented on Jun 11, 2026

    @benhg
    MemberAuthor

    That's fine to me.

    One thing worth thinking about before this becomes a public API: should sm_arch be validated/normalized, e.g. accept only sm_90/sm90/90 in a documented form? Deciding that now is easier than hardening the API later.

    I agree. I don't have a preference. what NVSHMEM does today is sm90, but of course we can change the API surface to wrap around variants for libraries if we need to.

  3. rwgk commented on Jun 11, 2026

    @rwgk
    Contributor

    I agree. I don't have a preference. what NVSHMEM does today is sm90, but of course we can change the API surface to wrap around variants for libraries if we need to.

    My first choice would be to validate fairly strictly before building the filename. I don’t feel strongly about the public spelling, but I’d prefer we document one canonical form and normalize from there rather than accepting arbitrary suffixes.

    Maybe accept something like sm90/sm90a at the API boundary, then map to the package filename convention (sm90, etc.) if needed? Mostly I’d like this to be a re.fullmatch-style check rather than free-form string concatenation.

  4. benhg commented on Jun 11, 2026

    @benhg
    MemberAuthor

    Sounds good to me.

  5. added
    featureNew feature or request
    cuda.pathfinderEverything related to the cuda.pathfinder module
    on Jun 11, 2026
  6. added this to the cuda.pathfinder next milestone on Jun 11, 2026
  7. removed
    triageNeeds the team's attention
    on Jun 11, 2026
  8. rwgk commented on Jul 1, 2026

    @rwgk
    Contributor

    Hi @benhg, @leofang is generalizing the pathfinder nvshmem pinning under #2286, as an emergency fix so that our CI goes green again.

    I'm a bit concerned if we leave nvshmem >= 3.7.0 as unsupported by pathfinder for an extended period of time. What could we do to avoid that?

  9. benhg commented on Jul 1, 2026

    @benhg
    MemberAuthor

    Hi @rwgk, the easiest thing to do is make pathfinder return just the sm90 bitcode for nvshmem. That matches pre-3.7 behavior.

  10. rwgk commented on Jul 1, 2026

    @rwgk
    Contributor

    Hi @rwgk, the easiest thing to do is make pathfinder return just the sm90 bitcode for nvshmem. That matches pre-3.7 behavior.

    Between that, and #2201, I'd strongly favor 2201.

    Reason: otherwise people will start to hack around the lack of the 2201 feature, e.g. by engineering the path for other sm versions by taking the dirname of what find_bitcode_lib("nvshmem_device") returns and then manufacture the version-specific full path. So we'll essentially have many adhoc versions of 2201 floating around in the wild. I think we're doing the community a favor by taking a little bit of ownership here to manage the tiny API extension under 2201.

    @leofang for visibility

  11. benhg commented on Jul 6, 2026

    @benhg
    MemberAuthor

    After discussion, we've decided to change from adding new arguments to find_bitcode_lib, to adding a new function find_bitcode_lib_by_name instead, which will search in that project's lib directory for a specific name. Libraries can wrap that function to provide search across any attributes.

  12. rwgk commented on Jul 20, 2026

    @rwgk
    Contributor

    I've been thinking through the tradeoffs between the two alternative approaches in #2201 and #2302. I think they optimize for different API requirements:

    • 2302 avoids teaching Pathfinder every package-specific filename convention, or accumulating specialized parameters such as sm_arch, ABI, LTO mode, and so on.
    • 2201 avoids exposing a lower-level search primitive that accepts caller-supplied physical filenames and broadens Pathfinder's otherwise curated artifact-discovery.

    Both approaches draw technically coherent boundaries:

    • In 2302, the caller owns the desired artifact name while Pathfinder owns installation-layout discovery. The search is limited to expected directories and validates basenames, so it is not arbitrary filesystem access.
    • In 2201, callers express the semantic property they care about, while Pathfinder owns the filename convention and its evolution. That is more consistent with Pathfinder's existing, deliberately controlled APIs.

    The distinction that matters most to me is that sm_arch is a property of the requested artifact, whereas a filename is a packaging and storage detail. Keeping that detail centralized lets Pathfinder adapt when package layouts or filenames change without pushing the same naming logic into every consumer. It also keeps user code minimal and stable: callers should need to change code only when their artifact requirements change, not merely because a wheel starts using a different raw filename.

    My preference is therefore to build on #2201 and strengthen its controlled, semantic contract:

    1. Keep find_bitcode_lib(..., sm_arch=None) as the public API.
    2. Model supported SM variants per library and report unsupported combinations clearly.

    An exact-name lookup can still be useful as an internal implementation primitive. I would prefer to consider exposing that broader, lower-level API only when we have concrete additional use cases that require it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cuda.pathfinderEverything related to the cuda.pathfinder modulefeatureNew feature or request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions