feat(fine-tuning): storage-first delivery flow with TEE fallback#354
feat(fine-tuning): storage-first delivery flow with TEE fallback#354
Conversation
- Finalizer now always encrypts locally first (TEE backup) - Then attempts upload to 0G Storage (unless skipStorageUpload=true) - If storage upload fails, falls back to local hash gracefully - Encrypted file is always retained for TEE download fallback - Removes old encryptAndUploadModel (split into encrypt + upload) Co-authored-by: Cursor <cursoragent@cursor.com>
Previously DownloadFromStorage always assumed ZIP format, causing "zip: not a valid zip file" when CLI uploads raw JSONL to 0G Storage. Changes: - Detect file type via magic bytes before attempting unzip - For non-ZIP files (raw JSONL), move directly to target path - Convert raw JSONL to HuggingFace DatasetDict format after download (required by token counter and training executor) Co-authored-by: Cursor <cursoragent@cursor.com>
- DownloadFromStorage: detect file type via magic bytes, handle non-ZIP - Clean up existing target before rename on retry - Convert raw JSONL to HF DatasetDict format after download - Auto-calculate fee when fee=0 (broker-calculated fee mode) - Verify signature with original fee to avoid mismatch Co-authored-by: Cursor <cursoragent@cursor.com>
|
Claude finished @zeyuyuyu's task in 1m 48s —— View job Code ReviewTodo List
OverviewThis PR implements a storage-first delivery flow with TEE fallback for fine-tuning model delivery and adds support for raw JSONL dataset handling. The changes improve robustness by:
Critical Issues[HIGH]
|
- [HIGH] Use passed ctx instead of context.Background() in Download call for proper cancellation/timeout propagation - [HIGH] Add defer cleanup for temp download file to prevent disk leaks on early error returns - [MEDIUM] Improve isZipFile() to return errors on I/O failures instead of silently treating them as non-ZIP files Co-authored-by: Cursor <cursoragent@cursor.com>
|
Claude finished @zeyuyuyu's task in 1m 48s —— View job Code ReviewTodo List
OverviewThis PR implements a storage-first delivery flow with TEE fallback for fine-tuning model delivery and adds automatic handling of raw JSONL datasets. The changes significantly improve robustness and user experience. Key improvements:
Critical Issues[HIGH]
|
- Upgrade 0g-storage-client v1.2.1 → v1.2.2 to fix ABI incompatibility with testnet Flow contract (was causing `execution reverted; data: 0x`) - Remove deprecated WithRoutines() calls (now set internally via UploaderConfig in v1.2.2) - Fix uploadModel() to return raw 32-byte hash (hash.Bytes()) instead of hex string bytes ([]byte(hash.Hex())), which caused double-encoding via hexutil.Encode and prevented client from downloading model via 0G Storage Tested: Full flow verified with Qwen2.5-0.5B and Qwen3-32B (1.1GB model) — broker upload, client download from 0G Storage, decrypt, LoRA verified. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Key Changes
Storage Client (
storage/client.go)DownloadFromStorage: detects ZIP vs raw file via magic bytes (PK\x03\x04)Setup Service (
services/setup.go)Finalizer (
services/finalizer.go)skipStorageUploadis false; falls back to local hash on failureTest plan
--dataset-pathuploads JSONL to 0G StorageMade with Cursor