Add secure, transactional CUDA and WebGPU EP bootstrapping - #952
Merged
Baiju Meswani (baijumeswani) merged 11 commits intoAug 8, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Copilot started reviewing on behalf of
Baiju Meswani (baijumeswani)
August 5, 2026 22:17
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a shared, transactional installer for CUDA and WebGPU execution-provider bundles.
Changes:
- Adds verified, reusable bundle installation with atomic activation.
- Adds CUDA platform manifests, NVML detection, and dependency ownership.
- Replaces external ZIP extraction and expands security-focused tests.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
sdk_v2/cpp/vcpkg.json |
Adds archive dependencies. |
sdk_v2/cpp/CMakeLists.txt |
Builds and links new components. |
sdk_v2/cpp/src/ep_detection/cuda_ep_bootstrapper.cc |
Installs and registers CUDA bundles. |
sdk_v2/cpp/src/ep_detection/cuda_ep_bootstrapper.h |
Updates CUDA bootstrapper ownership. |
sdk_v2/cpp/src/ep_detection/cuda_ep_manifest.cc |
Defines platform CUDA bundles. |
sdk_v2/cpp/src/ep_detection/cuda_ep_manifest.h |
Declares CUDA manifest APIs. |
sdk_v2/cpp/src/ep_detection/ep_bundle_installer.cc |
Implements transactional installation. |
sdk_v2/cpp/src/ep_detection/ep_bundle_installer.h |
Declares installer transactions. |
sdk_v2/cpp/src/ep_detection/ep_bundle_manifest.h |
Defines bundle metadata. |
sdk_v2/cpp/src/ep_detection/ep_utils.cc |
Manages Windows dependencies. |
sdk_v2/cpp/src/ep_detection/ep_utils.h |
Exposes dependency helpers. |
sdk_v2/cpp/src/ep_detection/nvml_gpu_detector.cc |
Implements NVML GPU detection. |
sdk_v2/cpp/src/ep_detection/nvml_gpu_detector.h |
Declares GPU detection APIs. |
sdk_v2/cpp/src/ep_detection/webgpu_ep_bootstrapper.cc |
Migrates WebGPU to bundles. |
sdk_v2/cpp/src/ep_detection/webgpu_ep_bootstrapper.h |
Updates WebGPU bootstrapper ownership. |
sdk_v2/cpp/src/http/http_download.cc |
Adds strict size handling. |
sdk_v2/cpp/src/http/http_download.h |
Extends downloader contract. |
sdk_v2/cpp/src/manager.cc |
Updates EP lifecycle and teardown. |
sdk_v2/cpp/src/manager.h |
Documents revised ownership order. |
sdk_v2/cpp/src/util/zip_extract.cc |
Adds in-process bounded extraction. |
sdk_v2/cpp/src/util/zip_extract.h |
Defines extraction limits. |
sdk_v2/cpp/test/CMakeLists.txt |
Registers new unit tests. |
sdk_v2/cpp/test/internal_api/c_api_test.cc |
Tests manager recreation. |
sdk_v2/cpp/test/internal_api/cuda_ep_bootstrapper_test.cc |
Tests CUDA manifests and behavior. |
sdk_v2/cpp/test/internal_api/ep_bundle_installer_test.cc |
Tests installation transactions. |
sdk_v2/cpp/test/internal_api/ep_utils_test.cc |
Tests dependency selection. |
sdk_v2/cpp/test/internal_api/http_download_test.cc |
Tests Content-Length parsing. |
sdk_v2/cpp/test/internal_api/nvml_gpu_detector_test.cc |
Tests capability filtering. |
sdk_v2/cpp/test/internal_api/webgpu_ep_bootstrapper_test.cc |
Tests WebGPU registration. |
sdk_v2/cpp/test/internal_api/zip_extract_test.cc |
Tests secure extraction. |
sdk_v2/cpp/test/utils/scoped_environment_variable.h |
Adds environment test helper. |
sdk_v2/cpp/test/utils/zip_builder.h |
Adds ZIP fixture builder. |
Scott McKay (skottmckay)
previously approved these changes
Aug 7, 2026
Baiju Meswani (baijumeswani)
enabled auto-merge (squash)
August 7, 2026 22:56
Baiju Meswani (baijumeswani)
deleted the
baijumeswani/secure-ep-bootstrapping
branch
August 8, 2026 00:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change adds first-class CUDA execution-provider bootstrapping for Windows x64, Windows ARM64, and Linux x64. It also moves WebGPU onto the same reusable bundle installer so both providers follow one secure, transactional installation flow.
CUDA is treated as one compatible bundle assembled from independently reusable artifacts. The large CUDA and cuDNN packages change less frequently than the execution-provider package, so Foundry Local validates each installed artifact before downloading anything. If the CUDA or cuDNN runtime-file hashes are unchanged, those files are reused and only changed artifacts are downloaded. The reused and newly downloaded files are then assembled, verified, and atomically activated as one generation.
On Windows, provider dependencies are made discoverable at model-load time using
SetDllDirectoryW. This avoids eagerly loading the full CUDA bundle while still supporting downstream bare-name DLL loads performed by ONNX Runtime GenAI. On Linux x64,libonnxruntime-genai-cuda.sois preloaded withRTLD_NOW | RTLD_GLOBALand retained for the bootstrapper lifetime.Bundle installer responsibilities
The shared installer provides one implementation for:
Architecture
The bootstrappers describe their bundles and handle provider-specific registration. The shared installer owns the package lifecycle.
Shared bundle installation
Activation and provider registration
The install transaction keeps the cross-process lock until registration succeeds or is rolled back.
The transaction retains its logger, so destructor-triggered rollback can report recovery failures instead of failing silently.
Provider registration and model loading
SetDllDirectoryWis process-global, but model loads are serialized and the directory is selected immediately before GenAI model construction. This supports GenAI's bare-name DLL loads without preloading the CUDA and cuDNN bundle.CUDA platform support
WebGPU behavior
WebGPU uses the shared bundle installer on its supported platforms.
Generic GPU models continue to prefer CUDA when CUDA is registered. If CUDA is unavailable and WebGPU is registered, the model uses WebGPU. The Windows WebGPU bundle directory is prepared with
SetDllDirectoryWbefore model construction so delayed dependencies such as DXCompiler can be discovered.WebGPU uses the same:
Installation and repair behavior
Valid active bundle
Every declared runtime file is rehashed. If all hashes and the exact installed file set match, the existing generation is reused without downloading.
Partially damaged bundle
Each artifact is checked independently. Valid artifact files are copied into a new staging generation, while only invalid artifacts are downloaded again. The combined generation is fully verified before activation.
Forced installation
A forced request downloads every artifact instead of selectively reusing installed files.
Concurrent processes
Each provider uses its own OS-backed cross-process file lock. Only one process can install and register a given EP at a time. Other processes wait for the lock and then reuse the verified active generation. Different providers use different locks and may install concurrently.
The lock is held through provider registration and transaction finalization. OS locks are released automatically when a process exits; the lock file remaining on disk does not indicate that the lock is still held.
Failure or cancellation
Failed downloads, hash mismatches, malformed archives, cancellation, activation failures, and registration failures return failure for that provider. Temporary staging data is removed, and the previous active generation is restored when registration fails after activation.
EpDetectorattempts the remaining requested providers after one provider fails. It stops early only when the caller cancels through the progress callback. The result reports both successfully registered and failed providers.EP artifact downloads currently restart from the beginning after an interruption; resumable range downloads are not part of this change.
Recovery behavior
The installer is designed to recover without manual cache deletion:
Manual cleanup should only be necessary for external filesystem failures such as broken permissions, antivirus interference, or directories that the operating system refuses to remove.
Security and reliability
Content-Length.Content-Lengthparsing.NVIDIA GPU detection
CUDA eligibility is detected through NVML. Foundry Local requires at least one NVIDIA device with the supported compute capability. NVML is loaded dynamically and released after detection.