Skip to content

Reference coordinator#

istemci/koordinator.py is the full implementation of protocol v1, tested with real training (Python standard HTTP server + PyTorch). It is the shortest way to start without writing your own coordinator.

Requirements#

  • Python 3.10+, torch, safetensors, transformers, peft (to produce the starting adapter)
  • Base model: models/qwen3-0.6b-base (Qwen/Qwen3-0.6B-Base, Apache-2.0). The coordinator only handles adapter weights, but the script that produces the starting adapter needs the model. No GPU needed.
  • RAM: a few hundred MB (adapter 40 MB, multiplied by the number of workers).

Running#

python istemci/baslat.py                                   # produces the round-0 adapter
python istemci/koordinator.py \
    --baslangic istemci/calisma/tur-0.safetensors \
    --tur 20 --en-az 2 --ic-adim 20 --port 8750

Status panel: http://127.0.0.1:8750/ (JSON: /durum).

Flags#

FlagDefaultMeaning
--baslangic(required)Starting adapter (baslat.py output)
--host127.0.0.1Address to listen on. Do not use 0.0.0.0 directly on public networks; use a reverse proxy
--port8750Port
--tur6Total rounds
--en-az2Minimum results needed to close a round
--zaman-asimi900Seconds; when it expires, the round closes with the results at hand (≥1)
--parca4Number of data shards (n_parca); assigned to workers in rotation
--ic-adim20H: the worker's local steps
--bs4Batch size
--seq512Sequence length
--lr2e-4Peak learning rate (cosine schedule on the worker)
--dis-lr1.0Outer-step learning rate
--dis-mom0.5Outer-step momentum
--aykiri-kat5.0Drop a result whose delta norm exceeds this multiple of the median (with ≥3 results)
--anahtar(empty)If set, all requests must carry an X-Anahtar header. Several comma-separated keys are allowed (one per volunteer; rotate a leaked one by restarting)
--veri(empty)Tokenised training data (safetensors); sharded and served to workers at /veri. Produced with istemci/veri_donustur.py
--modcptTraining mode announced to workers: cpt or sft
--sifirdanoffIgnore the saved state in the work folder and start from round 0
--en-cok-isci1000Maximum number of distinct worker names tracked (memory bound); new workers beyond it get 503
--istek-siniri240Maximum requests per IP per minute (0 = unlimited); beyond it 429
--vekiloffBehind a trusted reverse proxy: take the client IP from X-Forwarded-For
--calismaistemci/calismaOutput folder
--tohum0Starting-adapter seed

Output files#

In the --calisma folder:

FileContent
tur-N.safetensorsGlobal adapter after round N (round 0 is the start)
durum.json, momentum.safetensorsPersistent state written at the end of every round (round, worker-shard assignments, outer-step momentum). After a restart the coordinator resumes where it stopped; --sifirdan ignores it
gunluk.jsonRound log (workers used/dropped, delta norms, duration) and traffic
sorular.jsonlCommunity questions arriving via /soru (read with python istemci/sorular.py)

Publishing on the public internet#

coordinator.example.org {
    reverse_proxy 127.0.0.1:8750
}

(Add --vekil so rate limits use the real client IP.) Then run the conformance test and verify your address. A persistent systemd unit:

[Unit]
Description=Modelen coordinator
After=network.target

[Service]
User=modelen
WorkingDirectory=/opt/modelen
ExecStart=/opt/modelen/.venv/bin/python istemci/koordinator.py --baslangic istemci/calisma/tur-0.safetensors --tur 50 --en-az 3 --vekil
Restart=always

[Install]
WantedBy=multi-user.target

Known limits#

Dikkat

The reference coordinator is a prototype:

  • The outer-step momentum is written to disk at the end of every round and restored on restart; results of a round still in progress live in memory and are lost, and workers resubmit that round.
  • Authentication is only an optional shared key(s); there are no accounts. There is a per-IP rate limit and a worker-count limit, but this is not a defence against Sybil attacks.
  • Poisoning protection is only simple outlier-norm elimination (with ≥3 results). It is not enough against a determined attacker; repeated verification (giving the same task to two workers and comparing) is not done.
  • No TLS; a reverse proxy is required.
  • All workers take the same number of steps; a slow GPU delays the round (the timeout closes it with what is at hand).

More detail: istemci/ISTEMCI.md.