Skip to content

Set up CI with Azure Pipelines - #1

Closed
azure-pipelines[bot] wants to merge 1 commit into
masterfrom
azure-pipelines
Closed

Set up CI with Azure Pipelines#1
azure-pipelines[bot] wants to merge 1 commit into
masterfrom
azure-pipelines

Conversation

@azure-pipelines

Copy link
Copy Markdown

No description provided.

@msftclas

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

❌ azure-pipelines[bot] sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

@raymondxyang
Raymond Yang (raymondxyang) deleted the azure-pipelines branch November 19, 2018 20:22
trent (tmccrmck) added a commit to tmccrmck/onnxruntime that referenced this pull request Aug 28, 2019
Nick Groszewski (groszewn) pushed a commit to groszewn/onnxruntime that referenced this pull request Nov 13, 2019
…essor_double

Update TreeEnsembleRegressor type support
Shucai Xiao (scxiao) referenced this pull request in ROCm/onnxruntime Feb 4, 2020
Chi Lo (chilo-ms) pushed a commit that referenced this pull request Jun 1, 2026
### Description

Add an internal session config entry, `"session.compile_only"`, set by
`CompileModel()` before
  session initialization. The NvTensorRTRTX EP reads it in
`NvExecutionProviderInfo::FromProviderOptions()` and, when set, skips
`deserializeCudaEngine()` /
  `createExecutionContext()` in `CreateNodeComputeInfoFromGraph()`.

The EP context node is still saved — that path uses the serialized
engine buffer directly and does
not depend on the deserialized engine. A stub compute function is
registered to satisfy the
framework; it returns `NOT_IMPLEMENTED` if called, which cannot happen
in practice because
  compile-only sessions are destroyed without inference.


### Motivation and Context

`OrtCompileAPI::CompileModel()` creates an `InferenceSession` solely to
drive `EP::Compile()` and
write out the EPContext model, then destroys it without running
inference. During that session, the
NvTensorRTRTX EP was performing a full `deserializeCudaEngine()` and
`createExecutionContext()` —
uploading engine weights to the GPU and JIT-ing the engine, only to free
everything when the session
  was destroyed.

When the user then loads the EPContext model in a real session, the same
JIT and upload happen again.
   Net effect on the typical "compile, then load and run" flow:

  ```
  ONNX model
      → CompileModel()         [JIT + GPU upload #1 — discarded]
      → EP context model saved to disk
      → Session from EP context model
                               [JIT + GPU upload #2 — necessary]
      → Inference
  ```

  JIT and GPU upload run twice.
Tianlei Wu (tianleiwu) added a commit that referenced this pull request Jul 27, 2026
)

### Description

`import onnxruntime` segfaults during `dlopen` of
`onnxruntime_pybind11_state.so` on Linux. This removes the global
initializer in `onnxruntime_pybind_state.cc` that eagerly calls
`Env::Default()`, and resolves the platform `Env` on first use at its
two call sites instead.

### Motivation and Context

The module has a namespace-scope dynamic initializer:

```cpp
static Env& platform_env = Env::Default();
```

Since POSIX telemetry landed (#27379), `Env::Default()` constructs
`PosixEnv`, whose `PosixTelemetry` member initializes the 1DS SDK in its
constructor. That path reads `defaultRuntimeConfig`, a namespace-scope
`static ILogConfiguration` defined in the 1DS SDK's
`RuntimeConfig_Default.hpp`, which lives in a **different translation
unit of the same shared library**.

Dynamic initialization order across translation units is unspecified,
and the pybind TU's initializer runs first. `Variant::merge_map`
therefore iterates a still zero-initialized `std::map`: `_M_node_count
== 0`, but `_M_header._M_left` is `nullptr` rather than self-pointing,
so `begin() != end()` and the loop dereferences null.

Textbook static initialization order fiasco. Backtrace (Release build
relinked without `--strip-all` to recover symbols):

```
#0  std::map<..., Variant>::lower_bound        stl_map.h:1307
#1  std::map<..., Variant>::operator[]         stl_map.h:509
#2  Variant::merge_map                         VariantType.hpp:508
#3  RuntimeConfig_Default::RuntimeConfig_Default  RuntimeConfig_Default.hpp:97
#4  LogManagerImpl::LogManagerImpl             LogManagerImpl.cpp:183
#5  LogManagerFactory::Create                  LogManagerFactory.cpp:36
#6  LogManagerFactory::lease
#7  LogManagerFactory::Get                     LogManagerFactory.hpp:71
#8  LogManagerProvider::Get                    LogManagerProvider.cpp:16
#9  onnxruntime::PosixTelemetry::Initialize()
#10 onnxruntime::PosixTelemetry::PosixTelemetry()
#11 onnxruntime::(anonymous namespace)::PosixEnv::PosixEnv()
#12 onnxruntime::Env::Default()
#13 _GLOBAL__sub_I_onnxruntime_pybind_state.cc
#14 call_init                                  elf/dl-init.c:74
...
#21 _dl_open                                   elf/dl-open.c:905
```

The crash is independent of `LD_LIBRARY_PATH` and `CUDA_VISIBLE_DEVICES`
— it happens before any ORT runtime code runs. `libonnxruntime.so` is
unaffected because it contains no global initializer that reaches
`Env::Default()`, which is why C/C++ and onnxruntime-genai consumers do
not see it.

Both remaining uses of `platform_env` are inside pybind lambdas that run
long after load, so calling `Env::Default()` there is safe. This also
removes the now-stale `TODO: we may delay-init this variable` and a
pre-existing `#pragma warning(push)` that should have been `pop`.

Note for follow-up: `Env::Default()` is now unsafe to call from any
dynamic initializer. This was the only such call site in the tree, but
hardening `PosixTelemetry` to defer SDK initialization out of its
constructor would remove the hazard entirely.

### Tests

Verified on a Linux CUDA 13 Release build (`onnxruntime_USE_TELEMETRY`
enabled):

- `dlopen` of `onnxruntime_pybind11_state.so` succeeds (previously
SIGSEGV).
- `import onnxruntime` reports the version and
`['CUDAExecutionProvider', 'CPUExecutionProvider']`.
- `onnxruntime.enable_telemetry_events()` / `disable_telemetry_events()`
— the two call sites changed here — work.
- CPU and CUDA inference sessions produce correct results.
- Reproduced and verified with `LD_LIBRARY_PATH` unset and
`CUDA_VISIBLE_DEVICES` empty.
Akshay Sonawane (apsonawane) added a commit that referenced this pull request Aug 5, 2026
…ression

This commit addresses all open review comments from PR #31651:

SECURITY FIX (Copilot Comment #1):
- Enhanced CheckBlockTableAndPastSeqLensValues() with comprehensive validation:
  * Added check that cumulative_sequence_length[0] == 0
  * Added non-negative checks for all cumulative_seqlens values
  * Improved error messages with specific invalid indices
  * Prevents invalid memory access in CUDA kernels

PERFORMANCE FIX (tianleiwu CHANGES_REQUESTED - Blocking):
- Eliminated unconditional device-to-host sync on critical path:
  * Moved validation into existing FA/MEA code path (lines 240-296)
  * Removed separate D->H copies + sync that duplicated existing work
  * Validation now only runs when Flash Attention/MEA is enabled
  * Reuses already-synced cumulative_q buffer where possible
  * Result: Zero overhead for non-FA/MEA paths, minimal for FA/MEA

EDGE CASE FIX (Copilot Suppressed Comment):
- Improved handling of full cache with zero new tokens:
  * When q_len == 0: Allow past_length anywhere in [0, max_cache_sequence_length]
  * When q_len > 0: Require space for both past and current query
  * Proper separation of logic for zero-token vs has-token cases

TEST COVERAGE (Copilot Comment #3):
- Added 5 new comprehensive test cases:
  * CheckBlockTableAndPastSeqLensValuesRejectsNegativeCumulativeSeqLen
  * CheckBlockTableAndPastSeqLensValuesRejectsCumulativeNotStartingAtZero
  * CheckBlockTableAndPastSeqLensValuesRejectsNegativePastSeqlens
  * CheckBlockTableAndPastSeqLensValuesAllowsFullCacheWithZeroTokens
  * CheckBlockTableAndPastSeqLensValuesRejectsFullCacheWithNewTokens
- Comprehensive boundary condition testing

Files changed:
- paged_attention_helper.h: Enhanced validation logic with security checks
- paged_attention.cc: Refactored to integrate validation with existing D->H sync
- paged_attention_helper_test.cc: Added 5 new test cases for edge cases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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