From 83ebed849e23043c237e341c6c02f8555469e7e8 Mon Sep 17 00:00:00 2001 From: athms Date: Fri, 23 Feb 2024 09:15:51 +0000 Subject: [PATCH 1/8] adding setup.py --- setup.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7b847cd --- /dev/null +++ b/setup.py @@ -0,0 +1,24 @@ +from setuptools import setup + +with open('README.md') as f: + readme = f.read() + +with open('requirements.txt') as f: + requirements = f.read().split('\n') + +sources = {'stripedhyena': 'src'} + +setup( + name='stripedhyena', + version='0.2.0', + description='StripedHyena', + long_description=readme, + long_description_content_type='text/markdown', + author='together.ai', + url='http://github.com/togethercomputer/stripedhyena', + license='Apache-2.0', + packages=sources.keys(), + package_dir=sources, + install_requires=requirements, + python_requires='>=3.6', +) \ No newline at end of file From 640d8d4a472b18b97d058179b3d200646be67066 Mon Sep 17 00:00:00 2001 From: athms Date: Fri, 23 Feb 2024 09:29:09 +0000 Subject: [PATCH 2/8] use find_packages instead of hardcoding sources --- setup.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 7b847cd..f0affc0 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages with open('README.md') as f: readme = f.read() @@ -6,8 +6,6 @@ with open('requirements.txt') as f: requirements = f.read().split('\n') -sources = {'stripedhyena': 'src'} - setup( name='stripedhyena', version='0.2.0', @@ -17,8 +15,7 @@ author='together.ai', url='http://github.com/togethercomputer/stripedhyena', license='Apache-2.0', - packages=sources.keys(), - package_dir=sources, + packages=find_packages(), install_requires=requirements, python_requires='>=3.6', ) \ No newline at end of file From ec3e385c03371c912dff648c28839702a3cd5e96 Mon Sep 17 00:00:00 2001 From: athms Date: Fri, 23 Feb 2024 18:05:49 +0000 Subject: [PATCH 3/8] removing pyptoject.toml --- pyproject.toml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 1433aca..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,24 +0,0 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" - -[project] -name = "stripedhyena" -version = "0.2.0" -description = "Model and inference code for beyond Transformer architectures" -readme = "README.md" -authors = [{ name = "Michael Poli"}] -dependencies = [ - "transformers", - "tokenizers", - "flash_attn>=2.0.0" -] - -[tool.black] -line-length = 119 - -[tool.isort] -profile = "black" -line_length = 119 -combine_as_imports = true -combine_star = true From ea30b9a950093ecdcc449b1bc88e9c4176716779 Mon Sep 17 00:00:00 2001 From: Zymrael Date: Fri, 23 Feb 2024 18:25:20 +0000 Subject: [PATCH 4/8] chore: add setup.py, fix find_packages --- .gitignore | 1 + pyproject.toml | 3 ++- setup.py | 9 ++++----- {src => stripedhyena}/__init__.py | 0 {src => stripedhyena}/cache.py | 0 {src => stripedhyena}/engine.py | 0 {src => stripedhyena}/generation.py | 0 {src => stripedhyena}/layers.py | 2 +- {src => stripedhyena}/model.py | 0 {src => stripedhyena}/positional_embeddings.py | 0 {src => stripedhyena}/sample.py | 0 {src => stripedhyena}/tokenizer.py | 0 {src => stripedhyena}/utils.py | 0 13 files changed, 8 insertions(+), 7 deletions(-) rename {src => stripedhyena}/__init__.py (100%) rename {src => stripedhyena}/cache.py (100%) rename {src => stripedhyena}/engine.py (100%) rename {src => stripedhyena}/generation.py (100%) rename {src => stripedhyena}/layers.py (99%) rename {src => stripedhyena}/model.py (100%) rename {src => stripedhyena}/positional_embeddings.py (100%) rename {src => stripedhyena}/sample.py (100%) rename {src => stripedhyena}/tokenizer.py (100%) rename {src => stripedhyena}/utils.py (100%) diff --git a/.gitignore b/.gitignore index bee8a64..f284384 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ __pycache__ +*egg* diff --git a/pyproject.toml b/pyproject.toml index 1433aca..91ac4e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,10 @@ build-backend = "setuptools.build_meta" [project] name = "stripedhyena" -version = "0.2.0" +version = "0.2.1" description = "Model and inference code for beyond Transformer architectures" readme = "README.md" +license = {file = "LICENSE"} authors = [{ name = "Michael Poli"}] dependencies = [ "transformers", diff --git a/setup.py b/setup.py index f0affc0..59446ab 100644 --- a/setup.py +++ b/setup.py @@ -8,14 +8,13 @@ setup( name='stripedhyena', - version='0.2.0', - description='StripedHyena', + version='0.2.1', + description='Model and inference code for beyond Transformer architectures', long_description=readme, long_description_content_type='text/markdown', - author='together.ai', + author='Michael Poli', url='http://github.com/togethercomputer/stripedhyena', license='Apache-2.0', - packages=find_packages(), + packages=find_packages(where="stripedhyena"), install_requires=requirements, - python_requires='>=3.6', ) \ No newline at end of file diff --git a/src/__init__.py b/stripedhyena/__init__.py similarity index 100% rename from src/__init__.py rename to stripedhyena/__init__.py diff --git a/src/cache.py b/stripedhyena/cache.py similarity index 100% rename from src/cache.py rename to stripedhyena/cache.py diff --git a/src/engine.py b/stripedhyena/engine.py similarity index 100% rename from src/engine.py rename to stripedhyena/engine.py diff --git a/src/generation.py b/stripedhyena/generation.py similarity index 100% rename from src/generation.py rename to stripedhyena/generation.py diff --git a/src/layers.py b/stripedhyena/layers.py similarity index 99% rename from src/layers.py rename to stripedhyena/layers.py index b9d518b..81e9a1d 100644 --- a/src/layers.py +++ b/stripedhyena/layers.py @@ -8,7 +8,7 @@ from einops import rearrange from torch import Tensor -from src.utils import grab_first_if_tuple +from stripedhyena.utils import grab_first_if_tuple class RMSNorm(torch.nn.Module): diff --git a/src/model.py b/stripedhyena/model.py similarity index 100% rename from src/model.py rename to stripedhyena/model.py diff --git a/src/positional_embeddings.py b/stripedhyena/positional_embeddings.py similarity index 100% rename from src/positional_embeddings.py rename to stripedhyena/positional_embeddings.py diff --git a/src/sample.py b/stripedhyena/sample.py similarity index 100% rename from src/sample.py rename to stripedhyena/sample.py diff --git a/src/tokenizer.py b/stripedhyena/tokenizer.py similarity index 100% rename from src/tokenizer.py rename to stripedhyena/tokenizer.py diff --git a/src/utils.py b/stripedhyena/utils.py similarity index 100% rename from src/utils.py rename to stripedhyena/utils.py From f2f623d63aefe0298f66b69dc3a159467570f25b Mon Sep 17 00:00:00 2001 From: Zymrael Date: Fri, 23 Feb 2024 18:30:23 +0000 Subject: [PATCH 5/8] chore: src to stripedhyena --- stripedhyena/engine.py | 2 +- stripedhyena/generation.py | 6 +++--- stripedhyena/model.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stripedhyena/engine.py b/stripedhyena/engine.py index 809f3be..fbb34b9 100644 --- a/stripedhyena/engine.py +++ b/stripedhyena/engine.py @@ -11,7 +11,7 @@ import conv1d_cpp except: pass -from src.utils import column_split +from stripedhyena.utils import column_split IIR_PREFILL_MODES = [ "recurrence", diff --git a/stripedhyena/generation.py b/stripedhyena/generation.py index a998c3f..bc23861 100644 --- a/stripedhyena/generation.py +++ b/stripedhyena/generation.py @@ -6,9 +6,9 @@ import torch -from src.sample import sample -from src.tokenizer import CharLevelTokenizer -from src.utils import print_rank_0 +from stripedhyena.sample import sample +from stripedhyena.tokenizer import CharLevelTokenizer +from stripedhyena.utils import print_rank_0 class Generator: diff --git a/stripedhyena/model.py b/stripedhyena/model.py index b118447..7e4881b 100644 --- a/stripedhyena/model.py +++ b/stripedhyena/model.py @@ -7,10 +7,10 @@ import torch.nn as nn import torch.nn.functional as F -from src.cache import InferenceParams, RecurrentInferenceParams -from src.engine import HyenaInferenceEngine -from src.layers import ParallelGatedMLP, RMSNorm, VocabParallelEmbedding -from src.utils import column_split, print_rank_0 +from stripedhyena.cache import InferenceParams, RecurrentInferenceParams +from stripedhyena.engine import HyenaInferenceEngine +from stripedhyena.layers import ParallelGatedMLP, RMSNorm, VocabParallelEmbedding +from stripedhyena.utils import column_split, print_rank_0 try: from flash_attn.modules.mha import MHA @@ -18,7 +18,7 @@ "flash_attn not installed" try: - from src.positional_embeddings import swap_mha_rope + from stripedhyena.positional_embeddings import swap_mha_rope except ImportError: "could not import swap_mha_rope from src.positional_embeddings" From 477f73ca2e50d78a8d880b202717887e18c307b9 Mon Sep 17 00:00:00 2001 From: Zymrael Date: Fri, 23 Feb 2024 18:31:09 +0000 Subject: [PATCH 6/8] chore: src to stripedhyena --- generate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/generate.py b/generate.py index 4a5c4d6..5b63b83 100644 --- a/generate.py +++ b/generate.py @@ -8,11 +8,11 @@ import torch import yaml -from src.generation import Generator -from src.model import StripedHyena -from src.sample import sample -from src.tokenizer import HFAutoTokenizer -from src.utils import dotdict, print_rank_0 +from stripedhyena.generation import Generator +from stripedhyena.model import StripedHyena +from stripedhyena.sample import sample +from stripedhyena.tokenizer import HFAutoTokenizer +from stripedhyena.utils import dotdict, print_rank_0 if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run StripedHyena Model") From a5ac1271722efc5244752caab8b8be1a419f6be0 Mon Sep 17 00:00:00 2001 From: Zymrael Date: Fri, 23 Feb 2024 18:33:20 +0000 Subject: [PATCH 7/8] chore: style --- setup.py | 24 ++++++++++++------------ test/test_backward.py | 1 - test/test_forward.py | 3 +-- test/test_numerics.py | 1 - test/test_prefill.py | 1 - 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 59446ab..7828490 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,20 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup -with open('README.md') as f: +with open("README.md") as f: readme = f.read() -with open('requirements.txt') as f: - requirements = f.read().split('\n') +with open("requirements.txt") as f: + requirements = f.read().split("\n") setup( - name='stripedhyena', - version='0.2.1', - description='Model and inference code for beyond Transformer architectures', + name="stripedhyena", + version="0.2.1", + description="Model and inference code for beyond Transformer architectures", long_description=readme, - long_description_content_type='text/markdown', - author='Michael Poli', - url='http://github.com/togethercomputer/stripedhyena', - license='Apache-2.0', + long_description_content_type="text/markdown", + author="Michael Poli", + url="http://github.com/togethercomputer/stripedhyena", + license="Apache-2.0", packages=find_packages(where="stripedhyena"), install_requires=requirements, -) \ No newline at end of file +) diff --git a/test/test_backward.py b/test/test_backward.py index 3335d10..c9a5fed 100644 --- a/test/test_backward.py +++ b/test/test_backward.py @@ -4,7 +4,6 @@ import torch import torch.nn as nn import yaml - from src.layers import RMSNorm from src.model import StripedHyena from src.utils import dotdict diff --git a/test/test_forward.py b/test/test_forward.py index d6ac2a9..0d0e652 100644 --- a/test/test_forward.py +++ b/test/test_forward.py @@ -4,11 +4,10 @@ import torch import torch.nn as nn import yaml -from torch.autograd import grad - from src.layers import RMSNorm from src.model import StripedHyena from src.utils import dotdict +from torch.autograd import grad try: from flashfftconv import FlashFFTConv diff --git a/test/test_numerics.py b/test/test_numerics.py index cd02eba..53a4423 100644 --- a/test/test_numerics.py +++ b/test/test_numerics.py @@ -4,7 +4,6 @@ import torch import torch.nn as nn import yaml - from src.layers import RMSNorm from src.utils import dotdict diff --git a/test/test_prefill.py b/test/test_prefill.py index 9e539a2..af8f93b 100644 --- a/test/test_prefill.py +++ b/test/test_prefill.py @@ -4,7 +4,6 @@ import torch import torch.nn as nn import yaml - from src.layers import RMSNorm from src.model import StripedHyena from src.utils import dotdict From 436c9989787fa7f3bec85fdae181d1de87409af1 Mon Sep 17 00:00:00 2001 From: athms Date: Fri, 23 Feb 2024 19:31:08 +0000 Subject: [PATCH 8/8] specify packages for setuptools --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 91ac4e1..6db7a11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,6 @@ profile = "black" line_length = 119 combine_as_imports = true combine_star = true + +[tool.setuptools] +packages = ['stripedhyena']