Skip to content

Commit c570639

Browse files
author
Thai Chau Truong
committed
Set up env to develop features
1 parent 39c984f commit c570639

File tree

7 files changed

+79
-10
lines changed

7 files changed

+79
-10
lines changed

.github/workflows/deploy_docs.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This is a basic workflow that is manually triggered
2+
3+
name: Manual workflow
4+
5+
# Controls when the action will run. Workflow runs when manually triggered using the UI
6+
# or API.
7+
on:
8+
workflow_dispatch:
9+
# Inputs the workflow accepts.
10+
inputs:
11+
name:
12+
# Friendly description to be shown in the UI instead of 'name'
13+
description: 'Person to greet'
14+
# Default value if no value is explicitly provided
15+
default: 'World'
16+
# Input has to be provided for the workflow to run
17+
required: true
18+
# The data type of the input
19+
type: string
20+
21+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
22+
jobs:
23+
deploy-docs:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up Python 3.9
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.9
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install --upgrade setuptools
35+
pip install -e .
36+
pip install -r docs/requirements.txt
37+
- name: Build docs
38+
run: |
39+
set -e
40+
# Check that docs are built without errors
41+
cd docs/ && make html && cd ..
42+
- name: Deploy docs
43+
uses: JamesIves/[email protected]
44+
with:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
BRANCH: gh-pages
47+
FOLDER: docs/build/html
48+
CLEAN: true

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- name: Set up Python 3.8
12+
- name: Set up Python 3.9
1313
uses: actions/setup-python@v2
1414
with:
15-
python-version: 3.8
15+
python-version: 3.9
1616
- name: Install dependencies
1717
run: |
1818
python -m pip install --upgrade pip
@@ -35,10 +35,10 @@ jobs:
3535
runs-on: ubuntu-latest
3636
steps:
3737
- uses: actions/checkout@v2
38-
- name: Set up Python 3.8
38+
- name: Set up Python 3.9
3939
uses: actions/setup-python@v2
4040
with:
41-
python-version: 3.8
41+
python-version: 3.9
4242
- name: Install dependencies
4343
run: |
4444
python -m pip install --upgrade pip

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ multi-bleu.perl
66
.idea
77
*.sublime-*
88
.DS_Store
9+
.env
10+
model/
911

1012
# Byte-compiled / optimized / DLL files
1113
__pycache__/

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel
2+
3+
RUN apt-get update
4+
RUN apt-get install -y vim
5+
COPY ./ /dependencies/opennmt-py/
6+
RUN cd /dependencies/opennmt-py/ && pip install -e .
7+
RUN pip install black
8+
RUN pip install sentencepiece

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include .env
2+
build:
3+
docker build --tag opennmt-py-dev:2.1.0-cuda12.1-cudnn8-devel .
4+
up:
5+
docker run -it --name opennmt-py-dev --gpus=all --shm-size=10G \
6+
-v ${MODEL_FOLDER}:/workspace/model \
7+
opennmt-py-dev:2.1.0-cuda12.1-cudnn8-devel /bin/bash
8+
down:
9+
docker stop opennmt-py-dev && docker rm opennmt-py-dev

onmt/modules/moe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def forward(self, x):
6060
y = torch.empty_like(x)
6161
for i, expert in enumerate(self.experts):
6262
if torch.any(flat_expert_indices == i):
63-
y[flat_expert_indices == i] = expert(x[flat_expert_indices == i])
63+
y[flat_expert_indices == i] = expert(
64+
x[flat_expert_indices == i].unsqueeze(0)
65+
)
6466
y = (y.view(*expert_weights.shape, -1) * expert_weights.unsqueeze(-1)).sum(
6567
dim=1
6668
)

onmt/modules/rmsnorm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import torch.nn as nn
55

66
try:
7-
import awq_inference_engine
7+
import awq_ext
88

9-
AWQ_INFERENCE_ENGINE = True
9+
AWQ_EXT = True
1010
except ImportError:
11-
AWQ_INFERENCE_ENGINE = False
11+
AWQ_EXT = False
1212

1313

1414
class RMSNorm(torch.nn.Module):
@@ -24,12 +24,12 @@ def __init__(self, hidden_size: int, eps: float = 1e-6):
2424
self.weight = nn.Parameter(torch.ones(hidden_size))
2525

2626
def forward(self, hidden_states):
27-
if AWQ_INFERENCE_ENGINE and not self.training:
27+
if AWQ_EXT and not self.training:
2828
inp_type = hidden_states.dtype
2929
output = torch.empty_like(hidden_states).to(inp_type)
3030
if hidden_states.dim() == 2: # patch for multi experts
3131
hidden_states = hidden_states.unsqueeze(0)
32-
awq_inference_engine.layernorm_forward_cuda(
32+
awq_ext.layernorm_forward_cuda(
3333
hidden_states.half(), self.weight.half(), output.half(), self.eps
3434
)
3535
if hidden_states.dim() == 2: # patch for multi experts

0 commit comments

Comments
 (0)