Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
742 commits
Select commit Hold shift + click to select a range
9f72ea6
feat(transformers): refactor optimizer parameter grouping for clarity
meichangsu1 Feb 2, 2026
9ca28d0
wip
tastelikefeet Feb 2, 2026
520991e
Merge commit '797078ac840723a59e32096bc164c5a86200ed68' into dev
tastelikefeet Feb 2, 2026
9adb7d0
feat(model): condition sp_strategy postprocessing on missing labels
meichangsu1 Feb 2, 2026
b21f8ad
feat(model): integrate sp_strategy loss reduction in TransformersModel
meichangsu1 Feb 2, 2026
b713d66
refactor processor
tastelikefeet Feb 2, 2026
6561350
wip
tastelikefeet Feb 2, 2026
9e4d950
fix
tastelikefeet Feb 2, 2026
853f289
wip
tastelikefeet Feb 2, 2026
3841384
feat(sequence_parallel): add docstrings and clarify SP group derivation
meichangsu1 Feb 2, 2026
3837bc9
Merge pull request #25 from modelscope/sp_ljl_dev
meichangsu1 Feb 3, 2026
99ffea8
wip
kevssim Feb 3, 2026
fadd7ac
Merge remote-tracking branch 'origin/dev' into expert_parallel
kevssim Feb 3, 2026
20fed75
update queue
Yunnglin Feb 3, 2026
f485955
wip
meichangsu1 Feb 3, 2026
7b4acd9
Merge pull request #26 from modelscope/sp_ljl_dev
meichangsu1 Feb 3, 2026
1cceb74
refactor expert parallel strategy and add grad clipping utility
kevssim Feb 3, 2026
5cda1af
Merge pull request #23 from modelscope/expert_parallel
kevssim Feb 3, 2026
a3b761e
update queue
Yunnglin Feb 3, 2026
aeb2027
update queue
Yunnglin Feb 3, 2026
5b285e7
update queue
Yunnglin Feb 3, 2026
27768d4
update queue
Yunnglin Feb 3, 2026
6a004af
update queue
Yunnglin Feb 3, 2026
51cc9ba
update queue
Yunnglin Feb 3, 2026
dbd0c52
fix
tastelikefeet Feb 3, 2026
b531079
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 3, 2026
d83ce5a
fix
tastelikefeet Feb 3, 2026
896170a
tinker api npu adapt
addsubmuldiv Feb 3, 2026
21ed267
update queue
Yunnglin Feb 3, 2026
109a8d7
Merge pull request #27 from modelscope/tps_control
Yunnglin Feb 3, 2026
c21bba6
refactor code
tastelikefeet Feb 3, 2026
d156ac7
Merge commit '109a8d74b2b668f1a071d2dff9e663b652941959' into dev
tastelikefeet Feb 3, 2026
bac13f3
remove unused loss functions
tastelikefeet Feb 3, 2026
dfbf13b
refactor code
tastelikefeet Feb 3, 2026
2613924
refactor code
tastelikefeet Feb 3, 2026
4190ef9
wip
tastelikefeet Feb 3, 2026
452e419
support num_samples in sampler (#28)
hjh0119 Feb 3, 2026
9ffd27d
fix
tastelikefeet Feb 3, 2026
8570b94
Merge commit '452e41909048d9734f6e9cfa5d9b29cf4f2ebe6c' into dev
tastelikefeet Feb 3, 2026
6f297a5
fix
tastelikefeet Feb 3, 2026
69c0790
fix
tastelikefeet Feb 3, 2026
5f1cec6
0203 单元测试
hzher Feb 3, 2026
143350f
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
hzher Feb 3, 2026
af20ed7
fix
tastelikefeet Feb 3, 2026
dfb4ff7
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 3, 2026
f72aba3
fix ci
tastelikefeet Feb 3, 2026
2ce2eb9
Merge commit 'dfb4ff70fb540e937364c1d4a910219f926ac75e' into dev
tastelikefeet Feb 3, 2026
5adea48
update example
Yunnglin Feb 3, 2026
5dd887b
fix
tastelikefeet Feb 3, 2026
68505a8
fix base model class
tastelikefeet Feb 3, 2026
ef8e170
fix name
tastelikefeet Feb 3, 2026
665cd50
fix dist initialization
tastelikefeet Feb 3, 2026
b6aafbc
update example
Yunnglin Feb 3, 2026
bce02e8
Merge pull request #29 from modelscope/add_tinker_example
Yunnglin Feb 3, 2026
0d2c1d0
fix
tastelikefeet Feb 3, 2026
88f9252
Merge branch 'dev' of https://github.com/modelscope/twinkle into dev
tastelikefeet Feb 3, 2026
ac21024
Merge branch 'dev' into remote_npu
addsubmuldiv Feb 3, 2026
08bd0e9
Merge branch 'dev' into remote_npu
addsubmuldiv Feb 3, 2026
d0745e7
Merge pull request #22 from modelscope/remote_npu
addsubmuldiv Feb 3, 2026
ad909ac
fix ep
kevssim Feb 4, 2026
e3ab369
feat(platform): refactor data_world_size calculation for FSDP compati…
meichangsu1 Feb 4, 2026
b4fb21e
feat(platform): refactor data_world_size calculation and improve asse…
meichangsu1 Feb 4, 2026
cbffd52
update
Yunnglin Feb 4, 2026
113e8f1
feat(utils): improve gather_object to handle distributed groups and i…
meichangsu1 Feb 4, 2026
4631843
Merge pull request #30 from modelscope/sp_ljl_dev
meichangsu1 Feb 4, 2026
422b798
wip
kevssim Feb 4, 2026
54c99bf
Merge remote-tracking branch 'origin/dev' into dev-wkw
kevssim Feb 4, 2026
902f9dd
add twinkle save push
Yunnglin Feb 4, 2026
a63d6a4
sampler add lora (#31)
hjh0119 Feb 4, 2026
1145fb5
add twinkle save push
Yunnglin Feb 4, 2026
1e0d369
add twinkle save push
Yunnglin Feb 4, 2026
33566fb
Merge branch 'dev' into add_upload_weight
Yunnglin Feb 4, 2026
789c5d0
add twinkle save push
Yunnglin Feb 4, 2026
6229d40
Merge pull request #32 from modelscope/add_upload_weight
Yunnglin Feb 4, 2026
4d3c443
add readme and docs
tastelikefeet Feb 4, 2026
dd93baf
wip
tastelikefeet Feb 4, 2026
9de4613
wip
tastelikefeet Feb 4, 2026
1cebf0a
wip
kevssim Feb 5, 2026
b5679bd
Merge remote-tracking branch 'origin/dev' into dev-wkw
kevssim Feb 5, 2026
dc67b12
wip
tastelikefeet Feb 5, 2026
88cacd0
docs for npu support
addsubmuldiv Feb 5, 2026
256ce76
docs update
addsubmuldiv Feb 5, 2026
ba89de4
update
addsubmuldiv Feb 5, 2026
39e3404
update
addsubmuldiv Feb 5, 2026
0c99fd3
add push lock
Yunnglin Feb 5, 2026
478e538
update
addsubmuldiv Feb 5, 2026
76d9f10
update
addsubmuldiv Feb 5, 2026
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
a8450de
fix npu grpo
addsubmuldiv Feb 11, 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
40 changes: 40 additions & 0 deletions .dev_scripts/ci_container_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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
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 optimum

# test with install
pip install .
else
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.

high

There is a large amount of duplicated code between the if and else blocks for running the docker container. This makes the script hard to read and maintain. Any changes to the docker run command will need to be applied in two places, which is error-prone.

You can refactor this by storing the common docker arguments in an array and conditionally adding the debug-specific arguments. This also allows you to remove the duplicated -e TEST_LEVEL=$TEST_LEVEL flag.

  docker_args=(
    --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_args+=(-e MODELSCOPE_SDK_DEBUG=True)
  fi

  docker run "${docker_args[@]}" "${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 with a variable that can be set from an environment variable (CI_COMMAND) is a significant security risk. It can allow arbitrary command execution if the CI_COMMAND environment variable is manipulated. It's strongly recommended to avoid eval here. If the command structure is known, you can parse it and execute it more safely, for example by using an array.


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