Skip to content

Conversation

@stevenwalton
Copy link

Converted install process to work with uv and virtual environments. While doing so I performed general upgrades to the setup file and our project file will make NATTEN more easily searchable on pypi

Changes

  • Created the pyproject.toml file
    • Also introduced classifiers for pypi. Compare torch to natten on left hand side.
  • Reformatted setup.py: This file should now be easier to edit for future architectures and flexible to other types of changes. Please review
  • Makefile now loads programs from the user's environment. This was the main issue previously as it would build natten into the wrong python version if you used environments.
  • CMakeLists was missing the ability to pass CMAKE_CUDA_FLAGS from the setup.py file. Now we can. Do we can run CMAKE_CUDA_FLAGS="-Wno-deprecated-declarations" uv pip install -e . if we want to turn off the cutlass deprecation warnings while building.
  • Removed requirements.txt: now handled by pyproject.toml
  • Removed requirements-dev.txt: now handled by pyproject.toml
  • Removed setup.cfg: No longer needed
  • Added uv.lock
  • Documented setup.py

Build process

$ git clone --recursive https://github.com/SHI-Labs/NATTEN
$ cd NATTEN

Option 1: Explicit

# Create the venv (default path is .venv)
# --seed means we pull in pip and other tools
# -p == --python
$ uv venv --seed -p 3.9

# Load venv
$ source .venv/bin/activate

# Install natten. Will do dependency resolution
# uv isn't needed because we did --seed
$ uv pip install -e .

# Get some tea, it'll be a bit

Option 2: One liner

# Create a venv based on pyproject.toml 
# We pass python version as by default it will use your most current version
$ uv sync -p 3.9

# Get some tea, it is installing natten too

Option 3: Build

# Do Option 1 but instead of the pip line 
$ uv build

# Get some tea

# Install wheel
$  uv pip install dist/natten-0.21.1-cp39-cp39-linux_x86_64.whl

After each of these options you may run the profile commands

Verified systems

  • OSX M2 Air
  • EndeavourOS with 4080S (sm89)

TODO:

  • @alihassanijr , you will need to edit pyproject.toml on lines 22 and 25 to add your email address. We can either keep authors as is or include all contributors. Maintainers is what pypi shows and should stay you.
  • Review
  • Test on other architectures (should be fine)
    • SM90
    • SM100
  • Clean up as we may not need some other files and dev dependencies like flake

stevenwalton and others added 8 commits August 18, 2025 17:31
Just a simple demonstration of converting this project to uv.

Install uv with
```
$ curl -LSsf https://astral.sh/uv/install.sh -o /tmp/uvinstall.sh \
        && sh /tmp/uvinstall.sh
$ curl -LSsf https://astral.sh/uv/install.sh | sh
```
Then do the following
```
$ uv run pytest -v -x ./tests
```

You can also build with which places wheels and zips in `dist/`
```
$ uv build
```

I've also slightly updated the Makefile to use the python and pip from
the local environment.
Builds fine on my machine. Pushing to pull and then test in clean
directory and on mac to make sure cpu only version works out.
The will perform cleanup duties.
So this is kinda working but there's still some issues with the setup.py
file.
These issues are kinda old so I'm just going to resolve them.
Mainly the problems are with the logic and environment detections.
That whole file is going to change so pushing this up first.
(Probably don't actually need setuptools-cuda but will fix that with the
 next fix)
The following commands work:
uv pip install -e .
uv build

I have also made significant changes for added flexibility.
We use a global env dictionary to handle all our variables compactly.
We also modified the way that the autogen policies are created so that
we may be more flexible to future builds and options. This should lead
to better extendability

Tested on Linux with 4080S.
Still need to test on other hardware
stevenwalton added a commit to stevenwalton/NATTEN that referenced this pull request Nov 1, 2025
This is the setup.py file from PR SHI-Labs#273
Updated with the minor change needed for blackwell ultra

Minor change to src/natten/profiler:
f-strings had use of " inside f (e.g. f"{", ".join(...)}.")
This is not supported in all python versions and is bad practice as it
is less readable.
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.

1 participant