-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
238 lines (189 loc) · 7.23 KB
/
Copy pathMakefile
File metadata and controls
238 lines (189 loc) · 7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# WronAI Development Makefile
# Simplified commands for development workflow
.PHONY: help venv venv-activate install install-dev install-core install-ml install-nlp install-utils clean test lint format docker-build docker-run prepare-data train inference
# Default target
help:
@echo "🐦⬛ WronAI Development Commands"
@echo ""
@echo "Setup Commands:"
@echo " venv Create Python virtual environment"
@echo " install Install all dependencies"
@echo " install-dev Install development dependencies"
@echo " install-core Install core dependencies only"
@echo " install-ml Install ML-related dependencies"
@echo " install-nlp Install NLP-related dependencies"
@echo " install-utils Install utility dependencies"
@echo " clean Clean build artifacts and cache"
@echo ""
@echo "Development Commands:"
@echo " format Format code with black and isort"
@echo " lint Run linting with flake8 and mypy"
@echo " test Run test suite"
@echo " test-cov Run tests with coverage report"
@echo ""
@echo "Data and Training:"
@echo " prepare-data Download and prepare training data"
@echo " train Start model training"
@echo " train-quick Quick training with minimal data"
@echo " inference Run inference on trained model"
@echo ""
@echo "Docker Commands:"
@echo " docker-build Build Docker container"
@echo " docker-run Run training in Docker"
@echo " docker-serve Serve model in Docker"
@echo ""
@echo "Utility Commands:"
@echo " docs Generate documentation"
@echo " notebook Start Jupyter notebook server"
@echo " tensorboard Start TensorBoard"
# Virtual environment commands
venv:
python -m venv wronai-env
@echo "Virtual environment created. Activate with:"
@echo " source wronai-env/bin/activate # Linux/Mac"
@echo " wronai-env\Scripts\activate # Windows"
# Installation commands
install:
pip install -r requirements.txt
install-dev:
pip install -e ".[dev,docs,inference]"
pre-commit install
install-core:
pip install torch transformers accelerate peft datasets evaluate
install-ml:
pip install bitsandbytes scipy safetensors wandb tensorboard
install-nlp:
pip install tokenizers sentencepiece regex spacy
install-utils:
pip install beautifulsoup4 requests aiohttp scrapy pyyaml omegaconf loguru rich
# Clean commands
clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info/
rm -rf __pycache__/
find . -type d -name __pycache__ -delete
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type f -name ".coverage" -delete
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
# Code quality commands
format:
black scripts/ wronai/ tests/ || echo "Warning: black formatter had issues"
isort scripts/ wronai/ tests/ || echo "Warning: isort had issues"
lint:
flake8 .
mypy scripts/ wronai/ --ignore-missing-imports
black --check .
isort --check-only .
# Testing commands
test:
pytest tests/ -v
test-cov:
pytest tests/ -v --cov=wronai --cov-report=html --cov-report=term
test-fast:
pytest tests/unit/ -v
# Data preparation
prepare-data:
python scripts/prepare_data.py --all --output-dir data/processed
prepare-data-minimal:
python scripts/prepare_data.py --create-instructions --output-dir data/processed
# Training commands
train:
python scripts/train.py --config configs/default.yaml
train-quick:
python scripts/train.py --config configs/quick_test.yaml
train-gpu:
CUDA_VISIBLE_DEVICES=0 python scripts/train.py --config configs/default.yaml
# Inference commands
inference:
python scripts/inference.py --model checkpoints/wronai-7b --chat
inference-prompt:
python scripts/inference.py --model checkpoints/wronai-7b --prompt "Opowiedz o Polsce"
# Docker commands
docker-build:
docker build -t wronai:latest .
docker-run:
docker-compose up wronai-training
docker-serve:
docker-compose up wronai-inference
docker-prep:
docker-compose up wronai-data-prep
docker-down:
docker-compose down
# Development utilities
docs:
cd docs && make html
docs-serve:
cd docs/_build/html && python -m http.server 8080
notebook:
jupyter notebook notebooks/
tensorboard:
tensorboard --logdir=logs --host=0.0.0.0 --port=6006
# Model evaluation
evaluate:
python scripts/evaluate.py --model checkpoints/wronai-7b --benchmarks all
benchmark:
python scripts/benchmark.py --model checkpoints/wronai-7b --output results/
# Release commands
build:
python setup.py sdist bdist_wheel
upload-test:
twine upload --repository testpypi dist/*
upload:
twine upload dist/*
# Environment setup
setup-env:
python -m venv venv
@echo "Run: source venv/bin/activate (Linux/Mac) or venv\\Scripts\\activate (Windows)"
setup-cuda:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# Quick start for new developers
quickstart: install-dev prepare-data-minimal train-quick
@echo "🎉 WronAI quickstart completed!"
@echo "Try: make inference"
# CI/CD simulation
ci: clean lint test
@echo "✅ CI checks passed!"
# Performance profiling
profile:
python -m cProfile -o profile.stats scripts/train.py --config configs/profile.yaml
python -c "import pstats; pstats.Stats('profile.stats').sort_stats('cumulative').print_stats(20)"
# Memory profiling
memory-profile:
mprof run python scripts/train.py --config configs/memory_test.yaml
mprof plot
# Model size analysis
model-size:
python -c "import torch; from transformers import AutoModel; model = AutoModel.from_pretrained('checkpoints/wronai-7b'); total_params = sum(p.numel() for p in model.parameters()); trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad); print(f'Total parameters: {total_params:,}'); print(f'Trainable parameters: {trainable_params:,}'); print(f'Model size: {total_params * 4 / 1024**3:.2f} GB (fp32)');"
# Download pre-trained models
download-models:
mkdir -p models/pretrained
wget -O models/pretrained/wronai-7b.tar.gz "https://softreck.dev/wronai-7b.tar.gz"
tar -xzf models/pretrained/wronai-7b.tar.gz -C models/pretrained/
# Health check
health-check:
python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); \\\n\tif torch.cuda.is_available(): \\\n\t print(f'CUDA version: {torch.version.cuda}'); \\\n\t print(f'GPU count: {torch.cuda.device_count()}'); \\\n\t for i in range(torch.cuda.device_count()): \\\n\t props = torch.cuda.get_device_properties(i); \\\n\t print(f'GPU {i}: {props.name} ({props.total_memory // 1024**3} GB)');"
# Package information
info:
@echo "🐦⬛ WronAI Project Information"
@echo "Version: $(shell python setup.py --version)"
@echo "Author: $(shell python setup.py --author)"
@echo "License: $(shell python setup.py --license)"
@echo ""
@echo "Dependencies:"
@pip list | grep -E "(torch|transformers|datasets|accelerate)"
# Security scan
security:
safety check
bandit -r wronai/ scripts/
# Update dependencies
update-deps:
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
# Backup important files
backup:
tar -czf backup_$(shell date +%Y%m%d_%H%M%S).tar.gz \
configs/ scripts/ wronai/ checkpoints/ data/processed/ \
--exclude="*.pyc" --exclude="__pycache__" --exclude="*.log"