Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ryt Embed cvm-runtime into CortexTheseus #568

Merged
merged 52 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
54f4f11
revise Makefile
declmal May 13, 2020
360eb1c
remove original cvm-runtime
declmal May 13, 2020
3a977a4
Squashed 'cvm-runtime/' content from commit 61fca7172
declmal May 13, 2020
6a732c2
Merge commit '3a977a415d41379228f85d1efa13b8576386c1da' as 'cvm-runtime'
declmal May 13, 2020
e576549
Fixed synapse kernel code & cvm library link
declmal May 18, 2020
1fce3af
revise version
declmal May 18, 2020
f4451c9
update gpu configuration for CortexTheseus
declmal May 19, 2020
7cb4947
remove cvm-runtime
declmal Jun 8, 2020
735203d
remove unused submodule'
declmal Jun 8, 2020
2bfd6a4
submodule add cvm-runtime
declmal Jun 8, 2020
a077653
update cvm-runtime libcvm.go
declmal Jun 8, 2020
0e9b225
reivse version
declmal Jun 8, 2020
4c75646
revise submodule from to && In cvm-runtime: merge ryt_cortex into m…
declmal Jun 10, 2020
a271092
add note for CVM_VERSION_TWO
declmal Jun 10, 2020
1d02f08
add golang unit tests in cvm-runtime
declmal Jun 11, 2020
48a8cca
Merge branch 'master' into ryt
declmal Jun 11, 2020
b5d4b7a
Merge branch 'master' into ryt
ucwong Jun 11, 2020
4dc73d5
fixxing merging conflicts for remote/origin/master
declmal Jun 11, 2020
983d88c
correct import packages
declmal Jun 11, 2020
9f56379
fix conflict
declmal Jun 11, 2020
1109ed4
Enable submodule
wlt-cortex Jun 16, 2020
3b823f0
Enable submodule test
wlt-cortex Jun 16, 2020
152bf64
Enable submodule update
wlt-cortex Jun 16, 2020
7bec1b8
install submodules
ucwong Jun 16, 2020
dcc9139
workflow install fix
ucwong Jun 16, 2020
b299e45
submodule source fix
ucwong Jun 16, 2020
2ca2518
Update go.yml
ucwong Jun 16, 2020
09d3a00
add --recursive to go.yml/install
ucwong Jun 16, 2020
c322396
Merge remote-tracking branch 'origin/master' into ryt
declmal Jun 17, 2020
6b17b0c
update cvm-runtime
declmal Jun 17, 2020
306d42b
Merge branch 'ryt' of github.com:CortexFoundation/CortexTheseus into ryt
declmal Jun 17, 2020
9254b66
remove symlink
declmal Jun 17, 2020
0adaded
fix Makefile for
declmal Jun 19, 2020
c3cb244
adjust for de58
declmal Jun 19, 2020
c8f4d51
pass dolores remote
declmal Jun 23, 2020
072f233
Revert "pass dolores remote"
declmal Jun 23, 2020
c4c2454
Revert "adjust for de58"
declmal Jun 23, 2020
323af0b
tmp revise
declmal Jun 24, 2020
2eb9261
hackFile for invalid torrents, (ignorant of NetworkId)
declmal Jun 24, 2020
77b91ee
using lower case 31f75c90e8fe1c5b16cbdc466dc6127487a92add
declmal Jun 24, 2020
a349acc
add cvmNetworkId into interfaces
declmal Jun 24, 2020
d129d91
replace hash for 31f75c90e8fe1c5b16cbdc466dc6127487a92add
declmal Jun 29, 2020
40ec74e
null change
declmal Jun 29, 2020
159fb9e
revise remote interfaces, dolores remote test passed
declmal Jun 29, 2020
b158a81
remove redundant hash files 31f7
declmal Jun 29, 2020
af7b5d1
fix conflicts and update versiong
declmal Jul 10, 2020
4d9a9bc
remove cvm-runtime
declmal Jul 10, 2020
c87de43
update cvm-runtime tag 1.0.0
declmal Jul 10, 2020
ee3518f
push
declmal Jul 10, 2020
63d508c
Merge remote-tracking branch 'origin/master' into ryt
declmal Jul 10, 2020
1fdc421
remove hackFile and de58
declmal Jul 10, 2020
2283046
verbosity level down for hack
declmal Jul 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
dep ensure
fi

- name: install
run: git submodule update --init --recursive

- name: Build
run: make clean && make -j$(nproc)

Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cvm-runtime"]
path = cvm-runtime
url = https://github.com/CortexFoundation/cvm-runtime.git
branch = master
wlt-cortex marked this conversation as resolved.
Show resolved Hide resolved
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ wnode:
build/env.sh go run build/ci.go install ./cmd/wnode
@echo "Done building."
@echo "Run \"$(GOBIN)/wnode\" to launch cortex whisper node."

torrent-test:
build/env.sh go run build/ci.go install ./cmd/torrent-test
@echo "Done building."
@echo "Run \"$(GOBIN)/torrent-test\" to launch cortex torrentfs-test."

cvm: plugins/lib_cvm.so
build/env.sh go run build/ci.go install ./cmd/cvm
@echo "Done building."
@echo "Run \"$(GOBIN)/cvm\" to launch cortex vm."
nodekey:
build/env.sh go run build/ci.go install ./cmd/nodekey
@echo "Done building."
@echo "Run \"$(GOBIN)/nodekey\" to launch nodekey."

plugins/cuda_helper_for_node.so:
$(MAKE) -C $(BASE)/solution cuda
build/env.sh go build -buildmode=plugin -o $@ consensus/cuckoo/plugins/cuda/cuda_helper_for_node.go
Expand All @@ -84,25 +99,18 @@ plugins/cpu_helper_for_node.so:
#$(MAKE) -C $(BASE)/solution cpu-miner
#build/env.sh go build -buildmode=plugin -o $@ consensus/cuckoo/plugins/cpu_helper_for_node.go

plugins/cuda_cvm.so:
$(MAKE) -C ${INFER_NET_DIR} -j$(nproc) gpu
mkdir -p $(BASE)/plugins
ln -sf ../cvm-runtime/build/gpu/libcvm_runtime_cuda.so $(BASE)/plugins/cuda_cvm.so
# build/env.sh go build -v -tags gpu -buildmode=plugin -o $@ cmd/plugins/c_wrapper.go

plugins/cpu_cvm.so:
$(MAKE) -C ${INFER_NET_DIR} -j$(nproc) cpu
mkdir -p $(BASE)/plugins
ln -sf ../cvm-runtime/build/cpu/libcvm_runtime_cpu.so $(BASE)/plugins/cpu_cvm.so
plugins/lib_cvm.so:
$(MAKE) -C ${INFER_NET_DIR} -j8 lib
@mkdir -p plugins
ln -sf ../cvm-runtime/build/libcvm_runtime.so $@
# build/env.sh go build -v -buildmode=plugin -o $@ cmd/plugins/c_wrapper.go
# ln -sf ../../cvm-runtime/kernel inference/synapse/kernel

clib_cpu: plugins/cpu_helper_for_node.so plugins/cpu_cvm.so
#clib_cpu: plugins/cpu_cvm.so
clib_cpu: plugins/cpu_helper_for_node.so plugins/lib_cvm.so

clib: plugins/cuda_helper_for_node.so plugins/cpu_helper_for_node.so plugins/cuda_cvm.so plugins/cpu_cvm.so
clib: plugins/cuda_helper_for_node.so plugins/cpu_helper_for_node.so plugins/lib_cvm.so

clib_mine: plugins/cuda_helper_for_node.so plugins/cpu_helper_for_node.so plugins/cpu_cvm.so
clib_mine: plugins/cuda_helper_for_node.so plugins/cpu_helper_for_node.so plugins/lib_cvm.so

#inferServer: clib
# build/env.sh go run build/ci.go install ./cmd/infer_server
Expand Down
10 changes: 6 additions & 4 deletions cmd/cortex/cvm_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func AvailableHandler(w http.ResponseWriter, inferWork *inference.AvailableWork)
return
}

if err := synapse.Engine().Available(inferWork.InfoHash, inferWork.RawSize); err != nil {
if err := synapse.Engine().Available(inferWork.InfoHash, inferWork.RawSize, inferWork.CvmNetworkId); err != nil {
RespErrorText(w, err)
} else {
ret_arr := Uint64ToBytes(1)
Expand All @@ -43,7 +43,7 @@ func gasHandler(w http.ResponseWriter, inferWork *inference.GasWork) {
return
}

ret, err := synapse.Engine().GetGasByInfoHash(inferWork.Model)
ret, err := synapse.Engine().GetGasByInfoHash(inferWork.Model, inferWork.CvmNetworkId)
if err != nil {
log.Warn("Gas calculate Failed", "error", err)
RespErrorText(w, err)
Expand All @@ -68,7 +68,8 @@ func infoHashHandler(w http.ResponseWriter, inferWork *inference.IHWork) {
}

log.Debug("Infer Task", "Model Hash", inferWork.Model, "Input Hash", inferWork.Input)
label, err := synapse.Engine().InferByInfoHash(inferWork.Model, inferWork.Input)
label, err := synapse.Engine().InferByInfoHash(
inferWork.Model, inferWork.Input, inferWork.CvmVersion, inferWork.CvmNetworkId)

if err != nil {
RespErrorText(w, err)
Expand Down Expand Up @@ -101,7 +102,8 @@ func inputContentHandler(w http.ResponseWriter, inferWork *inference.ICWork) {
// return
// }

label, err := synapse.Engine().InferByInputContent(model, input)
label, err := synapse.Engine().InferByInputContent(
model, input, inferWork.CvmVersion, inferWork.CvmNetworkId)
if err != nil {
log.Warn("Infer Failed", "error", err)
RespErrorText(w, err)
Expand Down
21 changes: 14 additions & 7 deletions core/vm/cvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,14 @@ func (cvm *CVM) DataSync(meta common.Address, dir string, errCh chan error) {
// infer function that returns an int64 as output, can be used a categorical output
func (cvm *CVM) Infer(modelInfoHash, inputInfoHash string, modelRawSize, inputRawSize uint64) ([]byte, error) {
//log.Info("Inference Information", "Model Hash", modelInfoHash, "Input Hash", inputInfoHash)
cvmNetworkId := cvm.chainConfig.ChainID.Int64()
if !cvm.vmConfig.DebugInferVM {
if err := synapse.Engine().Available(modelInfoHash, int64(modelRawSize)); err != nil {
if err := synapse.Engine().Available(modelInfoHash, int64(modelRawSize), cvmNetworkId); err != nil {
log.Warn("Infer", "Torrent file model not available, blockchain and torrent not match, modelInfoHash", modelInfoHash, "err", err)
return nil, err
}

if err := synapse.Engine().Available(inputInfoHash, int64(inputRawSize)); err != nil {
if err := synapse.Engine().Available(inputInfoHash, int64(inputRawSize), cvmNetworkId); err != nil {
//log.Warn("File non available", "inputInfoHash:", inputInfoHash, "err", err)
return nil, err
}
Expand All @@ -591,7 +592,9 @@ func (cvm *CVM) Infer(modelInfoHash, inputInfoHash string, modelRawSize, inputRa

start := mclock.Now()

inferRes, errRes = synapse.Engine().InferByInfoHash(modelInfoHash, inputInfoHash)
cvmVersion := synapse.CVMVersion(cvm.chainConfig, cvm.BlockNumber)
inferRes, errRes = synapse.Engine().InferByInfoHash(
modelInfoHash, inputInfoHash, cvmVersion, cvmNetworkId)
elapsed := time.Duration(mclock.Now()) - time.Duration(start)

if errRes == nil {
Expand All @@ -612,8 +615,9 @@ func (cvm *CVM) InferArray(modelInfoHash string, inputArray []byte, modelRawSize
if cvm.vmConfig.DebugInferVM {
fmt.Println("Model Hash", modelInfoHash, "number", cvm.BlockNumber, "Input Content", hexutil.Encode(inputArray))
}
cvmNetworkId := cvm.chainConfig.ChainID.Int64()
if !cvm.vmConfig.DebugInferVM {
if err := synapse.Engine().Available(modelInfoHash, int64(modelRawSize)); err != nil {
if err := synapse.Engine().Available(modelInfoHash, int64(modelRawSize), cvmNetworkId); err != nil {
log.Warn("InferArray", "modelInfoHash", modelInfoHash, "not Available", err)
return nil, err
}
Expand All @@ -626,7 +630,9 @@ func (cvm *CVM) InferArray(modelInfoHash string, inputArray []byte, modelRawSize

start := mclock.Now()

inferRes, errRes = synapse.Engine().InferByInputContent(modelInfoHash, inputArray)
cvmVersion := synapse.CVMVersion(cvm.chainConfig, cvm.BlockNumber)
inferRes, errRes = synapse.Engine().InferByInputContent(
modelInfoHash, inputArray, cvmVersion, cvmNetworkId)
elapsed := time.Duration(mclock.Now()) - time.Duration(start)

if errRes == nil {
Expand All @@ -644,17 +650,18 @@ func (cvm *CVM) OpsInfer(addr common.Address) (opsRes uint64, errRes error) {
return 0, err
}
modelRawSize := modelMeta.RawSize
cvmNetworkId := cvm.chainConfig.ChainID.Int64()

if !cvm.vmConfig.DebugInferVM {
if err := synapse.Engine().Available(modelMeta.Hash.Hex(), int64(modelRawSize)); err != nil {
if err := synapse.Engine().Available(modelMeta.Hash.Hex(), int64(modelRawSize), cvmNetworkId); err != nil {
log.Debug("cvm", "modelMeta", modelMeta, "modelRawSize", modelRawSize, "err", err)
return 0, err
}
}

start := mclock.Now()

opsRes, errRes = synapse.Engine().GetGasByInfoHash(modelMeta.Hash.Hex())
opsRes, errRes = synapse.Engine().GetGasByInfoHash(modelMeta.Hash.Hex(), cvmNetworkId)

elapsed := time.Duration(mclock.Now()) - time.Duration(start)

Expand Down
1 change: 1 addition & 0 deletions cvm-runtime
Submodule cvm-runtime added at dc9132
39 changes: 0 additions & 39 deletions cvm-runtime/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions cvm-runtime/.gitmodules

This file was deleted.

123 changes: 0 additions & 123 deletions cvm-runtime/CMakeLists.txt

This file was deleted.

19 changes: 0 additions & 19 deletions cvm-runtime/Makefile

This file was deleted.