Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
829 commits
Select commit Hold shift + click to select a range
c39bee6
wip
tastelikefeet Feb 5, 2026
b1f6746
add load remote
Yunnglin Feb 5, 2026
8d639d3
fix
tastelikefeet Feb 5, 2026
33b3c1b
fix
tastelikefeet Feb 5, 2026
3f40ddd
add tinker resume from remote
Yunnglin Feb 5, 2026
42e84d8
add manager
Yunnglin Feb 5, 2026
fe54791
update import
Yunnglin Feb 5, 2026
d0709b2
test accurancy
meichangsu1 Feb 4, 2026
cb7ee9a
feat(sp): add fsdp/ep alignment tests
meichangsu1 Feb 5, 2026
46b6948
wip
meichangsu1 Feb 5, 2026
9842025
feat(model): lazy initialization of sequence-parallel strategy
meichangsu1 Feb 5, 2026
43ada26
Merge pull request #36 from modelscope/sp_ljl_dev
meichangsu1 Feb 5, 2026
a96934f
wip
tastelikefeet Feb 5, 2026
8b4604d
Merge branch 'fix/0205-2' into dev
tastelikefeet Feb 5, 2026
47632ee
add more docs
tastelikefeet Feb 5, 2026
39c52a0
wip
tastelikefeet Feb 5, 2026
b1b11b4
Merge remote-tracking branch 'origin/dev' into dev-wkw
kevssim Feb 6, 2026
1e6f95b
wip
kevssim Feb 6, 2026
5522ff1
Merge pull request #33 from modelscope/dev-wkw
kevssim Feb 6, 2026
f096efb
fix npu sft lora
addsubmuldiv Feb 6, 2026
4dcc452
update server
Yunnglin Feb 6, 2026
35f349d
Update src/twinkle/server/launcher.py
Yunnglin Feb 6, 2026
00e8819
update server
Yunnglin Feb 6, 2026
0803a21
Merge branch 'update_sample' of https://github.com/modelscope/twinkle…
Yunnglin Feb 6, 2026
8ef21e9
add more docs
tastelikefeet Feb 6, 2026
3a8e3ee
Merge branch 'fix/0206-1' into dev
tastelikefeet Feb 6, 2026
09abd37
update ep cookbook
kevssim Feb 6, 2026
396b5b5
Merge pull request #40 from modelscope/dev-wkw
kevssim Feb 6, 2026
ad616ab
fix npu grpo lora training and add vllm graceful shutdown
addsubmuldiv Feb 6, 2026
a91aa70
Merge pull request #34 from modelscope/doc_npu
addsubmuldiv Feb 6, 2026
0ffbacb
Merge pull request #39 from modelscope/fix_npu_sft_lora
addsubmuldiv Feb 6, 2026
ca2d52e
add more docs
tastelikefeet Feb 6, 2026
9948ab0
Merge commit '0ffbacbac84368174ed70b7330899f6ca62d8f64' into dev
tastelikefeet Feb 6, 2026
d680e22
add github files
tastelikefeet Feb 6, 2026
0abc1bb
fix docs
tastelikefeet Feb 6, 2026
ca797d3
wip
tastelikefeet Feb 6, 2026
b5c535b
refactor docs
tastelikefeet Feb 6, 2026
356612f
wip
tastelikefeet Feb 7, 2026
3fa6f17
wip
tastelikefeet Feb 7, 2026
5054ef6
update
Yunnglin Feb 7, 2026
04f9f71
wip
tastelikefeet Feb 7, 2026
1dfcf43
Merge pull request #38 from modelscope/update_sample
Yunnglin Feb 7, 2026
86539cc
Merge pull request #41 from modelscope/fix_npu_grpo
addsubmuldiv Feb 7, 2026
71dd6a9
wip
tastelikefeet Feb 7, 2026
36c9a4e
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 7, 2026
5d83e5c
wip
tastelikefeet Feb 7, 2026
e03d087
add patch
Yunnglin Feb 7, 2026
2af73f2
fix
tastelikefeet Feb 7, 2026
a8fa9ef
update
Yunnglin Feb 7, 2026
61fecc6
Merge branch 'dev' into add_rl_server
Yunnglin Feb 7, 2026
2c3a20e
stand-alone rl (#42)
hjh0119 Feb 7, 2026
b481099
fix
tastelikefeet Feb 7, 2026
57af42d
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 7, 2026
9a1aa2e
add client code
Yunnglin Feb 7, 2026
9053664
update cookbook
Yunnglin Feb 7, 2026
b591870
update cookbook
Yunnglin Feb 7, 2026
4c996af
Merge branch 'dev' into add_rl_server
Yunnglin Feb 7, 2026
3fe6615
Merge pull request #43 from modelscope/add_rl_server
Yunnglin Feb 7, 2026
990928b
wip
tastelikefeet Feb 7, 2026
d7b101f
wip
tastelikefeet Feb 7, 2026
22b42fd
megatron grpo lora (#44)
hjh0119 Feb 7, 2026
f20fbfa
wip
tastelikefeet Feb 7, 2026
0f59785
Merge branch 'dev' into fix/0207-1
tastelikefeet Feb 7, 2026
0e0def8
wip
tastelikefeet Feb 7, 2026
5339485
wip
tastelikefeet Feb 7, 2026
eab3ca6
fix
tastelikefeet Feb 8, 2026
6c663d0
fix
tastelikefeet Feb 8, 2026
9f64a62
Merge commit 'eab3ca6e94860465907a2f7c8a54170e129f73d5' into fix/0207-1
tastelikefeet Feb 8, 2026
13cf6ae
wip
tastelikefeet Feb 8, 2026
c1769ac
fix
hjh0119 Feb 8, 2026
1b72ffc
Merge branch 'dev' into megatron-grpo-tp
hjh0119 Feb 8, 2026
2f37cdd
update docs
tastelikefeet Feb 8, 2026
7f149c9
fix grpo demo
hjh0119 Feb 8, 2026
e351f1c
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 8, 2026
d651f83
0208'
hzher Feb 8, 2026
3aeaa81
wip
tastelikefeet Feb 8, 2026
4d2f59b
Merge commit 'd651f832ac65a7ad8a706383a9ca51c2594b1eee' into dev
tastelikefeet Feb 8, 2026
446a521
add roadmap
tastelikefeet Feb 8, 2026
7124b1c
0205
hzher Feb 8, 2026
05eda76
0205
hzher Feb 8, 2026
93702fc
fix
tastelikefeet Feb 8, 2026
3d573cb
fix data loading
tastelikefeet Feb 8, 2026
21065ee
revert code
tastelikefeet Feb 8, 2026
0373d7a
wip
tastelikefeet Feb 8, 2026
e41815d
fix table
tastelikefeet Feb 8, 2026
e2e4383
fix files
tastelikefeet Feb 8, 2026
2d5f266
format docs
tastelikefeet Feb 8, 2026
26f25c5
add en readme
tastelikefeet Feb 8, 2026
6bad063
add en docs
tastelikefeet Feb 8, 2026
d357589
wip
tastelikefeet Feb 8, 2026
bc7c4c0
change `VLLM` to `vLLM`
tastelikefeet Feb 8, 2026
3970412
remove useless file
tastelikefeet Feb 8, 2026
cb65bff
fixlink
tastelikefeet Feb 8, 2026
f4c4fec
fix
tastelikefeet Feb 8, 2026
1ec06f0
fix
tastelikefeet Feb 8, 2026
ef7ec14
fix
tastelikefeet Feb 8, 2026
65ae1ed
Add rl example (#45)
Yunnglin Feb 8, 2026
aa72398
new script
hjh0119 Feb 8, 2026
6d20015
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 8, 2026
b1b0e71
fix VLLM->vLLM
hjh0119 Feb 8, 2026
25e89ab
gsm8k demo
hjh0119 Feb 9, 2026
4328a33
fix loss
hjh0119 Feb 9, 2026
91e8b49
clean
hjh0119 Feb 9, 2026
68ccd6c
fix
hjh0119 Feb 9, 2026
7aad0b3
fix default lora
hjh0119 Feb 9, 2026
7ce5899
fix ci config
tastelikefeet Feb 9, 2026
94f3768
fix
tastelikefeet Feb 9, 2026
caaa7d4
fix ci
tastelikefeet Feb 9, 2026
b081b5b
fixci
tastelikefeet Feb 9, 2026
2228ea8
fix ci
tastelikefeet Feb 9, 2026
dad0119
fix ci
tastelikefeet Feb 9, 2026
615047b
ep cookbook and script
kevssim Feb 9, 2026
5e1f465
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
kevssim Feb 9, 2026
3981b40
kernel doc
kevssim Feb 9, 2026
34e3d2f
update ep cookbook
kevssim Feb 9, 2026
41d2861
fix state dict
hjh0119 Feb 9, 2026
b63d1b1
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 9, 2026
877c28d
support seq_len advantages
hjh0119 Feb 9, 2026
ec6016f
fix grpo loss
hjh0119 Feb 9, 2026
2dc5ff8
sequence parallel fix bug (#47)
meichangsu1 Feb 9, 2026
51e3c15
fix ci
tastelikefeet Feb 9, 2026
976c98f
Merge commit '2dc5ff83e91f6193f271925239e0a0776d38e16c' into dev
tastelikefeet Feb 9, 2026
b2d56f0
wip
tastelikefeet Feb 9, 2026
cf840aa
fix ci
tastelikefeet Feb 9, 2026
b811680
enhence lora sync
tastelikefeet Feb 9, 2026
9d44518
Add tinker rl example (#48)
Yunnglin Feb 9, 2026
8045ef9
fix
tastelikefeet Feb 9, 2026
1451afc
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 9, 2026
0095fc0
wip
tastelikefeet Feb 9, 2026
efc99ca
add tp log
tastelikefeet Feb 9, 2026
1a49246
fix
tastelikefeet Feb 9, 2026
00c1e52
group sync
tastelikefeet Feb 10, 2026
aaddedf
Revert "group sync"
tastelikefeet Feb 10, 2026
d77153b
change server_config
tastelikefeet Feb 10, 2026
0d81634
fix env
tastelikefeet Feb 10, 2026
acf00e3
support from_sizes for tinker server
tastelikefeet Feb 10, 2026
1113e1a
fix server config
tastelikefeet Feb 10, 2026
9e82a21
Update attribution in README.md
yingdachen Feb 10, 2026
58388ef
fix multi lora megatron
tastelikefeet Feb 10, 2026
edc9b36
fix config
tastelikefeet Feb 10, 2026
595d97c
fix moe sync weights
hjh0119 Feb 10, 2026
d3cc3a0
moe sync weights
hjh0119 Feb 10, 2026
808cadb
add resource warning
tastelikefeet Feb 10, 2026
e2537a6
fix skip ranks
tastelikefeet Feb 10, 2026
42a9934
fix
hjh0119 Feb 10, 2026
2995fbb
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 10, 2026
9fbffc8
fix deployment
tastelikefeet Feb 10, 2026
6d8cbec
update readme
Feb 10, 2026
74b5922
update reademe
Feb 10, 2026
c6d9ad1
fix megatron load
tastelikefeet Feb 10, 2026
197cd2a
0210-improve
Feb 10, 2026
c98fee9
Add rl example (#49)
Yunnglin Feb 10, 2026
46cd9ad
update readme
Feb 10, 2026
5890afa
update sampler&script
hjh0119 Feb 10, 2026
f8ae876
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 10, 2026
6488986
wip
tastelikefeet Feb 10, 2026
de6b8a3
fix
tastelikefeet Feb 10, 2026
baaa426
fix
tastelikefeet Feb 10, 2026
ba835f2
fix
tastelikefeet Feb 10, 2026
08ee10a
change config
tastelikefeet Feb 10, 2026
3e4c283
fix
tastelikefeet Feb 10, 2026
b941858
fix
tastelikefeet Feb 10, 2026
7640fb2
fix
tastelikefeet Feb 10, 2026
eef624a
clean sampler
hjh0119 Feb 10, 2026
d7503d8
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 10, 2026
4316583
fix moe sp
hjh0119 Feb 10, 2026
1e650ec
fix sp pad
hjh0119 Feb 10, 2026
e0386aa
minor fix
Feb 11, 2026
fdae94c
fix pattern
tastelikefeet Feb 11, 2026
8dec1d5
Update sample (#50)
Yunnglin Feb 11, 2026
d587aeb
fix imports
tastelikefeet Feb 11, 2026
aa1f307
skip test because CI hang
tastelikefeet Feb 11, 2026
2bd0e17
fix
tastelikefeet Feb 11, 2026
4dab4c7
README
Feb 11, 2026
8ecf2ae
fix docs
tastelikefeet Feb 11, 2026
facca1a
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
Feb 11, 2026
4f93e99
add selective log
Yunnglin Feb 11, 2026
5a8ee4e
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
Yunnglin Feb 11, 2026
14cc565
fix
tastelikefeet Feb 11, 2026
9d3402b
Merge branch 'fix/0211-docs' into dev
tastelikefeet Feb 11, 2026
297b312
sp fix ci test hang (#52)
meichangsu1 Feb 11, 2026
f078aa9
refine framework picture
tastelikefeet Feb 11, 2026
69edc5e
fix framework graph
tastelikefeet Feb 11, 2026
0c9d86b
add remote sample code
tastelikefeet Feb 11, 2026
65d61ed
fix picture
tastelikefeet Feb 11, 2026
649e0b9
fix arrow
tastelikefeet Feb 11, 2026
fdd14ee
fix callback
tastelikefeet Feb 11, 2026
684c0b9
update
Yunnglin Feb 11, 2026
2741e3f
fix cookbook
tastelikefeet Feb 11, 2026
f61298c
fix
tastelikefeet Feb 11, 2026
c13ed95
fix
tastelikefeet Feb 11, 2026
17b0503
update
Yunnglin Feb 11, 2026
2a9c2e2
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
Yunnglin Feb 11, 2026
475f535
update load (#53)
Yunnglin Feb 11, 2026
2651686
fix bug
tastelikefeet Feb 11, 2026
5830460
fix
tastelikefeet Feb 11, 2026
6715192
fix npu grpo (#55)
addsubmuldiv Feb 12, 2026
063686c
fix import
tastelikefeet Feb 12, 2026
dd84454
fix weigt sync
hjh0119 Feb 12, 2026
9871f3c
merge
hjh0119 Feb 12, 2026
905cc57
fix
tastelikefeet Feb 12, 2026
af9ee69
Merge commit '9871f3cde444687ba53d8bcda41d82398fba0740' into dev
tastelikefeet Feb 12, 2026
80fa6de
fix zmq
hjh0119 Feb 12, 2026
43ed0a7
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 12, 2026
4f2f4a8
save mcore optimizer
hjh0119 Feb 12, 2026
6d80d9c
block main thread
tastelikefeet Feb 12, 2026
3cc2189
fix docs
tastelikefeet Feb 13, 2026
b6c05f0
fix
tastelikefeet Feb 13, 2026
688557d
fix pre-commit
tastelikefeet Feb 13, 2026
537baa3
lint passed
tastelikefeet Feb 13, 2026
05c81e7
rl cookbook
hjh0119 Feb 13, 2026
87999d7
merge
hjh0119 Feb 13, 2026
821cdf5
fix bugs
tastelikefeet Feb 13, 2026
547555e
update (#57)
yingdachen Feb 13, 2026
ca94db1
fix docs
tastelikefeet Feb 13, 2026
544098c
add wechat group
tastelikefeet Feb 13, 2026
5b0e132
fix
tastelikefeet Feb 13, 2026
d2c0ab7
En
Feb 13, 2026
aa86181
Fix moe (#58)
Yunnglin Feb 13, 2026
2ee8245
fix ci
tastelikefeet Feb 13, 2026
1e9c117
Merge commit 'aa86181dab427abcc56a9bc90103fe3d3267e321' into dev
tastelikefeet Feb 13, 2026
01c4b89
bump version
tastelikefeet Feb 13, 2026
c685f06
fix
tastelikefeet Feb 13, 2026
92717fa
fix config
tastelikefeet Feb 13, 2026
991a8d5
change token name
Feb 13, 2026
0a4ce8f
fix
tastelikefeet Feb 13, 2026
4007aa5
Merge commit '991a8d50c97bccb0affdfccb0e2adcc4c92a95ab' into dev
tastelikefeet Feb 13, 2026
d2f3406
fix rl demo
hjh0119 Feb 13, 2026
5665ba8
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 13, 2026
1595c38
add acknowledgements
tastelikefeet Feb 13, 2026
905d5fb
fix loss metric when enable sp (#59)
meichangsu1 Feb 13, 2026
a5c4927
tests
Feb 13, 2026
24c3923
remote legacy folder
tastelikefeet Feb 13, 2026
c42ff54
remove obsolete file
tastelikefeet Feb 13, 2026
e18fd36
Merge commit 'a5c492744e45306ee51478098526a15250ab5d94' into dev
tastelikefeet Feb 13, 2026
7c17844
lint code
tastelikefeet Feb 13, 2026
3ed9edd
fix
tastelikefeet Feb 13, 2026
c5aafff
Kernels unittest fix ljl (#61)
meichangsu1 Feb 13, 2026
6a2b9e7
remove
tastelikefeet Feb 13, 2026
188dd72
fix import bugs
tastelikefeet Feb 13, 2026
acc7183
fix doc
tastelikefeet Feb 13, 2026
dbceec8
fix vllm remove lora
hjh0119 Feb 13, 2026
9b875d7
Merge branch 'dev' of github.com:modelscope/twinkle into dev
hjh0119 Feb 13, 2026
3f8f6b0
fix
tastelikefeet Feb 13, 2026
454ebe8
unittest fix ljl (#62)
meichangsu1 Feb 13, 2026
4f57cbf
update grpo demo
hjh0119 Feb 13, 2026
b4c0e65
update demo
hjh0119 Feb 13, 2026
0857154
update
hjh0119 Feb 13, 2026
0e89db9
clean
hjh0119 Feb 13, 2026
fc0db72
modify cookbook (#63)
meichangsu1 Feb 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .dev_scripts/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd docs
rm -rf build

# update api rst
#rm -rf source/api/
#sphinx-apidoc --module-first -o source/api/ ../modelscope/
make html
47 changes: 47 additions & 0 deletions .dev_scripts/ci_container_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
install_twinkle_with_kernels() {
pip install ".[kernels]" -i https://mirrors.aliyun.com/pypi/simple/ || pip install ".[kernels]"
}

if [ "$MODELSCOPE_SDK_DEBUG" == "True" ]; then
# pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
git config --global --add safe.directory /twinkle
git config --global user.email tmp
git config --global user.name tmp.com

# linter test
# use internal project for pre-commit due to the network problem
if [ `git remote -v | grep alibaba | wc -l` -gt 1 ]; then
pre-commit run -c .pre-commit-config_local.yaml --all-files
if [ $? -ne 0 ]; then
echo "linter test failed, please run 'pre-commit run --all-files' to check"
echo "From the repository folder"
echo "Run 'pre-commit install' install pre-commit hooks."
echo "Finally run linter with command: 'pre-commit run --all-files' to check."
echo "Ensure there is no failure!!!!!!!!"
exit -1
fi
Comment on lines +15 to +22
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error handling can be improved for better shell scripting practice and correctness.

  1. It's more idiomatic and robust to check the exit code of a command directly in the if condition.
  2. exit -1 is not a standard exit code. The standard for error is a non-zero integer, typically 1.

I suggest refactoring this block for better readability and adherence to shell standards.

Suggested change
if [ $? -ne 0 ]; then
echo "linter test failed, please run 'pre-commit run --all-files' to check"
echo "From the repository folder"
echo "Run 'pre-commit install' install pre-commit hooks."
echo "Finally run linter with command: 'pre-commit run --all-files' to check."
echo "Ensure there is no failure!!!!!!!!"
exit -1
fi
if ! pre-commit run -c .pre-commit-config_local.yaml --all-files; then
echo "linter test failed, please run 'pre-commit run --all-files' to check"
echo "From the repository folder"
echo "Run 'pre-commit install' install pre-commit hooks."
echo "Finally run linter with command: 'pre-commit run --all-files' to check."
echo "Ensure there is no failure!!!!!!!!"
exit 1
fi

fi

pip install decord einops -U -i https://mirrors.aliyun.com/pypi/simple/
pip uninstall autoawq -y
pip uninstall lmdeploy -y
pip uninstall tensorflow -y
pip install kernels -U
pip install ray==2.48
pip install optimum

# test with install
install_twinkle_with_kernels
else
install_twinkle_with_kernels
echo "Running case in release image, run case directly!"
fi
# remove torch_extensions folder to avoid ci hang.
rm -rf ~/.cache/torch_extensions
if [ $# -eq 0 ]; then
ci_command="pytest tests"
else
ci_command="$@"
fi
echo "Running case with command: $ci_command"
$ci_command
96 changes: 96 additions & 0 deletions .dev_scripts/dockerci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
MODELSCOPE_CACHE_DIR_IN_CONTAINER=/modelscope_cache
CODE_DIR=$PWD
CODE_DIR_IN_CONTAINER=/twinkle
mkdir -p ~/.cache
MODELSCOPE_CACHE=~/.cache
IMAGE_NAME=modelscope-registry.us-west-1.cr.aliyuncs.com/modelscope-repo/modelscope
IMAGE_VERSION=ci_image
MODELSCOPE_HOME_CACHE=~/.cache
CI_TEST=True
MODELSCOPE_SDK_DEBUG=True
CI_COMMAND='bash .dev_scripts/ci_container_test.sh pytest tests'
MODELSCOPE_SDK_DEBUG=True
echo "$USER"
gpus='0,1 2,3'
cpu_sets='0-15 16-31'
cpu_sets_arr=($cpu_sets)
is_get_file_lock=false
echo "ci command: $CI_COMMAND"
PR_CHANGED_FILES="${PR_CHANGED_FILES:-}"
echo "PR modified files: $PR_CHANGED_FILES"
PR_CHANGED_FILES=${PR_CHANGED_FILES//[ ]/#}
echo "PR_CHANGED_FILES: $PR_CHANGED_FILES"
idx=0
for gpu in $gpus
do
exec {lock_fd}>"/tmp/gpu$gpu" || exit 1
flock -n "$lock_fd" || { echo "WARN: gpu $gpu is in use!" >&2; idx=$((idx+1)); continue; }
echo "get gpu lock $gpu"

CONTAINER_NAME="twinkle-ci-$idx"
let is_get_file_lock=true

# pull image if there are update
docker pull ${IMAGE_NAME}:${IMAGE_VERSION}
if [ "$MODELSCOPE_SDK_DEBUG" == "True" ]; then
echo 'debugging'
docker run --rm --name $CONTAINER_NAME --shm-size=16gb \
--cpuset-cpus=${cpu_sets_arr[$idx]} \
--gpus='"'"device=$gpu"'"' \
-v $CODE_DIR:$CODE_DIR_IN_CONTAINER \
-v $MODELSCOPE_CACHE:$MODELSCOPE_CACHE_DIR_IN_CONTAINER \
-v $MODELSCOPE_HOME_CACHE/$idx:/root \
-v /home/admin/pre-commit:/home/admin/pre-commit \
-e CI_TEST=True \
-e TEST_LEVEL=$TEST_LEVEL \
-e MODELSCOPE_CACHE=$MODELSCOPE_CACHE_DIR_IN_CONTAINER \
-e MODELSCOPE_DOMAIN=$MODELSCOPE_DOMAIN \
-e MODELSCOPE_SDK_DEBUG=True \
-e HUB_DATASET_ENDPOINT=$HUB_DATASET_ENDPOINT \
-e TEST_ACCESS_TOKEN_CITEST=$TEST_ACCESS_TOKEN_CITEST \
-e TEST_ACCESS_TOKEN_SDKDEV=$TEST_ACCESS_TOKEN_SDKDEV \
-e TEST_LEVEL=$TEST_LEVEL \
-e MODELSCOPE_ENVIRONMENT='ci' \
-e TEST_UPLOAD_MS_TOKEN=$TEST_UPLOAD_MS_TOKEN \
-e MODEL_TAG_URL=$MODEL_TAG_URL \
-e MODELSCOPE_API_TOKEN=$MODELSCOPE_API_TOKEN \
-e PR_CHANGED_FILES=$PR_CHANGED_FILES \
--workdir=$CODE_DIR_IN_CONTAINER \
${IMAGE_NAME}:${IMAGE_VERSION} \
$CI_COMMAND
else
docker run --rm --name $CONTAINER_NAME --shm-size=16gb \
--cpuset-cpus=${cpu_sets_arr[$idx]} \
--gpus='"'"device=$gpu"'"' \
-v $CODE_DIR:$CODE_DIR_IN_CONTAINER \
-v $MODELSCOPE_CACHE:$MODELSCOPE_CACHE_DIR_IN_CONTAINER \
-v $MODELSCOPE_HOME_CACHE/$idx:/root \
-v /home/admin/pre-commit:/home/admin/pre-commit \
-e CI_TEST=True \
-e TEST_LEVEL=$TEST_LEVEL \
-e MODELSCOPE_CACHE=$MODELSCOPE_CACHE_DIR_IN_CONTAINER \
-e MODELSCOPE_DOMAIN=$MODELSCOPE_DOMAIN \
-e HUB_DATASET_ENDPOINT=$HUB_DATASET_ENDPOINT \
-e TEST_ACCESS_TOKEN_CITEST=$TEST_ACCESS_TOKEN_CITEST \
-e TEST_ACCESS_TOKEN_SDKDEV=$TEST_ACCESS_TOKEN_SDKDEV \
-e TEST_LEVEL=$TEST_LEVEL \
-e MODELSCOPE_ENVIRONMENT='ci' \
-e TEST_UPLOAD_MS_TOKEN=$TEST_UPLOAD_MS_TOKEN \
-e MODEL_TAG_URL=$MODEL_TAG_URL \
-e MODELSCOPE_API_TOKEN=$MODELSCOPE_API_TOKEN \
-e PR_CHANGED_FILES=$PR_CHANGED_FILES \
--workdir=$CODE_DIR_IN_CONTAINER \
${IMAGE_NAME}:${IMAGE_VERSION} \
$CI_COMMAND
fi
Comment on lines +36 to +86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's significant code duplication between the if and else blocks for the docker run command. This makes the script harder to maintain, as any change to the common options needs to be applied in two places. Additionally, the -e TEST_LEVEL=$TEST_LEVEL option is duplicated within each block.

I recommend refactoring to define the common docker run arguments in an array and conditionally add the debug-specific flag. This will improve readability and maintainability.

  DOCKER_RUN_OPTS=(
    --rm --name "$CONTAINER_NAME" --shm-size=16gb
    --cpuset-cpus="${cpu_sets_arr[$idx]}"
    --gpus="'"device=$gpu"'"
    -v "$CODE_DIR:$CODE_DIR_IN_CONTAINER"
    -v "$MODELSCOPE_CACHE:$MODELSCOPE_CACHE_DIR_IN_CONTAINER"
    -v "$MODELSCOPE_HOME_CACHE/$idx:/root"
    -v /home/admin/pre-commit:/home/admin/pre-commit
    -e CI_TEST=True
    -e TEST_LEVEL="$TEST_LEVEL"
    -e MODELSCOPE_CACHE="$MODELSCOPE_CACHE_DIR_IN_CONTAINER"
    -e MODELSCOPE_DOMAIN="$MODELSCOPE_DOMAIN"
    -e HUB_DATASET_ENDPOINT="$HUB_DATASET_ENDPOINT"
    -e TEST_ACCESS_TOKEN_CITEST="$TEST_ACCESS_TOKEN_CITEST"
    -e TEST_ACCESS_TOKEN_SDKDEV="$TEST_ACCESS_TOKEN_SDKDEV"
    -e MODELSCOPE_ENVIRONMENT='ci'
    -e TEST_UPLOAD_MS_TOKEN="$TEST_UPLOAD_MS_TOKEN"
    -e MODEL_TAG_URL="$MODEL_TAG_URL"
    -e MODELSCOPE_API_TOKEN="$MODELSCOPE_API_TOKEN"
    -e PR_CHANGED_FILES="$PR_CHANGED_FILES"
    --workdir="$CODE_DIR_IN_CONTAINER"
  )

  if [ "$MODELSCOPE_SDK_DEBUG" == "True" ]; then
    echo 'debugging'
    DOCKER_RUN_OPTS+=("-e" "MODELSCOPE_SDK_DEBUG=True")
  fi

  docker run "${DOCKER_RUN_OPTS[@]}" "${IMAGE_NAME}:${IMAGE_VERSION}" "$CI_COMMAND"

if [ $? -ne 0 ]; then
echo "Running test case failed, please check the log!"
exit -1
fi
break
done
if [ "$is_get_file_lock" = false ] ; then
echo 'No free GPU!'
exit 1
fi
57 changes: 57 additions & 0 deletions .dev_scripts/dockerci_npu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
MODELSCOPE_CACHE_DIR=/modelscope_cache
CODE_DIR=$PWD
MODELSCOPE_SDK_DEBUG=True
echo "$USER"
gpus='0,1 2,3'
is_get_file_lock=false
CI_COMMAND=${CI_COMMAND:-bash .dev_scripts/ci_container_test.sh pytest tests}
echo "ci command: $CI_COMMAND"
PR_CHANGED_FILES="${PR_CHANGED_FILES:-}"
echo "PR modified files: $PR_CHANGED_FILES"
PR_CHANGED_FILES=${PR_CHANGED_FILES//[ ]/#}
echo "PR_CHANGED_FILES: $PR_CHANGED_FILES"
idx=0
for gpu in $gpus
do
exec {lock_fd}>"/tmp/gpu$gpu" || exit 1
flock -n "$lock_fd" || { echo "WARN: gpu $gpu is in use!" >&2; idx=$((idx+1)); continue; }
echo "get gpu lock $gpu"

let is_get_file_lock=true

# 设置环境变量
export CI_TEST=True
export TEST_LEVEL=$TEST_LEVEL
export MODELSCOPE_CACHE=${MODELSCOPE_CACHE:-$MODELSCOPE_CACHE_DIR}
export MODELSCOPE_DOMAIN=$MODELSCOPE_DOMAIN
export HUB_DATASET_ENDPOINT=$HUB_DATASET_ENDPOINT
export TEST_ACCESS_TOKEN_CITEST=$TEST_ACCESS_TOKEN_CITEST
export TEST_ACCESS_TOKEN_SDKDEV=$TEST_ACCESS_TOKEN_SDKDEV
export MODELSCOPE_ENVIRONMENT='ci'
export TEST_UPLOAD_MS_TOKEN=$TEST_UPLOAD_MS_TOKEN
export MODEL_TAG_URL=$MODEL_TAG_URL
export MODELSCOPE_API_TOKEN=$MODELSCOPE_API_TOKEN
export PR_CHANGED_FILES=$PR_CHANGED_FILES
export CUDA_VISIBLE_DEVICES=$gpu

if [ "$MODELSCOPE_SDK_DEBUG" == "True" ]; then
export MODELSCOPE_SDK_DEBUG=True
echo 'debugging'
fi

# 切换到代码目录并执行命令
cd $CODE_DIR
eval $CI_COMMAND
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using eval can be a security risk, especially if the CI_COMMAND variable could be influenced by an external or untrusted source (e.g., from a pull request). It allows for arbitrary code execution.

While it might be used here to handle arguments with spaces, it's a dangerous pattern. Consider safer alternatives, such as passing arguments to the script directly and using "$@", or using bash -c "$CI_COMMAND" if the command must be in a single string. If eval is absolutely necessary, ensure the CI_COMMAND variable is strictly controlled and sanitized.


if [ $? -ne 0 ]; then
echo "Running test case failed, please check the log!"
exit -1
fi
break
done

if [ "$is_get_file_lock" = false ] ; then
echo 'No free GPU!'
exit 1
fi
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/1-bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "🐛 Bug Report"
description: Create a bug report to help us improve twinkle
labels: ["bug"]

body:
- type: markdown
attributes:
value: |
Thank you for supporting twinkle and taking the time to submit this issue.
感谢你对 twinkle 的支持和抽出时间提交相关 issue。

- type: checkboxes
id: checklist
attributes:
label: Checklist / 检查清单
options:
- label: I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
required: true


- type: textarea
id: bug-description
validations:
required: true
attributes:
label: Bug Description / Bug 描述
description: |
Please describe the issue you encountered. It's better to include error screenshots or stack trace information.
请详细描述你遇到的问题,最好包含报错截图或报错栈信息。


- type: textarea
id: reproduction-steps
validations:
required: true
attributes:
label: How to Reproduce / 如何复现
description: |
Please provide steps to reproduce the issue, including twinkle version, runtime environment, and detailed reproduction steps.
请提供复现问题的步骤,包括 twinkle 的版本、运行环境、详细的复现步骤等。


- type: textarea
id: additional-information
attributes:
label: Additional Information / 补充信息
description: |
Please provide any additional information here.
在这里补充其他相关信息。
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/2-feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "🚀 Feature Request"
description: Submit a request for a new feature
labels: ["enhancement"]

body:
- type: markdown
attributes:
value: |
Thank you for supporting twinkle and taking the time to submit this issue.
感谢你对 twinkle 的支持和抽出时间提交相关 issue。

- type: checkboxes
id: checklist
attributes:
label: Checklist / 检查清单
options:
- label: I have searched existing issues, and this is a new feature request. / 我已经搜索过现有的 issues,确认这是一个新的 Feature Request。
required: true

- type: textarea
id: feature-request-description
validations:
required: true
attributes:
label: Feature Request Description / Feature Request 描述
description: |
Please provide a detailed description of the new feature you would like to see added.
请详细描述您希望添加的新功能特性。


- type: textarea
id: pull-request
attributes:
label: Pull Request / Pull Request 信息
description: |
Have you already submitted or plan to submit a Pull Request? Please share your plans.
你是否已经提交或即将提交 Pull Request?请说明你的计划。
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/3-question-discussion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "🤔 Question & Discussion"
description: Create an issue for questions and discussions
labels: ["question"]

body:
- type: markdown
attributes:
value: |
Thank you for supporting twinkle and taking the time to submit this issue.
感谢你对 twinkle 的支持和抽出时间提交相关 issue。

- type: checkboxes
id: checklist
attributes:
label: Checklist / 检查清单
options:
- label: I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
required: true

- type: textarea
id: question-description
validations:
required: true
attributes:
label: Question Description / 问题描述
description: |
Please describe the question or topic you would like to discuss.
请描述你想要讨论的问题或话题。
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# PR type
- [ ] Bug Fix
- [ ] New Feature
- [ ] Document Updates
- [ ] More Models or Datasets Support

# PR information

Write the detail information belongs to this PR.

## Experiment results

Paste your experiment result here(if needed).
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reporting Security Issues

Usually security issues of a deep learning project come from non-standard 3rd packages or continuous running services. If you are suffering from security issues from our project, please consider reporting to us. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
Loading
Loading