Skip to content

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 16, 2025

Closes #1670


📚 Documentation preview 📚: https://pytensor--1673.org.readthedocs.build/en/1673/

@ricardoV94 ricardoV94 force-pushed the fix_ccache_bug branch 3 times, most recently from e3668de to 593038b Compare October 16, 2025 16:03
@ricardoV94
Copy link
Member Author

ricardoV94 commented Oct 16, 2025

PS I don't love the shared baseclass of Constant and NominalVariables as "atomics". They are more like root variables (always required) than constants. The only difference between nominal and generic root variables is that they evaluate equal based on the "position / type" instead of id.

from pytensor.graph.basic import NominalVariable
from pytensor.tensor.type import TensorType

ScalarType = TensorType(dtype="float64", shape=())

n1 = NominalVariable(0, ScalarType)
n2 = NominalVariable(0, ScalarType)
n3 = NominalVariable(1, ScalarType)

t1 = ScalarType()
t2 = ScalarType()

assert n1 == n2 != n3 and t1 != t2

That's however tangential to the bug here. It could be emulated just with regular variables and constants, as in the first test

Copy link

codecov bot commented Oct 16, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.63%. Comparing base (27c21cd) to head (3b3c110).

Files with missing lines Patch % Lines
pytensor/link/c/basic.py 75.00% 0 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (75.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1673   +/-   ##
=======================================
  Coverage   81.63%   81.63%           
=======================================
  Files         242      242           
  Lines       53569    53569           
  Branches     9451     9451           
=======================================
  Hits        43732    43732           
- Misses       7360     7362    +2     
+ Partials     2477     2475    -2     
Files with missing lines Coverage Δ
pytensor/link/c/basic.py 87.44% <75.00%> (-0.31%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 requested a review from Copilot October 17, 2025 11:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a C-cache bug related to the input order of nominal variables in PyTensor's C linker. The issue occurred when compiling variants of the same graph with different orders of atomic inputs, which led to incorrect cache key generation and potential runtime errors.

Key changes:

  • Modified the in_sig function in CLinker.cmodule_key_ to properly handle nominal variables that appear in the inputs list
  • Added comprehensive test cases covering both constant and nominal variable scenarios with different input orderings

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pytensor/link/c/basic.py Fixed cache key generation logic to correctly identify and handle nominal/constant variables in input lists
tests/link/c/test_basic.py Added regression tests for input order variations and C/CVM linker compatibility with nominal variables

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ricardoV94 ricardoV94 merged commit 84252b5 into pymc-devs:main Oct 20, 2025
4 of 6 checks passed
@ricardoV94 ricardoV94 added bug Something isn't working C-backend labels Oct 20, 2025
@ricardoV94 ricardoV94 deleted the fix_ccache_bug branch October 20, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working C-backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caching error between C and CVM linkers

2 participants