Skip to content

Instantly share code, notes, and snippets.

@zhangw
zhangw / codefuse-chatbot-test-local-llmapi.py
Created February 21, 2024 02:53
codefuse-chatbot-test-local-llmapi
# 启动测试
import openai
openai.api_key = "" # Not support yet
openai.api_base = "http://127.0.0.1:18888/v1"
# 选择你启动的模型
model = "codellama_34b"
# create a chat completion
completion = openai.ChatCompletion.create(
@zhangw
zhangw / fschat-codefuse-codellama-34B-4bits
Last active February 4, 2024 09:23
fastchat load model
python -m fastchat.serve.cli --gptq-wbits 4 --gptq-group 64 --model-path $HOME/.cache/modelscope/hub/codefuse-ai/CodeFuse-CodeLlama-34B-4bits --device cuda --style rich
python -m fastchat.serve.controller
python -m fastchat.serve.model_worker --gptq-wbits 4 --gptq-group 64 --model-path $HOME/.cache/modelscope/hub/codefuse-ai/CodeFuse-CodeLlama-34B-4bits --device cuda
python -m fastchat.serve.test_message --model-name CodeFuse-CodeLlama-34B-4bits
python -m fastchat.serve.gradio_web_server
@zhangw
zhangw / load-codefuse-codellama-34B-4bits.py
Last active February 21, 2024 02:52
load-codefuse-codellama-34B-4bits
import os
import torch
import time
from modelscope import AutoTokenizer, snapshot_download
from auto_gptq import AutoGPTQForCausalLM
os.environ["TOKENIZERS_PARALLELISM"] = "false"
def load_model_tokenizer(model_path):
"""

Libuv and libev, two I/O libraries with similar names, recently had the privilege to use both libraries to write something. Now let's talk about my own subjective expression of common and different points.

The topic of high-performance network programming has been discussed. Asynchronous, asynchronous, or asynchronous. Whether it is epoll or kqueue, it is always indispensable to the asynchronous topic.

Libuv is asynchronous, and libev is synchronous multiplexing IO multiplexing.

Libev is a simple encapsulation of system I/O reuse. Basically, it solves the problem of different APIs between epoll and kqueuq. Ensure that programs written using livev's API can run on most *nix platforms. However, the disadvantages of libev are also obvious. Because it basically just encapsulates the Event Library, it is inconvenient to use. For example, accept(3) requires manual setnonblocking after connection. EAGAIN, EWOULDBLOCK, and EINTER need to be detected when reading from a socket. This is a

@zhangw
zhangw / daemonset-scaledown.md
Created June 20, 2023 12:09 — forked from ragul28/daemonset-scaledown.md
k8s Trick to Scale down daemonset to zero
  • Scaling k8s daemonset down to zero
kubectl -n kube-system patch daemonset myDaemonset -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'
  • Scaling up k8s daemonset
kubectl -n kube-system patch daemonset myDaemonset --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'
@zhangw
zhangw / README.md
Created June 14, 2023 08:10 — forked from ayosec/README.md
GDB commands to trace calls to malloc/free

Attach to a running process with

  gdb -x trace-dyn-mem -p $PID

After every malloc the returned value (the allocated address) will be read from the RAX (64 bits) register.

After every free the last item in the backtrace (the free itself) will be shown. With the libc6-dbg package installed you can see the address passed as the first argument of free.

@zhangw
zhangw / gist:06624e63baefda8523fb76b6003d2aa7
Last active March 30, 2023 04:02
Building starrocks fe on MacOS
# check the specific thrift version from fe-core, for 2.5.3
ag THRIFT_DOWNLOAD thirdparty/vars.sh
## 90:THRIFT_DOWNLOAD="http://archive.apache.org/dist/thrift/0.13.0/thrift-0.13.0.tar.gz"
# install the specific thrift version, using brew which help to compile automatically
brew tap-new $USER/local-tap
brew extract --version='0.13.0' thrift $USER/local-tap
brew install thrift@0.13.0
## check the installation path, for me
/opt/homebrew/Cellar/thrift@0.13.0/0.13.0/bin/thrift --version
@zhangw
zhangw / rust-openssl-musl-archlinux-build
Created February 18, 2023 15:03
rust + openssl + musl + archlinux
## install musl
sudo pacman -Syu musl
## install headers of musl
sudo pacman -Syu kernel-headers-musl
## cargo add musl target and toolchain
rustup target add --toolchain stable x86_64-unknown-linux-musl
## download openssl source code, version is 3.0.7
@zhangw
zhangw / rust-cross-compile-openssl
Last active February 18, 2023 05:16 — forked from marirs/rust-cross-compile-openssl
Rust OpenSSL Cross Compile for Linux on Mac M1
# Install the toolchain
```bash
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu
```
# this should get installed in:
# /opt/homebrew/Cellar/x86_64-unknown-linux-gnu/
# Installing the macOS OpenSSL - if not already installed
@zhangw
zhangw / README.md
Created October 11, 2022 04:32 — forked from darrenpmeyer/README.md
Automatically start a single instance of ssh-agent for all terminal sessions to share (bash)

Installation

  1. mkdir -p ~/.config && touch ~/.config/ssh-agent.pid
  2. Paste the contents of ssh-agent-manage.sh into your .bashrc or .bash_profile or similar
  3. killall -9 ssh-agent
  4. Start a new terminal session (note: old sessions will not see ssh-agent, only new ones)

Details

This snippet, when included in .bashrc, will ensure that your session has a working ssh-agent with all your ssh keys loaded into it. It does this without creating separate ssh-agent processes by: