Repository navigation
Finish train + infernet: p2p dataset/adapter pieces, multi-turn chats, native p2p chat - #165
Merged
Merged
Conversation
…native p2p chat train (infernet.text.train, `c0mpute train lora`): - The corpus goes out as content-addressed 1 MiB pieces from the buyer's chunk store; the worker pulls them over libp2p (InputRef::fetch_to_file, streamed) and checks the sha256 the offer names. Training events are published on the job topic (run_id, step events throttled to 4/s). The worker stores the adapter files as pieces behind an AdapterManifest and its receipt carries the manifest's content hash; the buyer fetches and keeps the adapter only if the weights match the manifest's sha256. Nothing needs a reachable HTTP address any more. - `c0mpute infernet text chat` (infernet.text.infer) is p2p the same way: adapter out as pieces (fetched on a worker cache miss), answer back as a chunk named by the receipt. - Compatibility: specs keep the HTTP fields optional. Workers before this release require dataset_url/adapter_url, so they never bid on a pieces-only job; `--legacy-http` makes the buyer also run the transfer server for them (receipt `sha256:` = the old HTTP path, checked as before). Old buyers' HTTP specs still parse and run on new workers. - Multi-turn chats: messages records are kept whole (every turn, in order) and prompt/completion becomes a one-exchange conversation, instead of collapsing to a "Brief me on: <last user turn>" record. Infernet's runner trains them with the loss on assistant turns (InfernetProtocol/infernet-protocol#161) and reports formats:["messages"]; workers then advertise infernet:text:format:messages and buyers whose corpus has conversations require it. {title, text} records are unchanged. - module.toml: available. infernet (infernet.inference): - New built-in workload c0mpute-core/src/inference.rs: workers answer chat turns from their own OpenAI-compatible runtime (Ollama at 127.0.0.1:11434 by default, C0MPUTE_INFERENCE_URL for llama-server etc., `off` disables). Role `inference`, on by default, advertised only while /v1/models lists chat models (refreshed every minute): infernet:inference plus a tag per model. Answers are stored as chunks and checked against the receipt. - `c0mpute chat --p2p` (the default when not signed in) runs one auction per turn over libp2p, REPL included; the jobs bridge accepts it too. No c0mpute.com and no infernet binary on either side. - module.toml: available; temporal and text workers still need the infernet CLI for Infernet's own runtimes. Tests: text_train_e2e (3 MiB mixed corpus as pieces on loopback with a fake peft runner, gossip progress, adapter pieces verified, then adapter chat p2p), inference_e2e (multi-turn chat p2p via the bridge; also passed against the live Ollama on dev2), unit tests for specs, compat, conversion and tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| print("usage: infernet model generate --adapter <dir> | --input <request.json>", file=sys.stderr) | ||
| sys.exit(2) | ||
| req = json.load(open(flag("--input"))) | ||
| weights = open(os.path.join(req["adapter_dir"], "adapter_model.safetensors"), "rb").read() |
ThreatCrush Security Scan13 finding(s) HIGH/CRITICAL: 1 | MEDIUM: 8 | LOW: 4
Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
train (
c0mpute train lora,infernet.text.train) → available(a) Peer to peer instead of buyer-hosted HTTP
pieces::put_bytes_pieces) and names them in the spec (corpus_hash/corpus_size/corpus_pieces). The worker pulls them over libp2p (newInputRef::fetch_to_file, streamed) and checks the offer's sha256.run_id; step events throttled to 4/s).AdapterManifestchunk; the receipt'soutput_hashis the manifest hash. Buyer fetches manifest + pieces and keeps the adapter only if the weights match the manifest's sha256. Worker job dir is removed afterwards; worker adapter pieces expire after 6 h.c0mpute infernet text chat(infernet.text.infer, the "use it" step) is p2p the same way: adapter out as pieces (only on a worker cache miss), answer back as a chunk.spawn_node_with_store).Compatibility. HTTP fields became optional. Workers before this release require
dataset_url/adapter_url, so they can't parse a pieces-only spec and never bid on one.--legacy-httpmakes the buyer also run the old transfer server so those workers can bid; asha256:receipt means the old HTTP path, checked exactly as before. Old buyers' HTTP specs still parse and run on new workers. A new worker prefers pieces when both are present.(b) Multi-turn chats.
messagesrecords stay whole (every turn, in order) and prompt/completion becomes a one-exchange conversation (the prompt verbatim, not "Brief me on: …"). Training them needs InfernetProtocol/infernet-protocol#161: the peft runner renders each conversation with the model's chat template, puts the loss on assistant turns only, and reportsformats: ["text","messages"]. Workers advertiseinfernet:text:format:messagesonly when their runner reports it, and a buyer whose corpus has conversations requires that tag, so an older runner (which would drop them) never wins the job.{title, text}records are unchanged.infernet (
infernet.inference) → availableBefore this,
c0mpute chatonly went through c0mpute.com's HTTP API (with sign-in), andc0mpute infernet chathanded off to the separate infernet CLI.c0mpute-core/src/inference.rs: workers answer from their own OpenAI-compatible runtime (Ollama at127.0.0.1:11434by default,C0MPUTE_INFERENCE_URLfor llama-server etc.,offdisables). New roleinference, on by default, advertised only while/v1/modelslists chat models (refreshed every minute):infernet:inferenceplusinfernet:inference:model:<id>. The runtime URL comes only from operator config, never from a spec. Answers are stored as chunks and checked against the receipt.c0mpute chat --p2p "…"(the default when not signed in) runs one auction per turn over libp2p, REPL included. Thec0mpute jobs servebridge acceptsinfernet.inferencetoo.infernet.temporal.*) and text train/infer (peft). Buyers never need it, and neither side needs it for chat. Answers come back in one piece; tokens are not streamed across the network yet.Tests (docker,
--network none --offline)cargo test --workspace --locked: all green (core lib 299 after merging master, cli 19).text_train_e2e(new, 2 tests): a 3 MiB mixed corpus (text + prompt/completion + 5-turn chats) goes out as pieces on loopback to a worker with a fake peft runner (tests/fixtures/fake-infernet-text). It writes a deterministic 2.5 MiB adapter derived from the corpus it received. The test checks: progress over gossip, the adapter coming back as pieces and matching byte for byte, every conversation turn reaching the trainer, worker cleanup, a tampered manifest being refused, then adapter chat p2p with a worker-side cache.inference_e2e(new): a multi-turn chat goes p2p through the bridge to a stand-in runtime (every turn forwarded in order), a named model works, an unserved model gets no bids, an invalid spec is refused. Also run against the live Ollama on dev2 (C0MPUTE_INFERENCE_LIVE_URL, host network): passed, and the model answered "Blue."🤖 Generated with Claude Code