tribunal-kit 9.2.3 → 9.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/.tribunal/session.jsonl +15 -0
- package/.agent/ARCHITECTURE.md +4 -4
- package/.agent/agents/agent-shield-auditor.md +18 -0
- package/.agent/agents/harness-manager.md +49 -0
- package/.agent/agents/human-gate-negotiator.md +22 -0
- package/.agent/agents/kernel-scheduler.md +56 -0
- package/.agent/agents/memory-archivist.md +37 -0
- package/.agent/agents/orchestrator.md +5 -0
- package/.agent/agents/project-planner.md +5 -0
- package/.agent/agents/security-auditor.md +5 -0
- package/.agent/rules/GEMINI.md +1 -1
- package/.agent/scripts/_utils.js +1 -1
- package/.agent/scripts/checklist.js +1 -1
- package/.agent/scripts/context_compiler.js +1 -1
- package/.agent/scripts/guardrail_engine.js +1 -1
- package/.agent/scripts/harness_manager.js +60 -0
- package/.agent/scripts/lint_runner.js +1 -1
- package/.agent/scripts/mcp_server.js +181 -0
- package/.agent/scripts/memory_archivist.js +97 -0
- package/.agent/scripts/memory_consolidator.js +37 -0
- package/.agent/scripts/memory_engine.js +61 -21
- package/.agent/scripts/pipeline_engine.js +17 -2
- package/.agent/scripts/session_logger.js +115 -0
- package/.agent/scripts/session_manager.js +10 -0
- package/.agent/scripts/swarm_dispatcher.js +74 -1
- package/.agent/scripts/syscall_registry.js +105 -0
- package/.agent/scripts/test_runner.js +1 -1
- package/.agent/scripts/verify_all.js +2 -2
- package/.agent/skill_topic_map.json +28 -1
- package/.agent/skills/agent-syscall-guidelines/SKILL.md +25 -0
- package/.agent/skills/agentic-workflows-2026/SKILL.md +8 -0
- package/.agent/skills/agentshield-security/SKILL.md +26 -0
- package/.agent/skills/context-engineering-pro/SKILL.md +7 -0
- package/.agent/skills/fabel-protocol/SKILL.md +5 -0
- package/.agent/skills/graph-engineering/SKILL.md +28 -0
- package/.agent/skills/harness-protocol/SKILL.md +8 -0
- package/.agent/skills/hf-cli/SKILL.md +239 -0
- package/.agent/skills/hf-cloud-aws-context-discovery/SKILL.md +74 -0
- package/.agent/skills/hf-cloud-python-env-setup/SKILL.md +90 -0
- package/.agent/skills/hf-cloud-python-env-setup/requirements.txt +17 -0
- package/.agent/skills/hf-cloud-python-env-setup/scripts/check_versions.py +29 -0
- package/.agent/skills/hf-cloud-python-env-setup/scripts/setup_env.py +143 -0
- package/.agent/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +90 -0
- package/.agent/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +102 -0
- package/.agent/skills/hf-cloud-sagemaker-iam-preflight/references/minimum-permissions.json +47 -0
- package/.agent/skills/hf-cloud-sagemaker-iam-preflight/references/trust-policy.json +12 -0
- package/.agent/skills/hf-cloud-sagemaker-iam-preflight/scripts/check_role.py +184 -0
- package/.agent/skills/hf-cloud-sagemaker-iam-preflight/scripts/create_role.py +118 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +419 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/references/deployment-template.md +59 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/_common.py +148 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy.py +327 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_async.py +434 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_ic.py +506 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/invoke_endpoint.py +180 -0
- package/.agent/skills/hf-cloud-sagemaker-production-defaults/scripts/teardown.py +246 -0
- package/.agent/skills/hf-cloud-serving-image-selection/SKILL.md +220 -0
- package/.agent/skills/hf-cloud-serving-image-selection/references/model-to-image.md +111 -0
- package/.agent/skills/hf-cloud-serving-image-selection/scripts/mirror_image.py +145 -0
- package/.agent/skills/hf-mem/SKILL.md +79 -0
- package/.agent/skills/huggingface-best/SKILL.md +134 -0
- package/.agent/skills/huggingface-community-evals/SKILL.md +207 -0
- package/.agent/skills/huggingface-community-evals/examples/.env.example +3 -0
- package/.agent/skills/huggingface-community-evals/examples/USAGE_EXAMPLES.md +101 -0
- package/.agent/skills/huggingface-community-evals/scripts/inspect_eval_uv.py +104 -0
- package/.agent/skills/huggingface-community-evals/scripts/inspect_vllm_uv.py +306 -0
- package/.agent/skills/huggingface-community-evals/scripts/lighteval_vllm_uv.py +297 -0
- package/.agent/skills/huggingface-datasets/SKILL.md +107 -0
- package/.agent/skills/huggingface-gradio/SKILL.md +298 -0
- package/.agent/skills/huggingface-gradio/examples.md +613 -0
- package/.agent/skills/huggingface-llm-trainer/SKILL.md +738 -0
- package/.agent/skills/huggingface-llm-trainer/references/gguf_conversion.md +296 -0
- package/.agent/skills/huggingface-llm-trainer/references/hardware_guide.md +283 -0
- package/.agent/skills/huggingface-llm-trainer/references/hub_saving.md +364 -0
- package/.agent/skills/huggingface-llm-trainer/references/local_training_macos.md +231 -0
- package/.agent/skills/huggingface-llm-trainer/references/reliability_principles.md +371 -0
- package/.agent/skills/huggingface-llm-trainer/references/trackio_guide.md +191 -0
- package/.agent/skills/huggingface-llm-trainer/references/training_methods.md +150 -0
- package/.agent/skills/huggingface-llm-trainer/references/training_patterns.md +203 -0
- package/.agent/skills/huggingface-llm-trainer/references/troubleshooting.md +282 -0
- package/.agent/skills/huggingface-llm-trainer/references/unsloth.md +313 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/convert_to_gguf.py +424 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/dataset_inspector.py +417 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/estimate_cost.py +150 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/hf_benchmarks.py +659 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/train_dpo_example.py +106 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/train_grpo_example.py +89 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/train_sft_example.py +122 -0
- package/.agent/skills/huggingface-llm-trainer/scripts/unsloth_sft_example.py +512 -0
- package/.agent/skills/huggingface-local-models/SKILL.md +113 -0
- package/.agent/skills/huggingface-local-models/references/hardware.md +38 -0
- package/.agent/skills/huggingface-local-models/references/hub-discovery.md +178 -0
- package/.agent/skills/huggingface-local-models/references/quantization.md +256 -0
- package/.agent/skills/huggingface-lora-space-builder/SKILL.md +394 -0
- package/.agent/skills/huggingface-lora-space-builder/references/adapting-to-the-lora.md +113 -0
- package/.agent/skills/huggingface-lora-space-builder/references/base-models/krea-2.md +63 -0
- package/.agent/skills/huggingface-lora-space-builder/references/base-models/ltx.md +205 -0
- package/.agent/skills/huggingface-lora-space-builder/references/base-models/qwen-image.md +144 -0
- package/.agent/skills/huggingface-lora-space-builder/references/creative-mode.md +262 -0
- package/.agent/skills/huggingface-lora-space-builder/references/tasks.md +124 -0
- package/.agent/skills/huggingface-lora-space-builder/references/zerogpu-and-publishing.md +196 -0
- package/.agent/skills/huggingface-paper-publisher/SKILL.md +624 -0
- package/.agent/skills/huggingface-paper-publisher/examples/example_usage.md +326 -0
- package/.agent/skills/huggingface-paper-publisher/references/quick_reference.md +216 -0
- package/.agent/skills/huggingface-paper-publisher/scripts/paper_manager.py +606 -0
- package/.agent/skills/huggingface-paper-publisher/templates/arxiv.md +299 -0
- package/.agent/skills/huggingface-paper-publisher/templates/ml-report.md +358 -0
- package/.agent/skills/huggingface-paper-publisher/templates/modern.md +319 -0
- package/.agent/skills/huggingface-paper-publisher/templates/standard.md +201 -0
- package/.agent/skills/huggingface-papers/SKILL.md +239 -0
- package/.agent/skills/huggingface-spaces/README.md +9 -0
- package/.agent/skills/huggingface-spaces/SKILL.md +242 -0
- package/.agent/skills/huggingface-spaces/references/3d-cuda-extensions.md +109 -0
- package/.agent/skills/huggingface-spaces/references/3d-generation.md +98 -0
- package/.agent/skills/huggingface-spaces/references/3d-gsplat.md +53 -0
- package/.agent/skills/huggingface-spaces/references/3d-models.md +227 -0
- package/.agent/skills/huggingface-spaces/references/3d-outputs.md +114 -0
- package/.agent/skills/huggingface-spaces/references/buckets.md +89 -0
- package/.agent/skills/huggingface-spaces/references/debugging.md +236 -0
- package/.agent/skills/huggingface-spaces/references/gradio.md +200 -0
- package/.agent/skills/huggingface-spaces/references/grants.md +63 -0
- package/.agent/skills/huggingface-spaces/references/inference-providers.md +97 -0
- package/.agent/skills/huggingface-spaces/references/known-errors.md +232 -0
- package/.agent/skills/huggingface-spaces/references/requirements.md +169 -0
- package/.agent/skills/huggingface-spaces/references/zerogpu.md +349 -0
- package/.agent/skills/huggingface-tool-builder/SKILL.md +120 -0
- package/.agent/skills/huggingface-tool-builder/references/baseline_hf_api.py +57 -0
- package/.agent/skills/huggingface-tool-builder/references/baseline_hf_api.sh +40 -0
- package/.agent/skills/huggingface-tool-builder/references/baseline_hf_api.tsx +57 -0
- package/.agent/skills/huggingface-tool-builder/references/find_models_by_paper.sh +230 -0
- package/.agent/skills/huggingface-tool-builder/references/hf_enrich_models.sh +96 -0
- package/.agent/skills/huggingface-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
- package/.agent/skills/huggingface-tool-builder/references/hf_model_papers_auth.sh +171 -0
- package/.agent/skills/huggingface-trackio/SKILL.md +142 -0
- package/.agent/skills/huggingface-trackio/references/alerts.md +196 -0
- package/.agent/skills/huggingface-trackio/references/logging_metrics.md +212 -0
- package/.agent/skills/huggingface-trackio/references/retrieving_metrics.md +251 -0
- package/.agent/skills/huggingface-vision-trainer/SKILL.md +593 -0
- package/.agent/skills/huggingface-vision-trainer/references/finetune_sam2_trainer.md +254 -0
- package/.agent/skills/huggingface-vision-trainer/references/hub_saving.md +618 -0
- package/.agent/skills/huggingface-vision-trainer/references/image_classification_training_notebook.md +279 -0
- package/.agent/skills/huggingface-vision-trainer/references/object_detection_training_notebook.md +700 -0
- package/.agent/skills/huggingface-vision-trainer/references/reliability_principles.md +310 -0
- package/.agent/skills/huggingface-vision-trainer/references/timm_trainer.md +91 -0
- package/.agent/skills/huggingface-vision-trainer/scripts/dataset_inspector.py +814 -0
- package/.agent/skills/huggingface-vision-trainer/scripts/estimate_cost.py +217 -0
- package/.agent/skills/huggingface-vision-trainer/scripts/image_classification_training.py +383 -0
- package/.agent/skills/huggingface-vision-trainer/scripts/object_detection_training.py +710 -0
- package/.agent/skills/huggingface-vision-trainer/scripts/sam_segmentation_training.py +382 -0
- package/.agent/skills/huggingface-zerogpu/SKILL.md +289 -0
- package/.agent/skills/huggingface-zerogpu/references/concurrency.md +79 -0
- package/.agent/skills/huggingface-zerogpu/references/cuda-and-deps.md +66 -0
- package/.agent/skills/huggingface-zerogpu/references/how-quota-works.md +74 -0
- package/.agent/skills/huggingface-zerogpu/references/how-zerogpu-works.md +50 -0
- package/.agent/skills/human-gate-negotiation/SKILL.md +30 -0
- package/.agent/skills/intelligent-routing/SKILL.md +10 -4
- package/.agent/skills/semantic-filesystem-navigation/SKILL.md +24 -0
- package/.agent/skills/session-log-interrogation/SKILL.md +29 -0
- package/.agent/skills/subagent-driven-development/SKILL.md +32 -0
- package/.agent/skills/systematic-debugging/SKILL.md +5 -0
- package/.agent/skills/train-sentence-transformers/SKILL.md +109 -0
- package/.agent/skills/train-sentence-transformers/references/base_model_selection.md +79 -0
- package/.agent/skills/train-sentence-transformers/references/dataset_formats.md +128 -0
- package/.agent/skills/train-sentence-transformers/references/evaluators_cross_encoder.md +116 -0
- package/.agent/skills/train-sentence-transformers/references/evaluators_multi_vector_encoder.md +101 -0
- package/.agent/skills/train-sentence-transformers/references/evaluators_sentence_transformer.md +151 -0
- package/.agent/skills/train-sentence-transformers/references/evaluators_sparse_encoder.md +121 -0
- package/.agent/skills/train-sentence-transformers/references/hardware_guide.md +105 -0
- package/.agent/skills/train-sentence-transformers/references/hf_jobs_execution.md +173 -0
- package/.agent/skills/train-sentence-transformers/references/losses_cross_encoder.md +137 -0
- package/.agent/skills/train-sentence-transformers/references/losses_multi_vector_encoder.md +100 -0
- package/.agent/skills/train-sentence-transformers/references/losses_sentence_transformer.md +246 -0
- package/.agent/skills/train-sentence-transformers/references/losses_sparse_encoder.md +106 -0
- package/.agent/skills/train-sentence-transformers/references/model_architectures.md +178 -0
- package/.agent/skills/train-sentence-transformers/references/prompts_and_instructions.md +160 -0
- package/.agent/skills/train-sentence-transformers/references/training_args.md +270 -0
- package/.agent/skills/train-sentence-transformers/references/troubleshooting.md +225 -0
- package/.agent/skills/train-sentence-transformers/scripts/mine_hard_negatives.py +199 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_cross_encoder_distillation_example.py +254 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_cross_encoder_example.py +253 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_cross_encoder_listwise_example.py +282 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_multi_vector_encoder_example.py +240 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_distillation_example.py +303 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_example.py +227 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_make_multilingual_example.py +308 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_matryoshka_example.py +212 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_multi_dataset_example.py +258 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_static_embedding_example.py +273 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sentence_transformer_with_lora_example.py +275 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sparse_encoder_distillation_example.py +262 -0
- package/.agent/skills/train-sentence-transformers/scripts/train_sparse_encoder_example.py +237 -0
- package/.agent/skills/transformers-js/SKILL.md +692 -0
- package/.agent/skills/transformers-js/references/CACHE.md +339 -0
- package/.agent/skills/transformers-js/references/CONFIGURATION.md +438 -0
- package/.agent/skills/transformers-js/references/EXAMPLES.md +620 -0
- package/.agent/skills/transformers-js/references/MODEL_ARCHITECTURES.md +167 -0
- package/.agent/skills/transformers-js/references/MODEL_REGISTRY.md +197 -0
- package/.agent/skills/transformers-js/references/PIPELINE_OPTIONS.md +557 -0
- package/.agent/skills/transformers-js/references/TEXT_GENERATION.md +315 -0
- package/.agent/skills/tribunal-instincts-memory/SKILL.md +31 -0
- package/.agent/skills/trl-training/SKILL.md +318 -0
- package/.agent/workflows/assimilate.md +21 -0
- package/.agent/workflows/audit.md +5 -0
- package/.agent/workflows/generate.md +5 -0
- package/.agent/workflows/htop.md +22 -0
- package/.agent/workflows/marathon.md +5 -0
- package/.agent/workflows/resume.md +20 -0
- package/.agent/workflows/team-mode.md +22 -0
- package/.agents/skills/agent-syscall-guidelines/SKILL.md +25 -0
- package/.agents/skills/agentic-workflows-2026/SKILL.md +8 -0
- package/.agents/skills/agentshield-security/SKILL.md +26 -0
- package/.agents/skills/context-engineering-pro/SKILL.md +7 -0
- package/.agents/skills/fabel-protocol/SKILL.md +5 -0
- package/.agents/skills/graph-engineering/SKILL.md +28 -0
- package/.agents/skills/harness-protocol/SKILL.md +8 -0
- package/.agents/skills/hf-cli/SKILL.md +239 -0
- package/.agents/skills/hf-cloud-aws-context-discovery/SKILL.md +74 -0
- package/.agents/skills/hf-cloud-python-env-setup/SKILL.md +90 -0
- package/.agents/skills/hf-cloud-python-env-setup/requirements.txt +17 -0
- package/.agents/skills/hf-cloud-python-env-setup/scripts/check_versions.py +29 -0
- package/.agents/skills/hf-cloud-python-env-setup/scripts/setup_env.py +143 -0
- package/.agents/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +90 -0
- package/.agents/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +102 -0
- package/.agents/skills/hf-cloud-sagemaker-iam-preflight/references/minimum-permissions.json +47 -0
- package/.agents/skills/hf-cloud-sagemaker-iam-preflight/references/trust-policy.json +12 -0
- package/.agents/skills/hf-cloud-sagemaker-iam-preflight/scripts/check_role.py +184 -0
- package/.agents/skills/hf-cloud-sagemaker-iam-preflight/scripts/create_role.py +118 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +419 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/references/deployment-template.md +59 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/_common.py +148 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy.py +327 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_async.py +434 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_ic.py +506 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/invoke_endpoint.py +180 -0
- package/.agents/skills/hf-cloud-sagemaker-production-defaults/scripts/teardown.py +246 -0
- package/.agents/skills/hf-cloud-serving-image-selection/SKILL.md +220 -0
- package/.agents/skills/hf-cloud-serving-image-selection/references/model-to-image.md +111 -0
- package/.agents/skills/hf-cloud-serving-image-selection/scripts/mirror_image.py +145 -0
- package/.agents/skills/hf-mem/SKILL.md +79 -0
- package/.agents/skills/huggingface-best/SKILL.md +134 -0
- package/.agents/skills/huggingface-community-evals/SKILL.md +207 -0
- package/.agents/skills/huggingface-community-evals/examples/.env.example +3 -0
- package/.agents/skills/huggingface-community-evals/examples/USAGE_EXAMPLES.md +101 -0
- package/.agents/skills/huggingface-community-evals/scripts/inspect_eval_uv.py +104 -0
- package/.agents/skills/huggingface-community-evals/scripts/inspect_vllm_uv.py +306 -0
- package/.agents/skills/huggingface-community-evals/scripts/lighteval_vllm_uv.py +297 -0
- package/.agents/skills/huggingface-datasets/SKILL.md +107 -0
- package/.agents/skills/huggingface-gradio/SKILL.md +298 -0
- package/.agents/skills/huggingface-gradio/examples.md +613 -0
- package/.agents/skills/huggingface-llm-trainer/SKILL.md +738 -0
- package/.agents/skills/huggingface-llm-trainer/references/gguf_conversion.md +296 -0
- package/.agents/skills/huggingface-llm-trainer/references/hardware_guide.md +283 -0
- package/.agents/skills/huggingface-llm-trainer/references/hub_saving.md +364 -0
- package/.agents/skills/huggingface-llm-trainer/references/local_training_macos.md +231 -0
- package/.agents/skills/huggingface-llm-trainer/references/reliability_principles.md +371 -0
- package/.agents/skills/huggingface-llm-trainer/references/trackio_guide.md +191 -0
- package/.agents/skills/huggingface-llm-trainer/references/training_methods.md +150 -0
- package/.agents/skills/huggingface-llm-trainer/references/training_patterns.md +203 -0
- package/.agents/skills/huggingface-llm-trainer/references/troubleshooting.md +282 -0
- package/.agents/skills/huggingface-llm-trainer/references/unsloth.md +313 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/convert_to_gguf.py +424 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/dataset_inspector.py +417 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/estimate_cost.py +150 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/hf_benchmarks.py +659 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/train_dpo_example.py +106 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/train_grpo_example.py +89 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/train_sft_example.py +122 -0
- package/.agents/skills/huggingface-llm-trainer/scripts/unsloth_sft_example.py +512 -0
- package/.agents/skills/huggingface-local-models/SKILL.md +113 -0
- package/.agents/skills/huggingface-local-models/references/hardware.md +38 -0
- package/.agents/skills/huggingface-local-models/references/hub-discovery.md +178 -0
- package/.agents/skills/huggingface-local-models/references/quantization.md +256 -0
- package/.agents/skills/huggingface-lora-space-builder/SKILL.md +394 -0
- package/.agents/skills/huggingface-lora-space-builder/references/adapting-to-the-lora.md +113 -0
- package/.agents/skills/huggingface-lora-space-builder/references/base-models/krea-2.md +63 -0
- package/.agents/skills/huggingface-lora-space-builder/references/base-models/ltx.md +205 -0
- package/.agents/skills/huggingface-lora-space-builder/references/base-models/qwen-image.md +144 -0
- package/.agents/skills/huggingface-lora-space-builder/references/creative-mode.md +262 -0
- package/.agents/skills/huggingface-lora-space-builder/references/tasks.md +124 -0
- package/.agents/skills/huggingface-lora-space-builder/references/zerogpu-and-publishing.md +196 -0
- package/.agents/skills/huggingface-paper-publisher/SKILL.md +624 -0
- package/.agents/skills/huggingface-paper-publisher/examples/example_usage.md +326 -0
- package/.agents/skills/huggingface-paper-publisher/references/quick_reference.md +216 -0
- package/.agents/skills/huggingface-paper-publisher/scripts/paper_manager.py +606 -0
- package/.agents/skills/huggingface-paper-publisher/templates/arxiv.md +299 -0
- package/.agents/skills/huggingface-paper-publisher/templates/ml-report.md +358 -0
- package/.agents/skills/huggingface-paper-publisher/templates/modern.md +319 -0
- package/.agents/skills/huggingface-paper-publisher/templates/standard.md +201 -0
- package/.agents/skills/huggingface-papers/SKILL.md +239 -0
- package/.agents/skills/huggingface-spaces/README.md +9 -0
- package/.agents/skills/huggingface-spaces/SKILL.md +242 -0
- package/.agents/skills/huggingface-spaces/references/3d-cuda-extensions.md +109 -0
- package/.agents/skills/huggingface-spaces/references/3d-generation.md +98 -0
- package/.agents/skills/huggingface-spaces/references/3d-gsplat.md +53 -0
- package/.agents/skills/huggingface-spaces/references/3d-models.md +227 -0
- package/.agents/skills/huggingface-spaces/references/3d-outputs.md +114 -0
- package/.agents/skills/huggingface-spaces/references/buckets.md +89 -0
- package/.agents/skills/huggingface-spaces/references/debugging.md +236 -0
- package/.agents/skills/huggingface-spaces/references/gradio.md +200 -0
- package/.agents/skills/huggingface-spaces/references/grants.md +63 -0
- package/.agents/skills/huggingface-spaces/references/inference-providers.md +97 -0
- package/.agents/skills/huggingface-spaces/references/known-errors.md +232 -0
- package/.agents/skills/huggingface-spaces/references/requirements.md +169 -0
- package/.agents/skills/huggingface-spaces/references/zerogpu.md +349 -0
- package/.agents/skills/huggingface-tool-builder/SKILL.md +120 -0
- package/.agents/skills/huggingface-tool-builder/references/baseline_hf_api.py +57 -0
- package/.agents/skills/huggingface-tool-builder/references/baseline_hf_api.sh +40 -0
- package/.agents/skills/huggingface-tool-builder/references/baseline_hf_api.tsx +57 -0
- package/.agents/skills/huggingface-tool-builder/references/find_models_by_paper.sh +230 -0
- package/.agents/skills/huggingface-tool-builder/references/hf_enrich_models.sh +96 -0
- package/.agents/skills/huggingface-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
- package/.agents/skills/huggingface-tool-builder/references/hf_model_papers_auth.sh +171 -0
- package/.agents/skills/huggingface-trackio/SKILL.md +142 -0
- package/.agents/skills/huggingface-trackio/references/alerts.md +196 -0
- package/.agents/skills/huggingface-trackio/references/logging_metrics.md +212 -0
- package/.agents/skills/huggingface-trackio/references/retrieving_metrics.md +251 -0
- package/.agents/skills/huggingface-vision-trainer/SKILL.md +593 -0
- package/.agents/skills/huggingface-vision-trainer/references/finetune_sam2_trainer.md +254 -0
- package/.agents/skills/huggingface-vision-trainer/references/hub_saving.md +618 -0
- package/.agents/skills/huggingface-vision-trainer/references/image_classification_training_notebook.md +279 -0
- package/.agents/skills/huggingface-vision-trainer/references/object_detection_training_notebook.md +700 -0
- package/.agents/skills/huggingface-vision-trainer/references/reliability_principles.md +310 -0
- package/.agents/skills/huggingface-vision-trainer/references/timm_trainer.md +91 -0
- package/.agents/skills/huggingface-vision-trainer/scripts/dataset_inspector.py +814 -0
- package/.agents/skills/huggingface-vision-trainer/scripts/estimate_cost.py +217 -0
- package/.agents/skills/huggingface-vision-trainer/scripts/image_classification_training.py +383 -0
- package/.agents/skills/huggingface-vision-trainer/scripts/object_detection_training.py +710 -0
- package/.agents/skills/huggingface-vision-trainer/scripts/sam_segmentation_training.py +382 -0
- package/.agents/skills/huggingface-zerogpu/SKILL.md +289 -0
- package/.agents/skills/huggingface-zerogpu/references/concurrency.md +79 -0
- package/.agents/skills/huggingface-zerogpu/references/cuda-and-deps.md +66 -0
- package/.agents/skills/huggingface-zerogpu/references/how-quota-works.md +74 -0
- package/.agents/skills/huggingface-zerogpu/references/how-zerogpu-works.md +50 -0
- package/.agents/skills/human-gate-negotiation/SKILL.md +30 -0
- package/.agents/skills/intelligent-routing/SKILL.md +10 -4
- package/.agents/skills/semantic-filesystem-navigation/SKILL.md +24 -0
- package/.agents/skills/session-log-interrogation/SKILL.md +29 -0
- package/.agents/skills/subagent-driven-development/SKILL.md +32 -0
- package/.agents/skills/systematic-debugging/SKILL.md +5 -0
- package/.agents/skills/train-sentence-transformers/SKILL.md +109 -0
- package/.agents/skills/train-sentence-transformers/references/base_model_selection.md +79 -0
- package/.agents/skills/train-sentence-transformers/references/dataset_formats.md +128 -0
- package/.agents/skills/train-sentence-transformers/references/evaluators_cross_encoder.md +116 -0
- package/.agents/skills/train-sentence-transformers/references/evaluators_multi_vector_encoder.md +101 -0
- package/.agents/skills/train-sentence-transformers/references/evaluators_sentence_transformer.md +151 -0
- package/.agents/skills/train-sentence-transformers/references/evaluators_sparse_encoder.md +121 -0
- package/.agents/skills/train-sentence-transformers/references/hardware_guide.md +105 -0
- package/.agents/skills/train-sentence-transformers/references/hf_jobs_execution.md +173 -0
- package/.agents/skills/train-sentence-transformers/references/losses_cross_encoder.md +137 -0
- package/.agents/skills/train-sentence-transformers/references/losses_multi_vector_encoder.md +100 -0
- package/.agents/skills/train-sentence-transformers/references/losses_sentence_transformer.md +246 -0
- package/.agents/skills/train-sentence-transformers/references/losses_sparse_encoder.md +106 -0
- package/.agents/skills/train-sentence-transformers/references/model_architectures.md +178 -0
- package/.agents/skills/train-sentence-transformers/references/prompts_and_instructions.md +160 -0
- package/.agents/skills/train-sentence-transformers/references/training_args.md +270 -0
- package/.agents/skills/train-sentence-transformers/references/troubleshooting.md +225 -0
- package/.agents/skills/train-sentence-transformers/scripts/mine_hard_negatives.py +199 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_cross_encoder_distillation_example.py +254 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_cross_encoder_example.py +253 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_cross_encoder_listwise_example.py +282 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_multi_vector_encoder_example.py +240 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_distillation_example.py +303 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_example.py +227 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_make_multilingual_example.py +308 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_matryoshka_example.py +212 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_multi_dataset_example.py +258 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_static_embedding_example.py +273 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sentence_transformer_with_lora_example.py +275 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sparse_encoder_distillation_example.py +262 -0
- package/.agents/skills/train-sentence-transformers/scripts/train_sparse_encoder_example.py +237 -0
- package/.agents/skills/transformers-js/SKILL.md +692 -0
- package/.agents/skills/transformers-js/references/CACHE.md +339 -0
- package/.agents/skills/transformers-js/references/CONFIGURATION.md +438 -0
- package/.agents/skills/transformers-js/references/EXAMPLES.md +620 -0
- package/.agents/skills/transformers-js/references/MODEL_ARCHITECTURES.md +167 -0
- package/.agents/skills/transformers-js/references/MODEL_REGISTRY.md +197 -0
- package/.agents/skills/transformers-js/references/PIPELINE_OPTIONS.md +557 -0
- package/.agents/skills/transformers-js/references/TEXT_GENERATION.md +315 -0
- package/.agents/skills/tribunal-instincts-memory/SKILL.md +31 -0
- package/.agents/skills/trl-training/SKILL.md +318 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +135 -435
- package/bin/adapter-install.js +1 -1
- package/bin/mcp-server.js +5 -5
- package/dist/tui/banner.js +1 -1
- package/gemini-extension.json +1 -1
- package/mcp_config.json +1 -1
- package/package.json +7 -7
- package/plugin.json +1 -1
- package/scripts/context_compiler.js +1 -1
- package/scripts/skill_enhancement_engine.js +6 -6
- package/skills/agent-syscall-guidelines/SKILL.md +25 -0
- package/skills/agentic-workflows-2026/SKILL.md +8 -0
- package/skills/agentshield-security/SKILL.md +26 -0
- package/skills/context-engineering-pro/SKILL.md +7 -0
- package/skills/fabel-protocol/SKILL.md +5 -0
- package/skills/graph-engineering/SKILL.md +28 -0
- package/skills/harness-protocol/SKILL.md +8 -0
- package/skills/hf-cli/SKILL.md +239 -0
- package/skills/hf-cloud-aws-context-discovery/SKILL.md +74 -0
- package/skills/hf-cloud-python-env-setup/SKILL.md +90 -0
- package/skills/hf-cloud-python-env-setup/requirements.txt +17 -0
- package/skills/hf-cloud-python-env-setup/scripts/check_versions.py +29 -0
- package/skills/hf-cloud-python-env-setup/scripts/setup_env.py +143 -0
- package/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +90 -0
- package/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +102 -0
- package/skills/hf-cloud-sagemaker-iam-preflight/references/minimum-permissions.json +47 -0
- package/skills/hf-cloud-sagemaker-iam-preflight/references/trust-policy.json +12 -0
- package/skills/hf-cloud-sagemaker-iam-preflight/scripts/check_role.py +184 -0
- package/skills/hf-cloud-sagemaker-iam-preflight/scripts/create_role.py +118 -0
- package/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +419 -0
- package/skills/hf-cloud-sagemaker-production-defaults/references/deployment-template.md +59 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/_common.py +148 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy.py +327 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_async.py +434 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/deploy_ic.py +506 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/invoke_endpoint.py +180 -0
- package/skills/hf-cloud-sagemaker-production-defaults/scripts/teardown.py +246 -0
- package/skills/hf-cloud-serving-image-selection/SKILL.md +220 -0
- package/skills/hf-cloud-serving-image-selection/references/model-to-image.md +111 -0
- package/skills/hf-cloud-serving-image-selection/scripts/mirror_image.py +145 -0
- package/skills/hf-mem/SKILL.md +79 -0
- package/skills/huggingface-best/SKILL.md +134 -0
- package/skills/huggingface-community-evals/SKILL.md +207 -0
- package/skills/huggingface-community-evals/examples/.env.example +3 -0
- package/skills/huggingface-community-evals/examples/USAGE_EXAMPLES.md +101 -0
- package/skills/huggingface-community-evals/scripts/inspect_eval_uv.py +104 -0
- package/skills/huggingface-community-evals/scripts/inspect_vllm_uv.py +306 -0
- package/skills/huggingface-community-evals/scripts/lighteval_vllm_uv.py +297 -0
- package/skills/huggingface-datasets/SKILL.md +107 -0
- package/skills/huggingface-gradio/SKILL.md +298 -0
- package/skills/huggingface-gradio/examples.md +613 -0
- package/skills/huggingface-llm-trainer/SKILL.md +738 -0
- package/skills/huggingface-llm-trainer/references/gguf_conversion.md +296 -0
- package/skills/huggingface-llm-trainer/references/hardware_guide.md +283 -0
- package/skills/huggingface-llm-trainer/references/hub_saving.md +364 -0
- package/skills/huggingface-llm-trainer/references/local_training_macos.md +231 -0
- package/skills/huggingface-llm-trainer/references/reliability_principles.md +371 -0
- package/skills/huggingface-llm-trainer/references/trackio_guide.md +191 -0
- package/skills/huggingface-llm-trainer/references/training_methods.md +150 -0
- package/skills/huggingface-llm-trainer/references/training_patterns.md +203 -0
- package/skills/huggingface-llm-trainer/references/troubleshooting.md +282 -0
- package/skills/huggingface-llm-trainer/references/unsloth.md +313 -0
- package/skills/huggingface-llm-trainer/scripts/convert_to_gguf.py +424 -0
- package/skills/huggingface-llm-trainer/scripts/dataset_inspector.py +417 -0
- package/skills/huggingface-llm-trainer/scripts/estimate_cost.py +150 -0
- package/skills/huggingface-llm-trainer/scripts/hf_benchmarks.py +659 -0
- package/skills/huggingface-llm-trainer/scripts/train_dpo_example.py +106 -0
- package/skills/huggingface-llm-trainer/scripts/train_grpo_example.py +89 -0
- package/skills/huggingface-llm-trainer/scripts/train_sft_example.py +122 -0
- package/skills/huggingface-llm-trainer/scripts/unsloth_sft_example.py +512 -0
- package/skills/huggingface-local-models/SKILL.md +113 -0
- package/skills/huggingface-local-models/references/hardware.md +38 -0
- package/skills/huggingface-local-models/references/hub-discovery.md +178 -0
- package/skills/huggingface-local-models/references/quantization.md +256 -0
- package/skills/huggingface-lora-space-builder/SKILL.md +394 -0
- package/skills/huggingface-lora-space-builder/references/adapting-to-the-lora.md +113 -0
- package/skills/huggingface-lora-space-builder/references/base-models/krea-2.md +63 -0
- package/skills/huggingface-lora-space-builder/references/base-models/ltx.md +205 -0
- package/skills/huggingface-lora-space-builder/references/base-models/qwen-image.md +144 -0
- package/skills/huggingface-lora-space-builder/references/creative-mode.md +262 -0
- package/skills/huggingface-lora-space-builder/references/tasks.md +124 -0
- package/skills/huggingface-lora-space-builder/references/zerogpu-and-publishing.md +196 -0
- package/skills/huggingface-paper-publisher/SKILL.md +624 -0
- package/skills/huggingface-paper-publisher/examples/example_usage.md +326 -0
- package/skills/huggingface-paper-publisher/references/quick_reference.md +216 -0
- package/skills/huggingface-paper-publisher/scripts/paper_manager.py +606 -0
- package/skills/huggingface-paper-publisher/templates/arxiv.md +299 -0
- package/skills/huggingface-paper-publisher/templates/ml-report.md +358 -0
- package/skills/huggingface-paper-publisher/templates/modern.md +319 -0
- package/skills/huggingface-paper-publisher/templates/standard.md +201 -0
- package/skills/huggingface-papers/SKILL.md +239 -0
- package/skills/huggingface-spaces/README.md +9 -0
- package/skills/huggingface-spaces/SKILL.md +242 -0
- package/skills/huggingface-spaces/references/3d-cuda-extensions.md +109 -0
- package/skills/huggingface-spaces/references/3d-generation.md +98 -0
- package/skills/huggingface-spaces/references/3d-gsplat.md +53 -0
- package/skills/huggingface-spaces/references/3d-models.md +227 -0
- package/skills/huggingface-spaces/references/3d-outputs.md +114 -0
- package/skills/huggingface-spaces/references/buckets.md +89 -0
- package/skills/huggingface-spaces/references/debugging.md +236 -0
- package/skills/huggingface-spaces/references/gradio.md +200 -0
- package/skills/huggingface-spaces/references/grants.md +63 -0
- package/skills/huggingface-spaces/references/inference-providers.md +97 -0
- package/skills/huggingface-spaces/references/known-errors.md +232 -0
- package/skills/huggingface-spaces/references/requirements.md +169 -0
- package/skills/huggingface-spaces/references/zerogpu.md +349 -0
- package/skills/huggingface-tool-builder/SKILL.md +120 -0
- package/skills/huggingface-tool-builder/references/baseline_hf_api.py +57 -0
- package/skills/huggingface-tool-builder/references/baseline_hf_api.sh +40 -0
- package/skills/huggingface-tool-builder/references/baseline_hf_api.tsx +57 -0
- package/skills/huggingface-tool-builder/references/find_models_by_paper.sh +230 -0
- package/skills/huggingface-tool-builder/references/hf_enrich_models.sh +96 -0
- package/skills/huggingface-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
- package/skills/huggingface-tool-builder/references/hf_model_papers_auth.sh +171 -0
- package/skills/huggingface-trackio/SKILL.md +142 -0
- package/skills/huggingface-trackio/references/alerts.md +196 -0
- package/skills/huggingface-trackio/references/logging_metrics.md +212 -0
- package/skills/huggingface-trackio/references/retrieving_metrics.md +251 -0
- package/skills/huggingface-vision-trainer/SKILL.md +593 -0
- package/skills/huggingface-vision-trainer/references/finetune_sam2_trainer.md +254 -0
- package/skills/huggingface-vision-trainer/references/hub_saving.md +618 -0
- package/skills/huggingface-vision-trainer/references/image_classification_training_notebook.md +279 -0
- package/skills/huggingface-vision-trainer/references/object_detection_training_notebook.md +700 -0
- package/skills/huggingface-vision-trainer/references/reliability_principles.md +310 -0
- package/skills/huggingface-vision-trainer/references/timm_trainer.md +91 -0
- package/skills/huggingface-vision-trainer/scripts/dataset_inspector.py +814 -0
- package/skills/huggingface-vision-trainer/scripts/estimate_cost.py +217 -0
- package/skills/huggingface-vision-trainer/scripts/image_classification_training.py +383 -0
- package/skills/huggingface-vision-trainer/scripts/object_detection_training.py +710 -0
- package/skills/huggingface-vision-trainer/scripts/sam_segmentation_training.py +382 -0
- package/skills/huggingface-zerogpu/SKILL.md +289 -0
- package/skills/huggingface-zerogpu/references/concurrency.md +79 -0
- package/skills/huggingface-zerogpu/references/cuda-and-deps.md +66 -0
- package/skills/huggingface-zerogpu/references/how-quota-works.md +74 -0
- package/skills/huggingface-zerogpu/references/how-zerogpu-works.md +50 -0
- package/skills/human-gate-negotiation/SKILL.md +30 -0
- package/skills/intelligent-routing/SKILL.md +10 -4
- package/skills/semantic-filesystem-navigation/SKILL.md +24 -0
- package/skills/session-log-interrogation/SKILL.md +29 -0
- package/skills/subagent-driven-development/SKILL.md +32 -0
- package/skills/systematic-debugging/SKILL.md +5 -0
- package/skills/train-sentence-transformers/SKILL.md +109 -0
- package/skills/train-sentence-transformers/references/base_model_selection.md +79 -0
- package/skills/train-sentence-transformers/references/dataset_formats.md +128 -0
- package/skills/train-sentence-transformers/references/evaluators_cross_encoder.md +116 -0
- package/skills/train-sentence-transformers/references/evaluators_multi_vector_encoder.md +101 -0
- package/skills/train-sentence-transformers/references/evaluators_sentence_transformer.md +151 -0
- package/skills/train-sentence-transformers/references/evaluators_sparse_encoder.md +121 -0
- package/skills/train-sentence-transformers/references/hardware_guide.md +105 -0
- package/skills/train-sentence-transformers/references/hf_jobs_execution.md +173 -0
- package/skills/train-sentence-transformers/references/losses_cross_encoder.md +137 -0
- package/skills/train-sentence-transformers/references/losses_multi_vector_encoder.md +100 -0
- package/skills/train-sentence-transformers/references/losses_sentence_transformer.md +246 -0
- package/skills/train-sentence-transformers/references/losses_sparse_encoder.md +106 -0
- package/skills/train-sentence-transformers/references/model_architectures.md +178 -0
- package/skills/train-sentence-transformers/references/prompts_and_instructions.md +160 -0
- package/skills/train-sentence-transformers/references/training_args.md +270 -0
- package/skills/train-sentence-transformers/references/troubleshooting.md +225 -0
- package/skills/train-sentence-transformers/scripts/mine_hard_negatives.py +199 -0
- package/skills/train-sentence-transformers/scripts/train_cross_encoder_distillation_example.py +254 -0
- package/skills/train-sentence-transformers/scripts/train_cross_encoder_example.py +253 -0
- package/skills/train-sentence-transformers/scripts/train_cross_encoder_listwise_example.py +282 -0
- package/skills/train-sentence-transformers/scripts/train_multi_vector_encoder_example.py +240 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_distillation_example.py +303 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_example.py +227 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_make_multilingual_example.py +308 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_matryoshka_example.py +212 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_multi_dataset_example.py +258 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_static_embedding_example.py +273 -0
- package/skills/train-sentence-transformers/scripts/train_sentence_transformer_with_lora_example.py +275 -0
- package/skills/train-sentence-transformers/scripts/train_sparse_encoder_distillation_example.py +262 -0
- package/skills/train-sentence-transformers/scripts/train_sparse_encoder_example.py +237 -0
- package/skills/transformers-js/SKILL.md +692 -0
- package/skills/transformers-js/references/CACHE.md +339 -0
- package/skills/transformers-js/references/CONFIGURATION.md +438 -0
- package/skills/transformers-js/references/EXAMPLES.md +620 -0
- package/skills/transformers-js/references/MODEL_ARCHITECTURES.md +167 -0
- package/skills/transformers-js/references/MODEL_REGISTRY.md +197 -0
- package/skills/transformers-js/references/PIPELINE_OPTIONS.md +557 -0
- package/skills/transformers-js/references/TEXT_GENERATION.md +315 -0
- package/skills/tribunal-instincts-memory/SKILL.md +31 -0
- package/skills/trl-training/SKILL.md +318 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# ZeroGPU
|
|
2
|
+
|
|
3
|
+
Read this whenever the Space targets ZeroGPU (`zero-a10g` flavor). The SKILL.md's 3-rule summary is a starting point; this file covers the model in enough detail to debug and design.
|
|
4
|
+
|
|
5
|
+
For numerical limits (per-tier daily quota minutes, runs-per-day caps, current backing GPU, supported Python / torch versions): https://huggingface.co/docs/hub/spaces-zerogpu. Those values change over time and are deliberately kept out of this skill.
|
|
6
|
+
|
|
7
|
+
## The mental model
|
|
8
|
+
|
|
9
|
+
A ZeroGPU Space runs as **two processes**:
|
|
10
|
+
|
|
11
|
+
- **Main web process** — long-lived. Imports `app.py`, launches Gradio. Holds no VRAM and, after the startup "pack" step, no model weights in RAM either.
|
|
12
|
+
- **GPU worker** — short-lived. Forked per `@spaces.GPU` request (or reused if warm). Eventually killed by the ZeroGPU scheduler when another Space needs the slot. Your code never kills its own worker.
|
|
13
|
+
|
|
14
|
+
`import spaces` monkey-patches `torch.cuda.*` in the main process so that `.to("cuda")` and `torch.cuda.is_available()` work at module scope **without** a real GPU attached. Module-level `model.to("cuda")` is intercepted: the tensor data physically stays in main-process RAM at this point, with a CUDA-presenting "fake" tensor registered alongside. At a startup "pack" step, the backend writes those original CPU tensors to disk via `O_DIRECT` and frees the RAM. After pack, main holds no weights anywhere.
|
|
15
|
+
|
|
16
|
+
When a `@spaces.GPU` call lands, the scheduler routes it to a worker:
|
|
17
|
+
|
|
18
|
+
- **Cold worker** — forked from the main process; torch is unpatched; real CUDA is initialized; weights are streamed disk → pinned host → VRAM via a double-buffered pipeline. This is the cold-start cost.
|
|
19
|
+
- **Warm worker** — alive worker bound to the same slot; init is skipped; weights stay on VRAM from the previous call.
|
|
20
|
+
|
|
21
|
+
A warm worker eventually dies when another Space needs the slot. Occasional cold starts on a low-traffic Space are normal.
|
|
22
|
+
|
|
23
|
+
## The three rules
|
|
24
|
+
|
|
25
|
+
### 1. `import spaces` before any CUDA-touching import
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
import spaces # FIRST
|
|
29
|
+
import torch # then this
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If something initializes CUDA before `import spaces`, the patch can't apply and you get `RuntimeError: CUDA has been initialized before importing the spaces package`. For libraries that eagerly init CUDA on import (e.g. `numba.cuda`, NeMo via numba), set the disable env *before* the import:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import os
|
|
36
|
+
os.environ.setdefault("NUMBA_DISABLE_CUDA", "1")
|
|
37
|
+
import spaces
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Load models at module scope, `.to("cuda")` eagerly
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
pipe = DiffusionPipeline.from_pretrained("...", torch_dtype=torch.bfloat16).to("cuda")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Do **not** lazy-load inside `@spaces.GPU`. The hijack is designed for module-level placement; deferring it puts tens of seconds of checkpoint I/O + dtype cast + GPU move inside every cold request.
|
|
47
|
+
|
|
48
|
+
Use the **string `"cuda"`** — never an integer device id. ZeroGPU re-allocates device ids per request, so `.to(0)`, `device_map={"": 0}`, `torch.cuda.set_device(0)` silently break.
|
|
49
|
+
|
|
50
|
+
For plain `from_pretrained` loads, use `.to("cuda")`, **not** `device_map="cuda"` (which routes through `accelerate.set_module_tensor_to_device` and calls `torch._C._cuda_init()` at load time, bypassing the hijack). The exception is loaders that are ZeroGPU-aware — notably the `bitsandbytes` quantization path; `from_pretrained(..., quantization_config=BitsAndBytesConfig(...))` works with `device_map="cuda"`.
|
|
51
|
+
|
|
52
|
+
**Preloading multiple variants** (e.g. base + refiner, image + video model) is fine as long as their combined VRAM fits. Load all of them sequentially at module scope into a dict, then key per request. Don't unload/reload between requests — that puts the load cost back on the user.
|
|
53
|
+
|
|
54
|
+
### 3. Decorate the function Gradio binds
|
|
55
|
+
|
|
56
|
+
ZeroGPU's startup scan walks Gradio's registered event handlers for `@spaces.GPU`-marked functions. If you decorate `inner_helper` but `click(fn=outer)` is what's wired up, you get `RuntimeError: No @spaces.GPU function detected during startup`. Always decorate the function passed to the event handler.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
@spaces.GPU(duration=60)
|
|
60
|
+
def generate(prompt):
|
|
61
|
+
return pipe(prompt).images[0]
|
|
62
|
+
|
|
63
|
+
btn.click(fn=generate, inputs=prompt_box, outputs=image_out)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Sizing duration
|
|
67
|
+
|
|
68
|
+
`@spaces.GPU(duration=N)` means "reserve N seconds of GPU time." Two failure modes:
|
|
69
|
+
|
|
70
|
+
- **`ZeroGPU illegal duration`** — `N` exceeds the visitor's tier cap. Lowering `duration` is the only fix.
|
|
71
|
+
- **`ZeroGPU quota exceeded`** — the visitor's remaining quota is less than `requested`. Compared as `requested vs remaining`, not `actual vs remaining` — so a 10-second task left at the default 60 s blocks the user as soon as their remaining drops below 60 s.
|
|
72
|
+
|
|
73
|
+
Smaller `duration` also ranks **higher** in the queue. Both reasons push toward declaring the realistic worst case, not a comfortable margin.
|
|
74
|
+
|
|
75
|
+
**Pick the value — don't guess.** A too-high duration deploys cleanly then errors on the first call; too-low silently truncates. Methodology:
|
|
76
|
+
|
|
77
|
+
1. Ship with a placeholder (e.g. 180 s).
|
|
78
|
+
2. Instrument with `time.perf_counter()` and return the seconds in the response.
|
|
79
|
+
3. Run 2–3 representative calls via `gradio_client`.
|
|
80
|
+
4. Set `duration = round(measured_max × 1.4)`.
|
|
81
|
+
|
|
82
|
+
For input-dependent runtime, pass a **callable**:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
def _estimate(prompt, steps, *args, **kwargs):
|
|
86
|
+
# Swallow extras with *args, **kwargs — Gradio passes progress= positionally
|
|
87
|
+
# and a strict signature will raise "takes 5 positional arguments but 6 were given"
|
|
88
|
+
return min(240, 60 + int(steps * 3.5))
|
|
89
|
+
|
|
90
|
+
@spaces.GPU(duration=_estimate)
|
|
91
|
+
def generate(prompt, steps, ..., progress=gr.Progress(track_tqdm=True)):
|
|
92
|
+
...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Sizing memory: `large` vs `xlarge`
|
|
96
|
+
|
|
97
|
+
`size="large"` (default) is half the backing card (48 GB on Blackwell). `size="xlarge"` is the full card (96 GB) and costs **2× quota** per second — plus higher queue waits. Use `large` unless the workload genuinely OOMs.
|
|
98
|
+
|
|
99
|
+
Rough VRAM sizing:
|
|
100
|
+
|
|
101
|
+
| Mode | Memory rule | 7B | 27B | 70B |
|
|
102
|
+
|------|------------|------|------|------|
|
|
103
|
+
| bf16 | `params × 2` GB | 14 GB ✓ large | 54 GB → xlarge | 140 GB → quant + xlarge |
|
|
104
|
+
| int8 | `params × 1` GB | 7 GB ✓ large | 27 GB ✓ large | 70 GB → xlarge |
|
|
105
|
+
| 4-bit (NF4 / int4) | `params × ~0.55` GB | 4 GB ✓ large | 15 GB ✓ large | 40 GB ✓ large |
|
|
106
|
+
|
|
107
|
+
Numbers are for weights only; activations and KV cache add on top (significant for long context).
|
|
108
|
+
|
|
109
|
+
## Quantization
|
|
110
|
+
|
|
111
|
+
ZeroGPU supports two quantization stacks: **`bitsandbytes`** (drop-in for transformers, well-trodden) and **`torchao`** (torch-native, newer, smaller install). Pick by what your model's `from_pretrained` actually wires up; if both work, default to `bitsandbytes` for transformers LLMs and `torchao` for diffusers.
|
|
112
|
+
|
|
113
|
+
### bitsandbytes (NF4 / int8)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import spaces, torch
|
|
117
|
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
|
118
|
+
|
|
119
|
+
bnb = BitsAndBytesConfig(
|
|
120
|
+
load_in_4bit=True,
|
|
121
|
+
bnb_4bit_quant_type="nf4",
|
|
122
|
+
bnb_4bit_use_double_quant=True,
|
|
123
|
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
|
124
|
+
)
|
|
125
|
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
|
126
|
+
model = AutoModelForCausalLM.from_pretrained(
|
|
127
|
+
MODEL_ID,
|
|
128
|
+
quantization_config=bnb,
|
|
129
|
+
device_map="cuda", # OK here — bnb's loader is ZeroGPU-aware
|
|
130
|
+
dtype=torch.bfloat16,
|
|
131
|
+
).eval()
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This is the one case where `device_map="cuda"` is **safe** on ZeroGPU at module scope (bitsandbytes' loader path intercepts cleanly). For non-bnb loads, stick to `.to("cuda")`.
|
|
135
|
+
|
|
136
|
+
`load_in_8bit=True` swaps the 4-bit block for int8 — same hijack-safe loader. Bigger but higher quality, no `compute_dtype` knob.
|
|
137
|
+
|
|
138
|
+
### torchao
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import spaces, torch
|
|
142
|
+
from diffusers import DiffusionPipeline
|
|
143
|
+
from torchao.quantization import quantize_, Int8WeightOnlyConfig
|
|
144
|
+
|
|
145
|
+
pipe = DiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16).to("cuda")
|
|
146
|
+
quantize_(pipe.transformer, Int8WeightOnlyConfig()) # mutates in place
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`torchao` is more flexible (fine-grained per-module quantization, `Int4WeightOnlyConfig`, `Float8WeightOnlyConfig`, etc.) and works with diffusers' `from_pretrained(..., quantization_config=TorchAoConfig(...))` integration too. No CUDA build dependency — installs as a wheel.
|
|
150
|
+
|
|
151
|
+
### Attention backends
|
|
152
|
+
|
|
153
|
+
**Default to `attn_implementation="sdpa"`** — torch-native, works everywhere on sm_120, and is the right choice for the overwhelming majority of Spaces. Reach for a Flash-Attention backend only when the **upstream repo already references FA** (its config/model code defaults to or recommends `flash_attn`) — match what it expects rather than forcing SDPA. If FA then breaks on Blackwell, fall back to SDPA.
|
|
154
|
+
|
|
155
|
+
**Flash Attention 2** — when you do need it, use the prebuilt wheel at `multimodalart/zerogpu-blackwell-wheels` ([`requirements.md`](requirements.md)), cp310–cp313. Drop the wheel URL in `requirements.txt`; no monkey-patch, no runtime build. The wheel's real `flash_attn_2_cuda` also satisfies xformers' import-time probes.
|
|
156
|
+
|
|
157
|
+
**xformers** — same wheels dataset; auto-dispatch picks FA2 on sm_120 with no monkey-patch.
|
|
158
|
+
|
|
159
|
+
**FA2 is the ceiling on ZeroGPU Blackwell — FA3 and FA4 cannot run on sm_120.** The RTX PRO 6000 (sm_120) lacks the TMEM / `tcgen05` tensor-memory subsystem the FA3/FA4 kernels are built on; those kernels only exist for Hopper (sm_90a) and datacenter Blackwell (sm_100a). This is a **hardware** limit, not a packaging gap — no wheel or branch fixes it:
|
|
160
|
+
|
|
161
|
+
- `kernels-community/flash-attn3` (any revision, including `fake-ops-return-probs`), `vllm-flash-attn3`, `sgl-flash-attn3` all either fail to load (no matching build) or hard-fault at call time with `CUDA error: no kernel image is available for execution on the device` — which **kills the ZeroGPU worker** (surfaces as `GPU task aborted`); it does not fall back.
|
|
162
|
+
- Verified empirically on the live runtime (`NVIDIA RTX PRO 6000 Blackwell … sm_120`, torch 2.11 / cu130) and confirmed upstream — every framework (vLLM, SGLang) falls back to FA2 on sm_120.
|
|
163
|
+
|
|
164
|
+
So on ZeroGPU the ladder is **SDPA (default) → FA2 (only if the repo uses FA)**. Don't wire in FA3/FA4 — a stray `config.json` `kernels` entry loading `flash-attn3` will abort the worker on first GPU call.
|
|
165
|
+
|
|
166
|
+
## Concurrency
|
|
167
|
+
|
|
168
|
+
Handlers run **concurrently by default**. Three rules:
|
|
169
|
+
|
|
170
|
+
1. **No mutable global state.** Handlers writing to a module-level dict / list race each other.
|
|
171
|
+
2. **No fixed output paths.** Two concurrent calls writing to `output.png` clobber each other (and leak data across users). Use `tempfile.NamedTemporaryFile(suffix=...)`.
|
|
172
|
+
3. **Read-only globals are safe** — models, tokenizers, configs loaded once and only read inside handlers.
|
|
173
|
+
|
|
174
|
+
## Process isolation and pickle
|
|
175
|
+
|
|
176
|
+
`@spaces.GPU` runs in a separate fork. Arguments and return values cross via pickle:
|
|
177
|
+
|
|
178
|
+
- **Only picklable objects** in/out. File handles, locks, lambdas, closures over unpicklable state → `PicklingError`.
|
|
179
|
+
- **Never return CUDA tensors.** Unpickling in the main process triggers `torch.cuda._lazy_init()`, which ZeroGPU blocks → the call hangs. Convert to CPU first: `return tensor.cpu()` or `.cpu().numpy()`.
|
|
180
|
+
- CPU tensors, numpy arrays, PIL Images, plain Python objects work fine.
|
|
181
|
+
- `gr.SelectData` is a special case — its `__getattr__` recurses under pickle. Extract the fields you need (`evt.index[0]`, etc.) in a thin un-decorated wrapper, pass plain values to the `@spaces.GPU` function.
|
|
182
|
+
|
|
183
|
+
### `gr.State` across the fork
|
|
184
|
+
|
|
185
|
+
`gr.State` is pickled on every yield. The handler receives a **copy**:
|
|
186
|
+
|
|
187
|
+
- In-place mutations inside the fork are invisible to other handlers until you explicitly `yield` the mutated value back.
|
|
188
|
+
- Yielding `gr.update()` for a state slot **skips** the update — other handlers continue to see pre-yield value.
|
|
189
|
+
- For large state, minimize how often you yield it — ideally once at the end.
|
|
190
|
+
- CUDA tensors inside state must be CPU-d before yielding (same `_lazy_init` issue).
|
|
191
|
+
|
|
192
|
+
## Generators and streaming
|
|
193
|
+
|
|
194
|
+
`@spaces.GPU` supports generator functions — first-class for progressive UI updates:
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
@spaces.GPU(duration=120)
|
|
198
|
+
def generate(prompt):
|
|
199
|
+
yield gr.update(value=None, label="Starting…")
|
|
200
|
+
for step in range(num_steps):
|
|
201
|
+
latent = step_fn(...)
|
|
202
|
+
yield gr.update(value=preview(latent), label=f"Step {step+1}/{num_steps}")
|
|
203
|
+
yield gr.update(value=final_image, label="Done")
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`gr.Progress(track_tqdm=True)` and `yield` compete with each other — pick one.
|
|
207
|
+
|
|
208
|
+
For streaming previews **inside** a diffusers `callback_on_step_end`, use a thread + queue inside the decorator (forks share threads):
|
|
209
|
+
|
|
210
|
+
```python
|
|
211
|
+
@spaces.GPU(duration=180)
|
|
212
|
+
def generate(prompt, num_steps):
|
|
213
|
+
q = queue.Queue()
|
|
214
|
+
DONE = object()
|
|
215
|
+
def cb(pipe, step, t, kw):
|
|
216
|
+
q.put((step, taef1_preview(kw["latents"])))
|
|
217
|
+
return kw
|
|
218
|
+
def run():
|
|
219
|
+
out = pipeline(prompt=prompt, num_inference_steps=num_steps,
|
|
220
|
+
callback_on_step_end=cb,
|
|
221
|
+
callback_on_step_end_tensor_inputs=["latents"])
|
|
222
|
+
q.put((DONE, out))
|
|
223
|
+
threading.Thread(target=run, daemon=True).start()
|
|
224
|
+
while True:
|
|
225
|
+
idx, payload = q.get()
|
|
226
|
+
if idx is DONE: break
|
|
227
|
+
yield gr.update(value=payload, label=f"Step {idx+1}/{num_steps}")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Do not** use `ProcessPoolExecutor` / `multiprocessing.Pool` inside `@spaces.GPU` — the daemonic fork can't spawn children (`AssertionError: daemonic processes are not allowed to have children`). Threads only.
|
|
231
|
+
|
|
232
|
+
## Compilation (AoTI)
|
|
233
|
+
|
|
234
|
+
`torch.compile` (JIT) is **not supported** on ZeroGPU — the forked GPU worker can't host the compile daemon. The supported path is PyTorch **ahead-of-time inductor (AoTI)**, wrapped by the `spaces` package (torch 2.8+, `spaces` ≥ 0.50). Its real value: compile a graph **once, offline**, publish it to the Hub, and have the serving Space load it — so serving cold starts pay no compile cost.
|
|
235
|
+
|
|
236
|
+
### The `spaces` AoTI API
|
|
237
|
+
|
|
238
|
+
- `spaces.aoti_capture(module)` — context manager. Run one real forward pass inside it; it patches `module.forward` to record that call's `args`/`kwargs` and abort the run. Gives you real example inputs for export.
|
|
239
|
+
- `spaces.aoti_compile(exported, inductor_configs=None)` → an in-memory `ZeroGPUCompiledModel`.
|
|
240
|
+
- `spaces.aoti_compile_and_save(package_dir, exported, inductor_configs=None)` — compile and write `{package_dir}/root/package.pt2`.
|
|
241
|
+
- `spaces.aoti_apply(compiled, module)` — swap `module.forward` for an in-memory compiled model, same process.
|
|
242
|
+
- `spaces.aoti_blocks_load(module, repo_id, variant=None)` — the high-level loader. For a module exposing `_repeated_blocks` (most diffusers transformers), it downloads `{BlockClass}[.{variant}]/package.pt2` from `repo_id` and patches every matching block. Weights stay **runtime inputs**, so one compiled block-graph serves any checkpoint with the same block architecture (e.g. a base and its distilled/turbo variant share one graph).
|
|
243
|
+
|
|
244
|
+
### Recommended workflow: precompile the repeated block, load at runtime
|
|
245
|
+
|
|
246
|
+
Split into a **compile Space** (run by hand, occasionally) and the **serving Space**, connected by a Hub **model** repo (`aoti_blocks_load` downloads with the default `repo_type="model"`).
|
|
247
|
+
|
|
248
|
+
**Compile Space** — capture one repeated block's inputs, export, compile, save, upload:
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
import os, spaces, torch, tempfile, shutil
|
|
252
|
+
from pathlib import Path
|
|
253
|
+
from huggingface_hub import HfApi
|
|
254
|
+
|
|
255
|
+
pipe = DiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16).to("cuda")
|
|
256
|
+
block = pipe.transformer.transformer_blocks[0] # one representative repeated block
|
|
257
|
+
BLOCK = type(block).__name__
|
|
258
|
+
|
|
259
|
+
@spaces.GPU(duration=1500)
|
|
260
|
+
def compile_and_upload():
|
|
261
|
+
with spaces.aoti_capture(block) as call: # capture the block's real inputs…
|
|
262
|
+
pipe("a prompt", num_inference_steps=1) # …from the first block call of a 1-step run
|
|
263
|
+
exported = torch.export.export(
|
|
264
|
+
block, call.args, call.kwargs,
|
|
265
|
+
dynamic_shapes=None, # start static; see note below
|
|
266
|
+
strict=False,
|
|
267
|
+
)
|
|
268
|
+
tmp = Path(tempfile.mkdtemp())
|
|
269
|
+
spaces.aoti_compile_and_save(tmp, exported) # -> tmp/root/package.pt2
|
|
270
|
+
out = Path(tempfile.mkdtemp()); (out / BLOCK).mkdir()
|
|
271
|
+
shutil.copy(tmp / "root" / "package.pt2", out / BLOCK / "package.pt2")
|
|
272
|
+
HfApi(token=os.environ["HF_TOKEN"]).upload_folder(
|
|
273
|
+
folder_path=str(out), repo_id=REPO, repo_type="model")
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The repo ends up as `{BlockClass}[.{variant}]/package.pt2`, optionally with a `config[.variant].json` listing custom `kernels` to fetch at load.
|
|
277
|
+
|
|
278
|
+
**Serving Space** — one line at module scope, with an eager fallback:
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
pipe = DiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16).to("cuda")
|
|
282
|
+
try:
|
|
283
|
+
spaces.aoti_blocks_load(pipe.transformer, REPO) # variant="fp8da" if you saved a variant
|
|
284
|
+
except Exception as e:
|
|
285
|
+
print(f"AoTI load failed ({e!r}); running eager")
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Only the repeated block is compiled, so the artifact is small and the same graph patches all N layers; compilation (minutes) happens offline, never on a serving cold start.
|
|
289
|
+
|
|
290
|
+
### Footguns
|
|
291
|
+
|
|
292
|
+
- **Construct the block identically in both Spaces.** The compiled graph's constant FQNs must line up with the serving module. If the block chooses kernels/norms via env var or import probe (e.g. a triton fused RMSNorm vs the pure-torch path), pin the *same* choice in compile and serving.
|
|
293
|
+
- **Dynamic shapes.** `dynamic_shapes=None` bakes in the one resolution you captured. To serve variable sequence length / image size, pass `torch.export.Dim(...)` for those axes (e.g. `{"hidden_states": {1: torch.export.Dim("seq")}}`) — this is per-model tuning.
|
|
294
|
+
- **Data-dependent inputs don't export.** A block taking per-sample python int lists (some double-stream blocks) can make `torch.export` refuse to make them dynamic — those stay eager. Single-stream blocks taking only packed tensors export cleanly.
|
|
295
|
+
- **Custom kernels.** Ship a `config[.variant].json` with a `kernels` list (`repo_id` + `revision`); `aoti_blocks_load` calls `kernels.get_kernel(...)` before loading so the op is registered. (FA3 still won't run on sm_120 — see Attention backends.)
|
|
296
|
+
- **Simpler in-process variant.** For a one-off, skip the Hub round-trip: `spaces.aoti_apply(spaces.aoti_compile(exported), module)` compiles and applies in the same process — but you re-compile on every cold start.
|
|
297
|
+
|
|
298
|
+
### Reference Spaces
|
|
299
|
+
|
|
300
|
+
- `multimodalart/Boogu-Image-0.1-Edit-aoti-compile` (compile + upload) and `multimodalart/Boogu-Image` (serving via block loading) — the blocks pattern end to end.
|
|
301
|
+
- `zerogpu-aoti/Qwen-Image`, `zerogpu-aoti/Wan2` — artifact repos showing the `{BlockClass}.{variant}/package.pt2` + `config.{variant}.json` layout.
|
|
302
|
+
- Deeper background on inductor configs and dynamic shapes: https://huggingface.co/blog/zerogpu-aoti
|
|
303
|
+
|
|
304
|
+
## Local development
|
|
305
|
+
|
|
306
|
+
**Do NOT** wrap `import spaces` in `try/except` with a no-op fallback. Off-ZeroGPU, the `spaces` package is *already* a true no-op — the heavyweight behavior is gated on `SPACES_ZERO_GPU=1`, set only on ZeroGPU. `@spaces.GPU` returns the undecorated function unchanged elsewhere. The Gradio base image installs `spaces` on every hardware tier, so a duplicate onto T4 / A10G / CPU works without code changes too.
|
|
307
|
+
|
|
308
|
+
That said: **iterate ON the Space, not locally.** The Space environment (Python, torch, CUDA, drivers, env vars) differs from yours; passing local tests doesn't prove the Space works. Push early — even with the app not fully polished — and use the rung ladder ([`debugging.md`](debugging.md)) against the live URL.
|
|
309
|
+
|
|
310
|
+
## Allocator config for memory pressure
|
|
311
|
+
|
|
312
|
+
If your workload hits transient allocation spikes (high-res pixel-space ops, large attention activations, SR models, video DiTs) and you see:
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
RuntimeError: NVML_SUCCESS == r INTERNAL ASSERT FAILED at .../CUDACachingAllocator.cpp
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
set expandable segments at the **very top** of `app.py`, before any torch import:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
import os
|
|
322
|
+
os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
|
|
323
|
+
import spaces
|
|
324
|
+
import torch
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Often single-line fix for what looks like an OOM. See [`known-errors.md`](known-errors.md).
|
|
328
|
+
|
|
329
|
+
## Example caching
|
|
330
|
+
|
|
331
|
+
`gr.Examples` defaults on ZeroGPU:
|
|
332
|
+
|
|
333
|
+
- `cache_examples=True`
|
|
334
|
+
- `cache_mode="lazy"` (eager would pre-run examples at startup, but no GPU is attached at startup)
|
|
335
|
+
|
|
336
|
+
Don't override to `cache_mode="eager"` on ZeroGPU — it will fail or burn the creator's daily quota. The cache is keyed by example **file path**, not content hash: regenerating an asset in place serves the stale cached output. Bump a `cache_version` constant if you replace example files.
|
|
337
|
+
|
|
338
|
+
## Real-time sessions
|
|
339
|
+
|
|
340
|
+
For real-time apps (webcam, audio streaming), the per-call fork model is too costly. ZeroGPU supports reusable "real-time sessions" — one GPU allocation amortized across many small requests. Reference Spaces:
|
|
341
|
+
|
|
342
|
+
- https://huggingface.co/spaces/diffusers/unofficial-SDXL-Turbo-i2i-t2i
|
|
343
|
+
- https://huggingface.co/spaces/huggingface-projects/rf-detr-realtime-webcam
|
|
344
|
+
|
|
345
|
+
## When things go wrong
|
|
346
|
+
|
|
347
|
+
For specific error strings (CUDA init order, illegal duration, allocator asserts, PicklingError, returning CUDA tensors, …): [`known-errors.md`](known-errors.md). It covers the ZeroGPU-specific patterns alongside everything else and is the single error lookup for the skill.
|
|
348
|
+
|
|
349
|
+
When the log endpoint can't explain a failure (device-side asserts, OOM under specific shapes, race conditions in pickle), dev mode + SSH is the last-resort tool — see [`debugging.md`](debugging.md).
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: huggingface-tool-builder
|
|
3
|
+
description: Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful when chaining or combining API calls or the task will be repeated/automated. This Skill creates a reusable script to fetch, enrich or process data.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hugging Face API Tool Builder
|
|
7
|
+
|
|
8
|
+
Your purpose is now is to create reusable command line scripts and utilities for using the Hugging Face API, allowing chaining, piping and intermediate processing where helpful. You can access the API directly, as well as use the `hf` command line tool. Model and Dataset cards can be accessed from repositories directly.
|
|
9
|
+
|
|
10
|
+
## Script Rules
|
|
11
|
+
|
|
12
|
+
Make sure to follow these rules:
|
|
13
|
+
- Scripts must take a `--help` command line argument to describe their inputs and outputs
|
|
14
|
+
- Non-destructive scripts should be tested before handing over to the User
|
|
15
|
+
- Shell scripts are preferred, but use Python or TSX if complexity or user need requires it.
|
|
16
|
+
- IMPORTANT: Use the `HF_TOKEN` environment variable as an Authorization header. For example: `curl -H "Authorization: Bearer ${HF_TOKEN}" https://huggingface.co/api/`. This provides higher rate limits and appropriate authorization for data access.
|
|
17
|
+
- Investigate the shape of the API results before commiting to a final design; make use of piping and chaining where composability would be an advantage - prefer simple solutions where possible.
|
|
18
|
+
- Share usage examples once complete.
|
|
19
|
+
|
|
20
|
+
Be sure to confirm User preferences where there are questions or clarifications needed.
|
|
21
|
+
|
|
22
|
+
## Sample Scripts
|
|
23
|
+
|
|
24
|
+
Paths below are relative to this skill directory.
|
|
25
|
+
|
|
26
|
+
Reference examples:
|
|
27
|
+
- `references/hf_model_papers_auth.sh` — uses `HF_TOKEN` automatically and chains trending → model metadata → model card parsing with fallbacks; it demonstrates multi-step API usage plus auth hygiene for gated/private content.
|
|
28
|
+
- `references/find_models_by_paper.sh` — optional `HF_TOKEN` usage via `--token`, consistent authenticated search, and a retry path when arXiv-prefixed searches are too narrow; it shows resilient query strategy and clear user-facing help.
|
|
29
|
+
- `references/hf_model_card_frontmatter.sh` — uses the `hf` CLI to download model cards, extracts YAML frontmatter, and emits NDJSON summaries (license, pipeline tag, tags, gated prompt flag) for easy filtering.
|
|
30
|
+
|
|
31
|
+
Baseline examples (ultra-simple, minimal logic, raw JSON output with `HF_TOKEN` header):
|
|
32
|
+
- `references/baseline_hf_api.sh` — bash
|
|
33
|
+
- `references/baseline_hf_api.py` — python
|
|
34
|
+
- `references/baseline_hf_api.tsx` — typescript executable
|
|
35
|
+
|
|
36
|
+
Composable utility (stdin → NDJSON):
|
|
37
|
+
- `references/hf_enrich_models.sh` — reads model IDs from stdin, fetches metadata per ID, emits one JSON object per line for streaming pipelines.
|
|
38
|
+
|
|
39
|
+
Composability through piping (shell-friendly JSON output):
|
|
40
|
+
- `references/baseline_hf_api.sh 25 | jq -r '.[].id' | references/hf_enrich_models.sh | jq -s 'sort_by(.downloads) | reverse | .[:10]'`
|
|
41
|
+
- `references/baseline_hf_api.sh 50 | jq '[.[] | {id, downloads}] | sort_by(.downloads) | reverse | .[:10]'`
|
|
42
|
+
- `printf '%s\n' openai/gpt-oss-120b meta-llama/Meta-Llama-3.1-8B | references/hf_model_card_frontmatter.sh | jq -s 'map({id, license, has_extra_gated_prompt})'`
|
|
43
|
+
|
|
44
|
+
## High Level Endpoints
|
|
45
|
+
|
|
46
|
+
The following are the main API endpoints available at `https://huggingface.co`
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
/api/datasets
|
|
50
|
+
/api/models
|
|
51
|
+
/api/spaces
|
|
52
|
+
/api/collections
|
|
53
|
+
/api/daily_papers
|
|
54
|
+
/api/notifications
|
|
55
|
+
/api/settings
|
|
56
|
+
/api/whoami-v2
|
|
57
|
+
/api/trending
|
|
58
|
+
/oauth/userinfo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Accessing the API
|
|
62
|
+
|
|
63
|
+
The API is documented with the OpenAPI standard at `https://huggingface.co/.well-known/openapi.json`.
|
|
64
|
+
|
|
65
|
+
**IMPORTANT:** DO NOT ATTEMPT to read `https://huggingface.co/.well-known/openapi.json` directly as it is too large to process.
|
|
66
|
+
|
|
67
|
+
**IMPORTANT** Use `jq` to query and extract relevant parts. For example,
|
|
68
|
+
|
|
69
|
+
Command to Get All 160 Endpoints
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths | keys | sort'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Model Search Endpoint Details
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths["/api/models"]'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can also query endpoints to see the shape of the data. When doing so constrain results to low numbers to make them easy to process, yet representative.
|
|
82
|
+
|
|
83
|
+
## Using the HF command line tool
|
|
84
|
+
|
|
85
|
+
The `hf` command line tool gives you further access to Hugging Face repository content and infrastructure.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
❯ hf --help
|
|
89
|
+
Usage: hf [OPTIONS] COMMAND [ARGS]...
|
|
90
|
+
|
|
91
|
+
Hugging Face Hub CLI
|
|
92
|
+
|
|
93
|
+
Options:
|
|
94
|
+
--help Show this message and exit.
|
|
95
|
+
|
|
96
|
+
Commands:
|
|
97
|
+
auth Manage authentication (login, logout, etc.).
|
|
98
|
+
buckets Commands to interact with buckets.
|
|
99
|
+
cache Manage local cache directory.
|
|
100
|
+
collections Interact with collections on the Hub.
|
|
101
|
+
datasets Interact with datasets on the Hub.
|
|
102
|
+
discussions Manage discussions and pull requests on the Hub.
|
|
103
|
+
download Download files from the Hub.
|
|
104
|
+
endpoints Manage Hugging Face Inference Endpoints.
|
|
105
|
+
env Print information about the environment.
|
|
106
|
+
extensions Manage hf CLI extensions.
|
|
107
|
+
jobs Run and manage Jobs on the Hub.
|
|
108
|
+
models Interact with models on the Hub.
|
|
109
|
+
papers Interact with papers on the Hub.
|
|
110
|
+
repos Manage repos on the Hub.
|
|
111
|
+
skills Manage skills for AI assistants.
|
|
112
|
+
spaces Interact with spaces on the Hub.
|
|
113
|
+
sync Sync files between local directory and a bucket.
|
|
114
|
+
upload Upload a file or a folder to the Hub.
|
|
115
|
+
upload-large-folder Upload a large folder to the Hub.
|
|
116
|
+
version Print information about the hf version.
|
|
117
|
+
webhooks Manage webhooks on the Hub.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The `hf` CLI command has replaced the now deprecated `huggingface-cli` command.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Ultra-simple Hugging Face API example (Python).
|
|
4
|
+
|
|
5
|
+
Fetches a small list of models from the HF API and prints raw JSON.
|
|
6
|
+
Uses HF_TOKEN for auth if the environment variable is set.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
import urllib.request
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def show_help() -> None:
|
|
17
|
+
print(
|
|
18
|
+
"""Ultra-simple Hugging Face API example (Python)
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
baseline_hf_api.py [limit]
|
|
22
|
+
baseline_hf_api.py --help
|
|
23
|
+
|
|
24
|
+
Description:
|
|
25
|
+
Fetches a small list of models from the HF API and prints raw JSON.
|
|
26
|
+
Uses HF_TOKEN for auth if the environment variable is set.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
baseline_hf_api.py
|
|
30
|
+
baseline_hf_api.py 5
|
|
31
|
+
HF_TOKEN=your_token baseline_hf_api.py 10
|
|
32
|
+
"""
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def main() -> int:
|
|
37
|
+
if len(sys.argv) > 1 and sys.argv[1] == "--help":
|
|
38
|
+
show_help()
|
|
39
|
+
return 0
|
|
40
|
+
|
|
41
|
+
limit = sys.argv[1] if len(sys.argv) > 1 else "3"
|
|
42
|
+
if not limit.isdigit():
|
|
43
|
+
print("Error: limit must be a number", file=sys.stderr)
|
|
44
|
+
return 1
|
|
45
|
+
|
|
46
|
+
token = os.getenv("HF_TOKEN")
|
|
47
|
+
headers = {"Authorization": f"Bearer {token}"} if token else {}
|
|
48
|
+
url = f"https://huggingface.co/api/models?limit={limit}"
|
|
49
|
+
|
|
50
|
+
req = urllib.request.Request(url, headers=headers)
|
|
51
|
+
with urllib.request.urlopen(req) as resp:
|
|
52
|
+
sys.stdout.write(resp.read().decode("utf-8"))
|
|
53
|
+
return 0
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
show_help() {
|
|
6
|
+
cat << EOF
|
|
7
|
+
Ultra-simple Hugging Face API example (Shell)
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
$0 [limit]
|
|
11
|
+
$0 --help
|
|
12
|
+
|
|
13
|
+
Description:
|
|
14
|
+
Fetches a small list of models from the HF API and prints raw JSON.
|
|
15
|
+
Uses HF_TOKEN for auth if the environment variable is set.
|
|
16
|
+
|
|
17
|
+
Examples:
|
|
18
|
+
$0
|
|
19
|
+
$0 5
|
|
20
|
+
HF_TOKEN=your_token $0 10
|
|
21
|
+
EOF
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if [[ "${1:-}" == "--help" ]]; then
|
|
25
|
+
show_help
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
LIMIT="${1:-3}"
|
|
30
|
+
if ! [[ "$LIMIT" =~ ^[0-9]+$ ]]; then
|
|
31
|
+
echo "Error: limit must be a number" >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
headers=()
|
|
36
|
+
if [[ -n "${HF_TOKEN:-}" ]]; then
|
|
37
|
+
headers=(-H "Authorization: Bearer ${HF_TOKEN}")
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
curl -s "${headers[@]}" "https://huggingface.co/api/models?limit=${LIMIT}"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ultra-simple Hugging Face API example (TSX).
|
|
5
|
+
*
|
|
6
|
+
* Fetches a small list of models from the HF API and prints raw JSON.
|
|
7
|
+
* Uses HF_TOKEN for auth if the environment variable is set.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const showHelp = () => {
|
|
11
|
+
console.log(`Ultra-simple Hugging Face API example (TSX)
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
baseline_hf_api.tsx [limit]
|
|
15
|
+
baseline_hf_api.tsx --help
|
|
16
|
+
|
|
17
|
+
Description:
|
|
18
|
+
Fetches a small list of models from the HF API and prints raw JSON.
|
|
19
|
+
Uses HF_TOKEN for auth if the environment variable is set.
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
baseline_hf_api.tsx
|
|
23
|
+
baseline_hf_api.tsx 5
|
|
24
|
+
HF_TOKEN=your_token baseline_hf_api.tsx 10
|
|
25
|
+
`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const arg = process.argv[2];
|
|
29
|
+
if (arg === "--help") {
|
|
30
|
+
showHelp();
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const limit = arg ?? "3";
|
|
35
|
+
if (!/^\d+$/.test(limit)) {
|
|
36
|
+
console.error("Error: limit must be a number");
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const token = process.env.HF_TOKEN;
|
|
41
|
+
const headers: Record<string, string> = token
|
|
42
|
+
? { Authorization: `Bearer ${token}` }
|
|
43
|
+
: {};
|
|
44
|
+
|
|
45
|
+
const url = `https://huggingface.co/api/models?limit=${limit}`;
|
|
46
|
+
|
|
47
|
+
(async () => {
|
|
48
|
+
const res = await fetch(url, { headers });
|
|
49
|
+
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
console.error(`Error: ${res.status} ${res.statusText}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const text = await res.text();
|
|
56
|
+
process.stdout.write(text);
|
|
57
|
+
})();
|