ProblemWhen KV-cache memory pressure triggered request preemption, waiting queue indices shifted without re-indexing, silently skipping incoming priority inference requests.
SolutionRecalculated queue offsets and preserved priority invariants during preemption eviction passes in policy.py.
OutcomeEliminated silent starvation for prioritized enterprise inference requests under heavy batch load.
@@ -184,8 +184,10 @@ def _preempt_by_priority(self, waiting_queue):
for idx, req in enumerate(waiting_queue):
- if req.priority < victim.priority:
- self._evict_block(req)
+ if req.priority < victim.priority and req.is_scheduled:
+ self._evict_and_reindex(waiting_queue, idx)
+ break
return self._rebalance_budget(waiting_queue)
ProblemConverting Block Sparse Row (BSR) tensors with zero-dimension block shapes triggered a hard C++ floating-point exception (division-by-zero) crashing the Python runtime.
SolutionAdded explicit zero-dimension dimension validation and guard assertions prior to block stride computation in ATen C++ kernel.
OutcomeTurned fatal segmentation crashes into recoverable PyTorch invalid argument exceptions.
@@ -412,6 +412,9 @@ Tensor sparse_compressed_to_dense(const Tensor& self) {
auto block_shape = self.sparse_dim_block_shape();
+ TORCH_CHECK(block_shape[0] > 0 && block_shape[1] > 0,
+ "BSR block dimensions must be positive, got ", block_shape);
const int64_t nnz = self._nnz();
- int64_t stride = nnz / (block_shape[0] * block_shape[1]);
+ int64_t stride = nnz / std::max<int64_t>(1, block_shape[0] * block_shape[1]);
return dense_out;
ProblemAddressSanitizer caught an out-of-bounds heap buffer read when malformed compressed row pointers pointed past the end of allocated index buffers.
SolutionEnforced strict monotonic bounds checking on compressed index vectors before invoking CPU vector conversion loops.
OutcomePatched memory safety vulnerability across all CPU sparse-to-dense matrix conversions.
@@ -89,7 +89,8 @@ void sparse_compressed_to_dense_cpu_kernel(...) {
for (int64_t r = 0; r < num_rows; ++r) {
- int64_t start = row_ptr[r], end = row_ptr[r + 1];
+ int64_t start = row_ptr[r];
+ int64_t end = std::min(row_ptr[r + 1], total_elements);
+ TORCH_CHECK(start <= end, "Corrupted row pointer index array");
for (int64_t i = start; i < end; ++i) {
ProblemThe PyTorch FX graph tracer emitted incorrect tuple return type annotations for multi-tensor ops, breaking downstream static analysis and TorchScript graph export.
SolutionUpdated FX schema parser to reconstruct parameterized tuple types from operator registration schemas rather than decaying to generic tuple.
OutcomeFixed downstream compiler type mismatches for Inductor and AOTAutograd graph captures.
@@ -231,7 +231,7 @@ def get_signature_for_torch_op(op):
if isinstance(ret_type, torch.TupleType):
- return Tuple
+ element_types = [map_torch_type_to_py(t) for t in ret_type.elements()]
+ return Tuple[tuple(element_types)] if element_types else Tuple
return map_torch_type_to_py(ret_type)
ProblemWhen source and destination paths pointed to the same physical inode through symlinks, catching EEXIST and unlinking destination accidentally wiped the source file.
SolutionAdded an os.path.samefile() guard in file_utils.py to detect inode equivalence and exit early before unlinking.
OutcomeStopped silent source file deletion during complex staged snapcraft builds across Ubuntu.
@@ -44,6 +44,8 @@ def link_or_copy(source: Path, destination: Path) -> None:
try:
+ if destination.exists() and os.path.samefile(source, destination):
+ return # Source and destination share inode; do not unlink.
os.link(source, destination)
- except FileExistsError:
- destination.unlink()
+ except FileExistsError:
+ if not os.path.samefile(source, destination): destination.unlink()
ProblemThousands of competitive programming editor UI strings lacked internationalization, while concurrent search re-indexing caused duplicate candidate lists.
SolutionEngineered an automated validation pipeline to translate and verify 3,600+ UI strings, and deduplicated Qt search indexing passes.
OutcomeDelivered full localization support and removed duplicate search stutter for competitive programmers worldwide.
@@ -120,6 +120,7 @@ void SearchIndex::addToken(const QString &token, int line) {
if (token.trimmed().isEmpty()) return;
- m_tokens.append({token, line});
+ if (!m_tokenSet.contains(token)) {
+ m_tokenSet.insert(token);
+ m_tokens.append({token, line});
+ }