Skip to content

Pixi rebuilds all 36 Cython extensions on every pixi run (editable install temp dirs) #2138

Closed

Description

@rparolin

Symptom

Every invocation of pixi run -e cu13 python examples/<foo>.py rebuilds all 36 Cython extensions in cuda_bindings (~27s of C++ compilation work per run), even when nothing has changed.

Build output shows a fresh /tmp/tmpXXXXXXXX.build-temp/ and .build-lib/ directory each run.

Root cause (3 layers)

  1. pixi-build: sees cuda_bindings as a path dep and unconditionally runs uv pip install --editable ../cuda_bindings on every pixi run, even when nothing changed.

  2. setuptools: editable_wheel._create_wheel_file (editable_wheel.py:342-344) hardcodes:

    build_lib = TemporaryDirectory(suffix=".build-lib")
    build_tmp = TemporaryDirectory(suffix=".build-temp")

    These are brand-new empty dirs every time.

  3. build_ext: walks the 36 Cython extensions and asks "is the .so in build_lib newer than the .cpp source?" Since build_lib is fresh and empty, the answer is always "no" → recompile everything. 36 × ~750ms ≈ 27s per run.

Why the fix is non-trivial

Simply pinning the build dirs to a fixed location would change behavior for CI configurations running in parallel. A reasonable fix likely involves a build-system toggle (env var or pixi option) so local dev machines can opt into a stable build dir while CI keeps the current isolated behavior.

Possible workaround to investigate

Setting no-build-isolation = true under [pypi-options] in the pixi manifest may help. See: https://pixi.prefix.dev/latest/reference/pixi_manifest/#no-build-isolation

Activity

  1. added
    triage
    on May 25, 2026
  2. added theissue type on May 25, 2026
  3. added this to the cuda.core v1.1.0 milestone on May 25, 2026
  4. added
    P1
    on Jul 15, 2026
  5. mdboom commented on Jul 17, 2026

    @mdboom
    Contributor

    @rparolin: We got a little stuck on "fix pixi" vs. "remove pixi". Should we discuss that again?

  6. rparolin commented on Jul 17, 2026

    @rparolin
    CollaboratorAuthor

    yeah, we should circle back on that discussion. My read is that we still want a higher level build system but its unclear if people want to pivot from pixi to uv or just use pip. I'm one of the people that likes that pixi manages the venvs more as part of the repo configuration.

  7. msarahan commented on Jul 20, 2026

    @msarahan
    Member

    Supposedly this is fixed in recent pixi releases (0.71+). It looks like CI here is currently pinned to 0.66. Maybe it's worth trying an update?

    Codex summary:

    The CUDA-Python rebuild problem is already fixed on current Pixi main, beginning with Pixi v0.71.0. I avoided duplicating that implementation and added stronger regression coverage on branch codex/cuda-python-2138-regression. Nothing was committed, pushed, or published.
    Root cause
    Older Pixi source-build caching mishandled backend-reported input globs and paths. The resulting cache miss caused Pixi to invoke pixi-build-python again. Its editable setuptools build used fresh temporary directories, amplifying the redundant invocation into recompilation of all Cython extensions.
    The upstream fix in #6285:
    Uses a content-addressed artifact cache keyed by backend, platform, variants, build/host dependencies, and package configuration.
    Tracks structured input globs and absolute input paths.
    Checks source mtimes and re-globs for added files.
    Returns cached artifacts without starting the build backend.
    Uses cross-process read/write locks for CI concurrency.
    Uses an environment fingerprint to avoid relinking an identical package set.
    Cython inputs are separately tracked through #6123, so .pyx, .pxd, and .pxi changes still invalidate the artifact correctly.

  8. rparolin commented on Jul 21, 2026

    @rparolin
    CollaboratorAuthor

    Thanks @msarahan — spot on. I tried the bump and it fixes it. Validated locally in cuda_bindings -e cu13, running the exact same command twice with nothing changed in between, and timing the second run (the one that should be a no-op):

    ┌──────────────┬───────────────────────┬─────────────────────┐
    │ pixi version │ 2nd run wall-clock    │ extensions rebuilt  │
    ├──────────────┼───────────────────────┼─────────────────────┤
    │ 0.66.0       │ ~27 s (full rebuild)  │ 29 of 29            │
    │ 0.73.0       │ <1 s (nothing built) │ 0 of 29             │
    └──────────────┴───────────────────────┴─────────────────────┘
    

    So under 0.66 the second no-op run still spends ~27 s recompiling all 29 Cython extensions; under 0.73 it returns in under a second and builds nothing.

    One wrinkle worth flagging: the fix (pixi#6285 + #6123) is available starting 0.71.0, but every fix-carrying version also bumps the pixi.lock format from v6 → v7, which pixi 0.66 can't read. So it's a coordinated bump — all contributors need pixi ≥0.71. I went with the latest (v0.73.0) and regenerated all six committed lock files to v7.

    PR up at #2396.

  9. self-assigned this
    on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P1triage

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions