EuuIia commited on
Commit
5f7901d
·
verified ·
1 Parent(s): 1797675

Upload 9 files

Browse files
Files changed (9) hide show
  1. Dockerfile +140 -0
  2. LICENSE +25 -0
  3. NOTICE.md +76 -0
  4. README.md +207 -8
  5. builder.sh +346 -0
  6. compose.yaml +26 -0
  7. entrypoint.sh +21 -0
  8. info.sh +154 -0
  9. start.sh +62 -0
Dockerfile ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =============================================================================
2
+ # ADUC-SDR Video Suite — High-Perf Diffusers for 8× L40S (SM 8.9)
3
+ # CUDA 12.8 | PyTorch 2.8.0+cu128 | Ubuntu 22.04
4
+ # =============================================================================
5
+ FROM nvidia/cuda:12.8.0-devel-ubuntu22.04
6
+
7
+ LABEL maintainer="Carlos Rodrigues dos Santos & Development Partner"
8
+ LABEL description="High-performance Diffusers stack with FA2/SDPA, 8×L40S"
9
+ LABEL version="4.4.0"
10
+ LABEL cuda_version="12.8.0"
11
+ LABEL python_version="3.10"
12
+ LABEL pytorch_version="2.8.0+cu128"
13
+ LABEL gpu_optimized_for="8x_NVIDIA_L40S"
14
+
15
+ # ---------------- Core env & caches ----------------
16
+ ENV DEBIAN_FRONTEND=noninteractive TZ=UTC LANG=C.UTF-8 LC_ALL=C.UTF-8 \
17
+ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
18
+ PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
19
+
20
+ # GPU/Compute
21
+ ENV NVIDIA_VISIBLE_DEVICES=all
22
+ ENV TORCH_CUDA_ARCH_LIST="8.9"
23
+ ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
24
+ ENV CUDA_DEVICE_MAX_CONNECTIONS=32
25
+
26
+ # Threads
27
+ ENV OMP_NUM_THREADS=8 MKL_NUM_THREADS=8 MAX_JOBS=160
28
+
29
+ # Alloc/caches
30
+ ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512,garbage_collection_threshold:0.8
31
+ ENV CUDA_LAUNCH_BLOCKING=0 CUDA_CACHE_MAXSIZE=2147483648 CUDA_CACHE_DISABLE=0
32
+
33
+ # Hugging Face caches
34
+ ENV APP_HOME=/app
35
+ WORKDIR $APP_HOME
36
+
37
+
38
+ ENV MODELS_DIR=/app/models
39
+ RUN mkdir -p /data /data/.cache/huggingface /home/user/.cache/models && ln -sf /home/user/.cache/models /app/models
40
+
41
+
42
+
43
+
44
+ # ---------------- Sistema & Python ----------------
45
+ RUN apt-get update && apt-get install -y --no-install-recommends \
46
+ build-essential gosu tree cmake git git-lfs curl wget ffmpeg ninja-build \
47
+ python3.10 python3.10-dev python3.10-distutils python3-pip \
48
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
49
+
50
+ RUN ln -sf /usr/bin/python3.10 /usr/bin/python3 && \
51
+ ln -sf /usr/bin/python3.10 /usr/bin/python && \
52
+ python3 -m pip install --upgrade pip
53
+
54
+
55
+ # ---------------- PyTorch cu128 (pinado) ----------------
56
+ RUN pip install --index-url https://download.pytorch.org/whl/cu128 \
57
+ torch==2.8.0+cu128 torchvision==0.23.0+cu128 torchaudio==2.8.0+cu128
58
+
59
+ # ---------------- Toolchain, Triton, FA2 (sem bnb) ----------------
60
+ RUN pip install packaging ninja cmake pybind11 scikit-build cython hf_transfer numpy>=1.24.4
61
+
62
+ # Triton 3.x (sem triton.ops)
63
+ RUN pip uninstall -y triton || true && \
64
+ pip install -v --no-build-isolation triton==3.4.0
65
+
66
+ # FlashAttention 2.8.x
67
+ RUN pip install flash-attn==2.8.3 --no-build-isolation || \
68
+ pip install flash-attn==2.8.2 --no-build-isolation || \
69
+ pip install flash-attn==2.8.1 --no-build-isolation || \
70
+ pip install flash-attn==2.8.0.post2 --no-build-isolation
71
+
72
+ # Diffusers/Transformers estáveis (sem dev)
73
+ #RUN pip install --no-cache-dir diffusers>=0.31.0 transformers>=4.44.2 accelerate>=0.34.2 omegaconf>=2.3.0
74
+
75
+ # Opcional: seu fork de otimizações
76
+ #RUN pip install -U git+https://github.com/carlex22/diffusers-aduc-sdr
77
+
78
+ # ---------------- Dependências da aplicação ----------------
79
+ COPY requirements.txt ./requirements.txt
80
+ RUN pip install --no-cache-dir -r requirements.txt
81
+
82
+ RUN pip install --upgrade bitsandbytes
83
+
84
+
85
+ RUN apt-get update && apt-get install -y curl && \
86
+ echo "Instalando dependências .whl customizadas..." && \
87
+ pip install --no-cache-dir \
88
+ "https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/apex-0.1-cp310-cp310-linux_x86_64.whl" \
89
+ "https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/dropout_layer_norm-0.1-cp310-cp310-linux_x86_64.whl" && \
90
+ apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
91
+
92
+
93
+ # ====================================================================
94
+ # <<< BLOCO ATUALIZADO PARA INSTALAR LTX-VIDEO E Q8_KERNELS (com .whl) >>>
95
+ #RUN echo "Instalando q8_kernels (wheel) e LTX-Video (git)..." && \
96
+ # 1. Instala q8_kernels a partir do seu arquivo .whl pré-compilado
97
+ #pip install --no-cache-dir "https://huggingface.co/euIaxs22/Aduc-sdr/resolve/main/q8_kernels-0.0.5-cp310-cp310-linux_x86_64.whl" && \
98
+
99
+ # 2. Instala a biblioteca LTX-Video a partir do fork (esta parte permanece igual)
100
+ #git clone https://github.com/Lightricks/LTX-Video.git /data/LTX-Video && \
101
+ #cd /data/LTX-Video && \
102
+ #python -m venv env && \
103
+ #source env/bin/activate && \
104
+ #python -m pip install -e .\[inference\] && \
105
+ #cd ..
106
+ # ====================================================================
107
+
108
+ # Scripts e configs
109
+ COPY info.sh ./app/info.sh
110
+ COPY builder.sh ./app/builder.sh
111
+ COPY start.sh ./app/start.sh
112
+ COPY entrypoint.sh ./app/entrypoint.sh
113
+
114
+ COPY . .
115
+ RUN useradd -m -u 1000 -s /bin/bash appuser
116
+ RUN chown -R appuser:appuser /app && \
117
+ chmod 0755 /app/entrypoint.sh /app/start.sh /app/info.sh /app/builder.sh
118
+
119
+
120
+
121
+ # Declara volume persistente para HF Spaces
122
+ VOLUME /data
123
+
124
+ # Env vars para caches em /data
125
+ ENV HF_HOME=/data/.cache/huggingface
126
+ ENV TORCH_HOME=/data/.cache/torch
127
+ ENV HF_DATASETS_CACHE=/data/.cache/datasets
128
+ ENV TRANSFORMERS_CACHE=/data/.cache/transformers
129
+ ENV DIFFUSERS_CACHE=/data/.cache/diffusers
130
+ ENV HF_HUB_ENABLE_HF_TRANSFER=1
131
+ ENV TOKENIZERS_PARALLELISM=false
132
+
133
+
134
+ ENTRYPOINT ["/app/entrypoint.sh"]
135
+
136
+ USER appuser
137
+
138
+ # ---------------- Entry ----------------
139
+
140
+ CMD ["/app/start.sh"]
LICENSE ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Euia-AducSdr: Uma implementação aberta e funcional da arquitetura ADUC-SDR para geração de vídeo coerente.
2
+ # Copyright (C) 4 de Agosto de 2025 Carlos Rodrigues dos Santos
3
+ #
4
+ # Contato:
5
+ # Carlos Rodrigues dos Santos
6
7
+ # Rua Eduardo Carlos Pereira, 4125, B1 Ap32, Curitiba, PR, Brazil, CEP 8102025
8
+ #
9
+ # Repositórios e Projetos Relacionados:
10
+ # GitHub: https://github.com/carlex22/Aduc-sdr
11
+ # Hugging Face (Ltx-SuperTime-60Secondos): https://huggingface.co/spaces/Carlexx/Ltx-SuperTime-60Secondos/
12
+ # Hugging Face (Novinho): https://huggingface.co/spaces/Carlexxx/Novinho/
13
+ #
14
+ # This program is free software: you can redistribute it and/or modify
15
+ # it under the terms of the GNU Affero General Public License as published by
16
+ # the Free Software Foundation, either version 3 of the License, or
17
+ # (at your option) any later version.
18
+ #
19
+ # This program is distributed in the hope that it will be useful,
20
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ # GNU Affero General Public License for more details.
23
+ #
24
+ # You should have received a copy of the GNU Affero General Public License
25
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
NOTICE.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NOTICE
2
+
3
+ Copyright (C) 2025 Carlos Rodrigues dos Santos. All rights reserved.
4
+
5
+ ---
6
+
7
+ ## Aviso de Propriedade Intelectual e Licenciamento
8
+
9
+ ### **Processo de Patenteamento em Andamento (EM PORTUGUÊS):**
10
+
11
+ O método e o sistema de orquestração de prompts denominados **ADUC (Automated Discovery and Orchestration of Complex tasks)**, conforme descritos neste documento e implementados neste software, estão atualmente em processo de patenteamento.
12
+
13
+ O titular dos direitos, Carlos Rodrigues dos Santos, está buscando proteção legal para as inovações chave da arquitetura ADUC, incluindo, mas não se limitando a:
14
+
15
+ * Fragmentação e escalonamento de solicitações que excedem limites de contexto de modelos de IA.
16
+ * Distribuição inteligente de sub-tarefas para especialistas heterogêneos.
17
+ * Gerenciamento de estado persistido com avaliação iterativa e realimentação para o planejamento de próximas etapas.
18
+ * Planejamento e roteamento sensível a custo, latência e requisitos de qualidade.
19
+ * O uso de "tokens universais" para comunicação agnóstica a modelos.
20
+
21
+ ### **Reconhecimento e Implicações (EM PORTUGUÊS):**
22
+
23
+ Ao acessar ou utilizar este software e a arquitetura ADUC aqui implementada, você reconhece:
24
+
25
+ 1. A natureza inovadora e a importância da arquitetura ADUC no campo da orquestração de prompts para IA.
26
+ 2. Que a essência desta arquitetura, ou suas implementações derivadas, podem estar sujeitas a direitos de propriedade intelectual, incluindo patentes.
27
+ 3. Que o uso comercial, a reprodução da lógica central da ADUC em sistemas independentes, ou a exploração direta da invenção sem o devido licenciamento podem infringir os direitos de patente pendente.
28
+
29
+ ---
30
+
31
+ ### **Patent Pending (IN ENGLISH):**
32
+
33
+ The method and system for prompt orchestration named **ADUC (Automated Discovery and Orchestration of Complex tasks)**, as described herein and implemented in this software, are currently in the process of being patented.
34
+
35
+ The rights holder, Carlos Rodrigues dos Santos, is seeking legal protection for the key innovations of the ADUC architecture, including, but not limited to:
36
+
37
+ * Fragmentation and scaling of requests exceeding AI model context limits.
38
+ * Intelligent distribution of sub-tasks to heterogeneous specialists.
39
+ * Persistent state management with iterative evaluation and feedback for planning subsequent steps.
40
+ * Cost, latency, and quality-aware planning and routing.
41
+ * The use of "universal tokens" for model-agnostic communication.
42
+
43
+ ### **Acknowledgement and Implications (IN ENGLISH):**
44
+
45
+ By accessing or using this software and the ADUC architecture implemented herein, you acknowledge:
46
+
47
+ 1. The innovative nature and significance of the ADUC architecture in the field of AI prompt orchestration.
48
+ 2. That the essence of this architecture, or its derivative implementations, may be subject to intellectual property rights, including patents.
49
+ 3. That commercial use, reproduction of ADUC's core logic in independent systems, or direct exploitation of the invention without proper licensing may infringe upon pending patent rights.
50
+
51
+ ---
52
+
53
+ ## Licença AGPLv3
54
+
55
+ This program is free software: you can redistribute it and/or modify
56
+ it under the terms of the GNU Affero General Public License as published by
57
+ the Free Software Foundation, either version 3 of the License, or
58
+ (at your option) any later version.
59
+
60
+ This program is distributed in the hope that it will be useful,
61
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
62
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63
+ GNU Affero General Public License for more details.
64
+
65
+ You should have received a copy of the GNU Affero General Public License
66
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
67
+
68
+ ---
69
+
70
+ **Contato para Consultas:**
71
+
72
+ Para mais informações sobre a arquitetura ADUC, o status do patenteamento, ou para discutir licenciamento para usos comerciais ou não conformes com a AGPLv3, por favor, entre em contato:
73
+
74
+ Carlos Rodrigues dos Santos
75
76
+ Rua Eduardo Carlos Pereira, 4125, B1 Ap32, Curitiba, PR, Brazil, CEP 8102025
README.md CHANGED
@@ -1,13 +1,212 @@
1
  ---
2
- title: LTX Video Fast
3
  emoji: 🎥
4
- colorFrom: yellow
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 5.42.0
8
  app_file: app.py
9
- pinned: false
10
- short_description: ultra-fast video model, LTX 0.9.8 13B distilled
 
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Euia-AducSdr
3
  emoji: 🎥
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: docker
 
7
  app_file: app.py
8
+ pinned: true
9
+ license: agpl-3.0
10
+ setup_file: setup.sh
11
+ short_description: Uma implementação aberta e funcional da arquitetura ADUC-SDR
12
  ---
13
 
14
+
15
+ ### 🇧🇷 Português
16
+
17
+ Uma implementação aberta e funcional da arquitetura ADUC-SDR (Arquitetura de Unificação Compositiva - Escala Dinâmica e Resiliente), projetada para a geração de vídeo coerente de longa duração. Este projeto materializa os princípios de fragmentação, navegação geométrica e um mecanismo de "eco causal 4bits memoria" para garantir a continuidade física e narrativa em sequências de vídeo geradas por múltiplos modelos de IA.
18
+
19
+ **Licença:** Este projeto é licenciado sob os termos da **GNU Affero General Public License v3.0**. Isto significa que se você usar este software (ou qualquer trabalho derivado) para fornecer um serviço através de uma rede, você é **obrigado a disponibilizar o código-fonte completo** da sua versão para os usuários desse serviço.
20
+
21
+ - **Copyright (C) 4 de Agosto de 2025, Carlos Rodrigues dos Santos**
22
+ - Uma cópia completa da licença pode ser encontrada no arquivo [LICENSE](LICENSE).
23
+
24
+ ---
25
+
26
+ ### 🇬🇧 English
27
+
28
+ An open and functional implementation of the ADUC-SDR (Architecture for Compositive Unification - Dynamic and Resilient Scaling) architecture, designed for long-form coherent video generation. This project materializes the principles of fragmentation, geometric navigation, and a "causal echo 4bits memori" mechanism to ensure physical and narrative continuity in video sequences generated by multiple AI models.
29
+
30
+ **License:** This project is licensed under the terms of the **GNU Affero General Public License v3.0**. This means that if you use this software (or any derivative work) to provide a service over a network, you are **required to make the complete source code** of your version available to the users of that service.
31
+
32
+ - **Copyright (C) August 4, 2025, Carlos Rodrigues dos Santos**
33
+ - A full copy of the license can be found in the [LICENSE](LICENSE) file.
34
+
35
+ ---
36
+
37
+ ## **Aviso de Propriedade Intelectual e Patenteamento**
38
+
39
+ ### **Processo de Patenteamento em Andamento (EM PORTUGUÊS):**
40
+
41
+ A arquitetura e o método **ADUC (Automated Discovery and Orchestration of Complex tasks)**, conforme descritos neste projeto e nas reivindicações associadas, estão **atualmente em processo de patenteamento**.
42
+
43
+ O titular dos direitos, Carlos Rodrigues dos Santos, está buscando proteção legal para as inovações chave da arquitetura ADUC, que incluem, mas não se limitam a:
44
+
45
+ * Fragmentação e escalonamento de solicitações que excedem limites de contexto de modelos de IA.
46
+ * Distribuição inteligente de sub-tarefas para especialistas heterogêneos.
47
+ * Gerenciamento de estado persistido com avaliação iterativa e realimentação para o planejamento de próximas etapas.
48
+ * Planejamento e roteamento sensível a custo, latência e requisitos de qualidade.
49
+ * O uso de "tokens universais" para comunicação agnóstica a modelos.
50
+
51
+ Ao utilizar este software e a arquitetura ADUC aqui implementada, você reconhece a natureza inovadora desta arquitetura e que a **reprodução ou exploração da lógica central da ADUC em sistemas independentes pode infringir direitos de patente pendente.**
52
+
53
+ ---
54
+
55
+ ### **Patent Pending (IN ENGLISH):**
56
+
57
+ The **ADUC (Automated Discovery and Orchestration of Complex tasks)** architecture and method, as described in this project and its associated claims, are **currently in the process of being patented.**
58
+
59
+ The rights holder, Carlos Rodrigues dos Santos, is seeking legal protection for the key innovations of the ADUC architecture, including, but not limited to:
60
+
61
+ * Fragmentation and scaling of requests exceeding AI model context limits.
62
+ * Intelligent distribution of sub-tasks to heterogeneous specialists.
63
+ * Persistent state management with iterative evaluation and feedback for planning subsequent steps.
64
+ * Cost, latency, and quality-aware planning and routing.
65
+ * The use of "universal tokens" for model-agnostic communication.
66
+
67
+ By using this software and the ADUC architecture implemented herein, you acknowledge the innovative nature of this architecture and that **the reproduction or exploitation of ADUC's core logic in independent systems may infringe upon pending patent rights.**
68
+
69
+ ---
70
+
71
+ ### Detalhes Técnicos e Reivindicações da ADUC
72
+
73
+ #### 🇧🇷 Definição Curta (para Tese e Patente)
74
+
75
+ **ADUC** é um *framework pré-input* e *intermediário* de **gerenciamento de prompts** que:
76
+
77
+ 1. **fragmenta** solicitações acima do limite de contexto de qualquer modelo,
78
+ 2. **escala linearmente** (processo sequencial com memória persistida),
79
+ 3. **distribui** sub-tarefas a **especialistas** (modelos/ferramentas heterogêneos), e
80
+ 4. **realimenta** a próxima etapa com avaliação do que foi feito/esperado (LLM diretor).
81
+
82
+ Não é um modelo; é uma **camada orquestradora** plugável antes do input de modelos existentes (texto, imagem, áudio, vídeo), usando *tokens universais* e a tecnologia atual.
83
+
84
+ #### 🇬🇧 Short Definition (for Thesis and Patent)
85
+
86
+ **ADUC** is a *pre-input* and *intermediate* **prompt management framework** that:
87
+
88
+ 1. **fragments** requests exceeding any model's context limit,
89
+ 2. **scales linearly** (sequential process with persisted memory),
90
+ 3. **distributes** sub-tasks to **specialists** (heterogeneous models/tools), and
91
+ 4. **feeds back** to the next step with an evaluation of what was done/expected (director LLM).
92
+
93
+ It is not a model; it is a pluggable **orchestration layer** before the input of existing models (text, image, audio, video), using *universal tokens* and current technology.
94
+
95
+ ---
96
+
97
+ #### 🇧🇷 Elementos Essenciais (Telegráfico)
98
+
99
+ * **Agnóstico a modelos:** opera com qualquer LLM/difusor/API.
100
+ * **Pré-input manager:** recebe pedido do usuário, **divide** em blocos ≤ limite de tokens, **prioriza**, **agenda** e **roteia**.
101
+ * **Memória persistida:** resultados/latentes/“eco” viram **estado compartilhado** para o próximo bloco (nada é ignorado).
102
+ * **Especialistas:** *routers* decidem quem faz o quê (ex.: “descrição → LLM-A”, “keyframe → Img-B”, “vídeo → Vid-C”).
103
+ * **Controle de qualidade:** LLM diretor compara *o que fez* × *o que deveria* × *o que falta* e **regenera objetivos** do próximo fragmento.
104
+ * **Custo/latência-aware:** planeja pela **VRAM/tempo/custo**, não tenta “abraçar tudo de uma vez”.
105
+
106
+ #### 🇬🇧 Essential Elements (Telegraphic)
107
+
108
+ * **Model-agnostic:** operates with any LLM/diffuser/API.
109
+ * **Pre-input manager:** receives user request, **divides** into blocks ≤ token limit, **prioritizes**, **schedules**, and **routes**.
110
+ * **Persisted memory:** results/latents/“echo” become **shared state** for the next block (nothing is ignored).
111
+ * **Specialists:** *routers* decide who does what (e.g., “description → LLM-A”, “keyframe → Img-B”, “video → Vid-C”).
112
+ * **Quality control:** director LLM compares *what was done* × *what should be done* × *what is missing* and **regenerates objectives** for the next fragment.
113
+ * **Cost/latency-aware:** plans by **VRAM/time/cost**, does not try to “embrace everything at once”.
114
+
115
+ ---
116
+
117
+ #### 🇧🇷 Reivindicações Independentes (Método e Sistema)
118
+
119
+ **Reivindicação Independente (Método) — Versão Enxuta:**
120
+
121
+ 1. **Método** de **orquestração de prompts** para execução de tarefas acima do limite de contexto de modelos de IA, compreendendo:
122
+ (a) **receber** uma solicitação que excede um limite de tokens;
123
+ (b) **analisar** a solicitação por um **LLM diretor** e **fragmentá-la** em sub-tarefas ≤ limite;
124
+ (c) **selecionar** especialistas de execução para cada sub-tarefa com base em capacidades declaradas;
125
+ (d) **gerar** prompts específicos por sub-tarefa em **tokens universais**, incluindo referências ao **estado persistido** de execuções anteriores;
126
+ (e) **executar sequencialmente** as sub-tarefas e **persistir** suas saídas como memória (incluindo latentes/eco/artefatos);
127
+ (f) **avaliar** automaticamente a saída versus metas declaradas e **regenerar objetivos** do próximo fragmento;
128
+ (g) **iterar** (b)–(f) até que os critérios de completude sejam atendidos, produzindo o resultado agregado;
129
+ em que o framework **escala linearmente** no tempo e armazenamento físico, **independente** da janela de contexto dos modelos subjacentes.
130
+
131
+ **Reivindicação Independente (Sistema):**
132
+
133
+ 2. **Sistema** de orquestração de prompts, compreendendo: um **planejador LLM diretor**; um **roteador de especialistas**; um **banco de estado persistido** (incl. memória cinética para vídeo); um **gerador de prompts universais**; e um **módulo de avaliação/realimentação**, acoplados por uma **API pré-input** a modelos heterogêneos.
134
+
135
+ #### 🇬🇧 Independent Claims (Method and System)
136
+
137
+ **Independent Claim (Method) — Concise Version:**
138
+
139
+ 1. A **method** for **prompt orchestration** for executing tasks exceeding AI model context limits, comprising:
140
+ (a) **receiving** a request that exceeds a token limit;
141
+ (b) **analyzing** the request by a **director LLM** and **fragmenting it** into sub-tasks ≤ the limit;
142
+ (c) **selecting** execution specialists for each sub-task based on declared capabilities;
143
+ (d) **generating** specific prompts per sub-task in **universal tokens**, including references to the **persisted state** of previous executions;
144
+ (e) **sequentially executing** the sub-tasks and **persisting** their outputs as memory (including latents/echo/artifacts);
145
+ (f) **automatically evaluating** the output against declared goals and **regenerating objectives** for the next fragment;
146
+ (g) **iterating** (b)–(f) until completion criteria are met, producing the aggregated result;
147
+ wherein the framework **scales linearly** in time and physical storage, **independent** of the context window of the underlying models.
148
+
149
+ **Independent Claim (System):**
150
+
151
+ 2. A prompt orchestration **system**, comprising: a **director LLM planner**; a **specialist router**; a **persisted state bank** (incl. kinetic memory for video); a **universal prompt generator**; and an **evaluation/feedback module**, coupled via a **pre-input API** to heterogeneous models.
152
+
153
+ ---
154
+
155
+ #### 🇧🇷 Dependentes Úteis
156
+
157
+ * (3) Onde o roteamento considera **custo/latência/VRAM** e metas de qualidade.
158
+ * (4) Onde o banco de estado inclui **eco cinético** para vídeo (últimos *n* frames/latentes/fluxo).
159
+ * (5) Onde a avaliação usa métricas específicas por domínio (Lflow, consistência semântica, etc.).
160
+ * (6) Onde *tokens universais* padronizam instruções entre especialistas.
161
+ * (7) Onde a orquestração decide **cut vs continuous** e **corte regenerativo** (Déjà-Vu) ao editar vídeo.
162
+ * (8) Onde o sistema **nunca descarta** conteúdo excedente: **reagenda** em novos fragmentos.
163
+
164
+ #### 🇬🇧 Useful Dependents
165
+
166
+ * (3) Wherein routing considers **cost/latency/VRAM** and quality goals.
167
+ * (4) Wherein the state bank includes **kinetic echo** for video (last *n* frames/latents/flow).
168
+ * (5) Wherein evaluation uses domain-specific metrics (Lflow, semantic consistency, etc.).
169
+ * (6) Wherein *universal tokens* standardize instructions between specialists.
170
+ * (7) Wherein orchestration decides **cut vs continuous** and **regenerative cut** (Déjà-Vu) when editing video.
171
+ * (8) Wherein the system **never discards** excess content: it **reschedules** it in new fragments.
172
+
173
+ ---
174
+
175
+ #### 🇧🇷 Como isso conversa com SDR (Vídeo)
176
+
177
+ * **Eco Cinético**: é um **tipo de estado persistido** consumido pelo próximo passo.
178
+ * **Déjà-Vu (Corte Regenerativo)**: é **uma política de orquestração** aplicada quando há edição; ADUC decide, monta os prompts certos e chama o especialista de vídeo.
179
+ * **Cut vs Continuous**: decisão do **diretor** com base em estado + metas; ADUC roteia e garante a sobreposição/remoção final.
180
+
181
+ #### 🇬🇧 How this Converses with SDR (Video)
182
+
183
+ * **Kinetic Echo**: is a **type of persisted state** consumed by the next step.
184
+ * **Déjà-Vu (Regenerative Cut)**: is an **orchestration policy** applied during editing; ADUC decides, crafts the right prompts, and calls the video specialist.
185
+ * **Cut vs Continuous**: decision made by the **director** based on state + goals; ADUC routes and ensures the final overlap/removal.
186
+
187
+ ---
188
+
189
+ #### 🇧🇷 Mensagem Clara ao Usuário (Experiência)
190
+
191
+ > “Seu pedido excede o limite X do modelo Y. Em vez de truncar silenciosamente, o **ADUC** dividirá e **entregará 100%** do conteúdo por etapas coordenadas.”
192
+
193
+ Isso é diferencial prático e jurídico: **não-obviedade** por transformar limite de contexto em **pipeline controlado**, com **persistência de estado** e **avaliação iterativa**.
194
+
195
+ #### 🇬🇧 Clear User Message (Experience)
196
+
197
+ > "Your request exceeds model Y's limit X. Instead of silently truncating, **ADUC** will divide and **deliver 100%** of the content through coordinated steps."
198
+
199
+ This is a practical and legal differentiator: **non-obviousness** by transforming context limits into a **controlled pipeline**, with **state persistence** and **iterative evaluation**.
200
+
201
+ ---
202
+
203
+ ### Contact / Contato / Contacto
204
+
205
+ - **Author / Autor:** Carlos Rodrigues dos Santos
206
+ - **Email:** [email protected]
207
+ - **GitHub:** [https://github.com/carlex22/Aduc-sdr](https://github.com/carlex22/Aduc-sdr)
208
+ - **Hugging Face Spaces:**
209
+ - [Ltx-SuperTime-60Secondos](https://huggingface.co/spaces/Carlexx/Ltx-SuperTime-60Secondos/)
210
+ - [Novinho](https://huggingface.co/spaces/Carlexxx/Novinho/)
211
+
212
+ ---
builder.sh ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ echo "🚀 Builder (FlashAttn LayerNorm extra + Apex + Q8) — runtime com GPU visível"
5
+
6
+ # ===== Config e diretórios =====
7
+
8
+
9
+ mkdir -p /app/wheels /app/cuda_cache /app/wheels/src
10
+ chmod -R 777 /app/wheels || true
11
+ export CUDA_CACHE_PATH="/app/cuda_cache"
12
+
13
+ # Preserva licença NGC (se existir)
14
+ if [ -f "/NGC-DL-CONTAINER-LICENSE" ]; then
15
+ cp -f /NGC-DL-CONTAINER-LICENSE /app/wheels/NGC-DL-CONTAINER-LICENSE || true
16
+ fi
17
+
18
+ # ===== Dependências mínimas =====
19
+ python -m pip install -v -U pip build setuptools wheel hatchling hatch-vcs scikit-build-core cmake ninja packaging "huggingface_hub[hf_transfer]" || true
20
+
21
+ # ===== Tags de ambiente (Python/CUDA/Torch) =====
22
+ PY_TAG="$(python -c 'import sys; print(f"cp{sys.version_info[0]}{sys.version_info[1]}")' 2>/dev/null || echo cp310)"
23
+ TORCH_VER="$(python - <<'PY'
24
+ try:
25
+ import torch, re
26
+ v = torch.__version__
27
+ print(re.sub(r'\+.*$', '', v))
28
+ except Exception:
29
+ print("unknown")
30
+ PY
31
+ )"
32
+ CU_TAG="$(python - <<'PY'
33
+ try:
34
+ import torch
35
+ cu = getattr(torch.version, "cuda", None)
36
+ print("cu"+cu.replace(".","")) if cu else print("")
37
+ except Exception:
38
+ print("")
39
+ PY
40
+ )"
41
+ echo "[env] PY_TAG=${PY_TAG} TORCH_VER=${TORCH_VER} CU_TAG=${CU_TAG}"
42
+
43
+ # ============================================================================
44
+ # CHECKERS
45
+ # ============================================================================
46
+
47
+ # Checa especificamente o módulo nativo requerido pelo layer_norm (sem checar 'flash-attn' geral)
48
+ check_flash_layer_norm_bin () {
49
+ python - <<'PY'
50
+ import importlib
51
+ ok = False
52
+ # extensões conhecidas produzidas por csrc/layer_norm
53
+ for name in [
54
+ "dropout_layer_norm", # nome do módulo nativo
55
+ "flash_attn.ops.layer_norm", # wrapper python que usa o nativo
56
+ "flash_attn.ops.rms_norm", # pode depender do mesmo backend em alguns empacotamentos
57
+ ]:
58
+ try:
59
+ importlib.import_module(name)
60
+ ok = True
61
+ break
62
+ except Exception:
63
+ pass
64
+ raise SystemExit(0 if ok else 1)
65
+ PY
66
+ }
67
+
68
+ check_apex () {
69
+ python - <<'PY'
70
+ try:
71
+ from apex.normalization import FusedLayerNorm
72
+ import importlib; importlib.import_module("fused_layer_norm_cuda")
73
+ ok = True
74
+ except Exception:
75
+ ok = False
76
+ raise SystemExit(0 if ok else 1)
77
+ PY
78
+ }
79
+
80
+ check_q8 () {
81
+ python - <<'PY'
82
+ import importlib.util
83
+ spec = importlib.util.find_spec("ltx_q8_kernels") or importlib.util.find_spec("q8_kernels")
84
+ raise SystemExit(0 if spec else 1)
85
+ PY
86
+ }
87
+
88
+ # ============================================================================
89
+ # DOWNLOAD DO HUB (GENÉRICO)
90
+ # ============================================================================
91
+
92
+ # Instala uma wheel do HF por prefixo simples (ex.: apex-, q8_kernels-)
93
+ install_from_hf_by_prefix () {
94
+ local PREFIX="$1"
95
+ echo "[hub] Procurando wheels '${PREFIX}-*.whl' em ${SELF_HF_REPO_ID} com tags ${PY_TAG}/${CU_TAG}"
96
+ python - "$PREFIX" "$PY_TAG" "$CU_TAG" <<'PY' || exit 0
97
+ import os, sys
98
+ from huggingface_hub import HfApi, hf_hub_download, HfFolder
99
+
100
+ prefix, py_tag, cu_tag = sys.argv[1], sys.argv[2], sys.argv[3]
101
+ repo = os.environ.get("SELF_HF_REPO_ID","euIaxs22/Aduc-sdr")
102
+ api = HfApi(token=os.getenv("HF_TOKEN") or HfFolder.get_token())
103
+ try:
104
+ files = api.list_repo_files(repo_id=repo, repo_type="model")
105
+ except Exception:
106
+ raise SystemExit(0)
107
+
108
+ def match(name: str) -> bool:
109
+ return name.endswith(".whl") and name.rsplit("/",1)[-1].startswith(prefix + "-") and (py_tag in name)
110
+
111
+ cands = [f for f in files if match(f)]
112
+ pref = [f for f in cands if cu_tag and cu_tag in f] or cands
113
+ if not pref:
114
+ raise SystemExit(0)
115
+
116
+ target = sorted(pref, reverse=True)[0]
117
+ print(target)
118
+ path = hf_hub_download(repo_id=repo, filename=target, repo_type="model", local_dir="/app/wheels")
119
+ print(path)
120
+ PY
121
+ }
122
+
123
+ # Instala wheels do submódulo layer_norm aceitando variantes de nome
124
+ install_flash_layer_norm_from_hf () {
125
+ echo "[hub] Procurando wheels FlashAttention LayerNorm em ${SELF_HF_REPO_ID}"
126
+ python - "$PY_TAG" "$CU_TAG" <<'PY' || exit 0
127
+ import os, sys, re
128
+ from huggingface_hub import HfApi, hf_hub_download, HfFolder
129
+
130
+ py_tag, cu_tag = sys.argv[1], sys.argv[2]
131
+ repo = os.environ.get("SELF_HF_REPO_ID","euIaxs22/Aduc-sdr")
132
+ api = HfApi(token=os.getenv("HF_TOKEN") or HfFolder.get_token())
133
+ try:
134
+ files = api.list_repo_files(repo_id=repo, repo_type="model")
135
+ except Exception:
136
+ raise SystemExit(0)
137
+
138
+ pats = [
139
+ r"^flash[_-]?attn[_-]?.*layer[_-]?norm-.*\.whl$",
140
+ r"^dropout[_-]?layer[_-]?norm-.*\.whl$",
141
+ ]
142
+ def ok(fn: str) -> bool:
143
+ name = fn.rsplit("/",1)[-1]
144
+ if py_tag not in name: return False
145
+ return any(re.search(p, name, flags=re.I) for p in pats)
146
+
147
+ cands = [f for f in files if ok(f)]
148
+ pref = [f for f in cands if cu_tag and cu_tag in f] or cands
149
+ if not pref:
150
+ raise SystemExit(0)
151
+
152
+ target = sorted(pref, reverse=True)[0]
153
+ print(target)
154
+ path = hf_hub_download(repo_id=repo, filename=target, repo_type="model", local_dir="/app/wheels")
155
+ print(path)
156
+ PY
157
+ }
158
+
159
+ # ============================================================================
160
+ # BUILDERS
161
+ # ============================================================================
162
+
163
+ # Passo extra: SIEMPRE tenta instalar o submódulo layer_norm via wheel do HF;
164
+ # se não houver wheel compatível, compila a partir de csrc/layer_norm e gera wheel.
165
+ build_or_install_flash_layer_norm () {
166
+ echo "[flow] === FlashAttn LayerNorm (passo extra) ==="
167
+
168
+ # 1) Tentar instalar wheel do HF primeiro (evita recompilar)
169
+ HF_OUT="$(install_flash_layer_norm_from_hf || true)"
170
+ if [ -n "${HF_OUT:-}" ]; then
171
+ WHEEL_PATH="$(printf "%s\n" "${HF_OUT}" | tail -n1)"
172
+ echo "[hub] Baixado: ${WHEEL_PATH}"
173
+ python -m pip install -v -U --no-build-isolation --no-deps "${WHEEL_PATH}" || true
174
+ if check_flash_layer_norm_bin; then
175
+ echo "[flow] FlashAttn LayerNorm: OK via wheel do Hub"
176
+ return 0
177
+ fi
178
+ echo "[flow] Wheel do Hub não resolveu import; seguirá com build"
179
+ else
180
+ echo "[hub] Nenhuma wheel compatível encontrada para FlashAttn LayerNorm"
181
+ fi
182
+
183
+ # 2) Build from source do submódulo csrc/layer_norm -> wheel
184
+ local SRC="/app/wheels/src/flash-attn"
185
+ echo "[build] Preparando fonte FlashAttention (layer_norm) em ${SRC}"
186
+ if [ -d "$SRC/.git" ]; then
187
+ git -C "$SRC" fetch --all -p || true
188
+ git -C "$SRC" reset --hard origin/main || true
189
+ git -C "$SRC" clean -fdx || true
190
+ else
191
+ rm -rf "$SRC"
192
+ git clone --depth 1 https://github.com/Dao-AILab/flash-attention "$SRC"
193
+ fi
194
+
195
+ # Define CC alvo a partir da GPU ativa (reduz tempo/ruído de build)
196
+ export TORCH_CUDA_ARCH_LIST="$(python - <<'PY'
197
+ import torch
198
+ try:
199
+ cc = "%d.%d" % torch.cuda.get_device_capability(0)
200
+ print(cc)
201
+ except Exception:
202
+ print("8.9") # fallback p/ Ada (L40S) caso build sem GPU visível
203
+ PY
204
+ )"
205
+ echo "[build] TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}"
206
+
207
+ pushd "$SRC/csrc/layer_norm" >/dev/null
208
+ export MAX_JOBS="${MAX_JOBS:-90}"
209
+ # Gera wheel reutilizável
210
+ python -m pip wheel -v --no-build-isolation --no-deps . -w /app/wheels || true
211
+ popd >/dev/null
212
+
213
+ # Instala a wheel gerada
214
+ local W="$(ls -t /app/wheels/*flash*attn*layer*norm*-*.whl 2>/dev/null | head -n1 || true)"
215
+ if [ -z "${W}" ]; then
216
+ W="$(ls -t /app/wheels/*dropout*layer*norm*-*.whl 2>/dev/null | head -n1 || true)"
217
+ fi
218
+ if [ -z "${W}" ]; then
219
+ # fallback para qualquer .whl recém gerado
220
+ W="$(ls -t /app/wheels/*.whl 2>/dev/null | head -n1 || true)"
221
+ fi
222
+
223
+ if [ -n "${W}" ]; then
224
+ python -m pip install -v -U --no-deps "${W}" || true
225
+ echo "[build] FlashAttn LayerNorm instalado da wheel: ${W}"
226
+ else
227
+ echo "[build] Nenhuma wheel gerada; instalando direto do source (último recurso)"
228
+ python -m pip install -v --no-build-isolation "$SRC/csrc/layer_norm" || true
229
+ fi
230
+
231
+ # Checagem final do binário
232
+ if check_flash_layer_norm_bin; then
233
+ echo "[flow] FlashAttn LayerNorm: import OK após build"
234
+ return 0
235
+ fi
236
+ echo "[flow] FlashAttn LayerNorm: falhou import após build"
237
+ return 1
238
+ }
239
+
240
+ build_apex () {
241
+ local SRC="/app/wheels/src/apex"
242
+ echo "[build] Preparando fonte Apex em ${SRC}"
243
+ if [ -d "$SRC/.git" ]; then
244
+ git -C "$SRC" fetch --all -p || true
245
+ git -C "$SRC" reset --hard HEAD || true
246
+ git -C "$SRC" clean -fdx || true
247
+ else
248
+ rm -rf "$SRC"
249
+ git clone --depth 1 https://github.com/NVIDIA/apex "$SRC"
250
+ fi
251
+ echo "[build] Compilando Apex -> wheel"
252
+ export APEX_CPP_EXT=1 APEX_CUDA_EXT=1 APEX_ALL_CONTRIB_EXT=0
253
+ python -m pip wheel -v --no-build-isolation --no-deps "$SRC" -w /app/wheels || true
254
+ local W="$(ls -t /app/wheels/apex-*.whl 2>/dev/null | head -n1 || true)"
255
+ if [ -n "${W}" ]; then
256
+ python -m pip install -v -U --no-deps "${W}" || true
257
+ echo "[build] Apex instalado da wheel recém-compilada: ${W}"
258
+ else
259
+ echo "[build] Nenhuma wheel Apex gerada; instalando do source"
260
+ python -m pip install -v --no-build-isolation "$SRC" || true
261
+ fi
262
+ }
263
+
264
+ Q8_REPO="${Q8_REPO:-https://github.com/Lightricks/LTX-Video-Q8-Kernels}"
265
+ Q8_COMMIT="${Q8_COMMIT:-f3066edea210082799ca5a2bbf9ef0321c5dd8fc}"
266
+ build_q8 () {
267
+ local SRC="/app/wheels/src/q8_kernels"
268
+ rm -rf "$SRC"
269
+ git clone --filter=blob:none "$Q8_REPO" "$SRC"
270
+ git -C "$SRC" checkout "$Q8_COMMIT"
271
+ git -C "$SRC" submodule update --init --recursive
272
+ echo "[build] Compilando Q8 Kernels -> wheel"
273
+ python -m pip wheel -v --no-build-isolation "$SRC" -w /app/wheels || true
274
+ local W="$(ls -t /app/wheels/q8_kernels-*.whl 2>/dev/null | head -n1 || true)"
275
+ if [ -n "${W}" ]; then
276
+ python -m pip install -v -U --no-deps "${W}" || true
277
+ echo "[build] Q8 instalado da wheel recém-compilada: ${W}"
278
+ else
279
+ echo "[build] Nenhuma wheel q8_kernels gerada; instalando do source"
280
+ python -m pip install -v --no-build-isolation "$SRC" || true
281
+ fi
282
+ }
283
+
284
+ # ============================================================================
285
+ # EXECUÇÃO
286
+ # ============================================================================
287
+
288
+ # Passo adicional SEM depender de "flash-attn" já instalado: trata somente o layer_norm
289
+ #build_q8 || true
290
+
291
+ # Apex (mantido)
292
+ # Tenta primeiro via wheel no HF e, se não houver, compila e instala em wheel
293
+ #echo "[flow] === apex ==="
294
+ #HF_OUT="$(install_from_hf_by_prefix "apex" || true)"
295
+ #if [ -n "${HF_OUT:-}" ]; then
296
+ # WHEEL_PATH="$(printf "%s\n" "${HF_OUT}" | tail -n1)"
297
+ # echo "[hub] Baixado: ${WHEEL_PATH}"
298
+ # python -m pip install -v -U --no-build-isolation "${WHEEL_PATH}" || true
299
+ # if ! check_apex; then
300
+ # echo "[flow] apex: import falhou após wheel; compilando"
301
+ # #build_apex || true
302
+ # fi
303
+ #else
304
+ # echo "[hub] Nenhuma wheel apex compatível; compilando"
305
+ # build_apex || true
306
+ #fi
307
+
308
+ #Q8 (opcional)
309
+ echo "[flow] === q8_kernels ==="
310
+ HF_OUT="$(install_from_hf_by_prefix "q8_kernels" || true)"
311
+ if [ -n "${HF_OUT:-}" ]; then
312
+ WHEEL_PATH="$(printf "%s\n" "${HF_OUT}" | tail -n1)"
313
+ echo "[hub] Baixado: ${WHEEL_PATH}"
314
+ python -m pip install -v -U --no-build-isolation "${WHEEL_PATH}" || true
315
+ if ! check_q8; then
316
+ echo "[flow] q8_kernels: import falhou após wheel; compilando"
317
+ build_q8 || true
318
+ fi
319
+ else
320
+ echo "[hub] Nenhuma wheel q8_kernels compatível; compilando"
321
+ build_q8 || true
322
+ fi
323
+
324
+ # Upload de wheels produzidas para o HF (cache cross-restarts)
325
+ python - <<'PY'
326
+ import os
327
+ from huggingface_hub import HfApi, HfFolder
328
+
329
+ repo = os.environ.get("SELF_HF_REPO_ID","euIaxs22/Aduc-sdr")
330
+ token = os.getenv("HF_TOKEN") or HfFolder.get_token()
331
+ if not token:
332
+ raise SystemExit("HF_TOKEN ausente; upload desabilitado")
333
+
334
+ api = HfApi(token=token)
335
+ api.upload_folder(
336
+ folder_path="/app/wheels",
337
+ repo_id=repo,
338
+ repo_type="model",
339
+ allow_patterns=["*.whl","NGC-DL-CONTAINER-LICENSE"],
340
+ ignore_patterns=["**/src/**","**/*.log","**/logs/**",".git/**"],
341
+ )
342
+ print("Upload concluído (wheels + licença).")
343
+ PY
344
+
345
+ chmod -R 777 /app/wheels || true
346
+ echo "✅ Builder finalizado."
compose.yaml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ vincie:
3
+ image: img2img:edit
4
+ deploy:
5
+ resources:
6
+ reservations:
7
+ devices:
8
+ - capabilities: [gpu]
9
+ ports:
10
+ - "7860:7860"
11
+ environment:
12
+ GRADIO_SERVER_PORT: "7860"
13
+ HF_HUB_CACHE: "/data/.cache/huggingface/hub"
14
+ CKPT_ROOT: "/data/ckpt/VINCIE-3B"
15
+ VINCIE_ROOT: "/data/VINCIE"
16
+ volumes:
17
+ - vincie_hub:/data/.cache/huggingface/hub
18
+ - vincie_ckpt:/data/ckpt/VINCIE-3B
19
+ - vincie_out:/app/outputs
20
+ - vincie_repo:/data/VINCIE
21
+ volumes:
22
+ vincie_hub: {}
23
+ vincie_ckpt: {}
24
+ vincie_out: {}
25
+ vincie_repo: {}
26
+
entrypoint.sh ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # entrypoint.sh - Executado como root para corrigir permissões.
3
+ set -e
4
+
5
+ echo "🔐 ENTRYPOINT (root): Corrigindo permissões para os diretórios de dados e saída..."
6
+
7
+ # Lista de diretórios a serem criados e terem suas permissões ajustadas
8
+ # Usamos os valores padrão, pois as variáveis de ambiente podem não estar disponíveis aqui.
9
+ DIRS_TO_OWN="/app/outputs /app/inputs"
10
+
11
+ # Garante que os diretórios existam
12
+ mkdir -p $DIRS_TO_OWN
13
+
14
+ # Muda o proprietário para o UID e GID 1000, que corresponde ao 'appuser'
15
+ # Usar UID/GID é mais robusto em ambientes de contêiner.
16
+ chown -R 1000:1000 $DIRS_TO_OWN
17
+
18
+ echo "✅ ENTRYPOINT (root): Permissões corrigidas."
19
+
20
+ # Passa a execução para o comando principal (CMD) definido no Dockerfile.
21
+ exec "$@"
info.sh ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ echo "================= RUNTIME CAPABILITIES ================="
6
+ date
7
+
8
+ echo
9
+ if command -v nvidia-smi >/dev/null 2>&1; then
10
+ nvidia-smi
11
+ else
12
+ echo "nvidia-smi: not available"
13
+ fi
14
+ echo
15
+
16
+ echo "CUDA_HOME: ${CUDA_HOME:-/usr/local/cuda}"
17
+ if command -v nvcc >/dev/null 2>&1; then
18
+ nvcc --version || true
19
+ else
20
+ echo "nvcc: not available"
21
+ fi
22
+ echo
23
+
24
+ echo "[PyTorch / CUDA backend]"
25
+ python3 - <<'PY'
26
+ import json, os, torch, inspect
27
+
28
+ def to_bool(x):
29
+ try:
30
+ if callable(x):
31
+ try:
32
+ sig = inspect.signature(x)
33
+ if len(sig.parameters)==0:
34
+ return bool(x())
35
+ except Exception:
36
+ pass
37
+ return True
38
+ return bool(x)
39
+ except Exception:
40
+ return None
41
+
42
+ info = {
43
+ "torch": getattr(torch, "__version__", None),
44
+ "cuda_available": torch.cuda.is_available(),
45
+ "cuda_device_count": torch.cuda.device_count(),
46
+ "cuda_runtime_version": getattr(torch.version, "cuda", None),
47
+ "cudnn_version": torch.backends.cudnn.version() if torch.backends.cudnn.is_available() else None,
48
+ "tf32": (torch.backends.cuda.matmul.allow_tf32 if torch.cuda.is_available() else None),
49
+ "flash_sdp": (to_bool(getattr(torch.backends.cuda, "enable_flash_sdp", None)) if torch.cuda.is_available() else None),
50
+ "mem_efficient_sdp": (to_bool(getattr(torch.backends.cuda, "enable_mem_efficient_sdp", None)) if torch.cuda.is_available() else None),
51
+ "math_sdp": (to_bool(getattr(torch.backends.cuda, "enable_math_sdp", None)) if torch.cuda.is_available() else None),
52
+ }
53
+ print(json.dumps(info, indent=2))
54
+ for i in range(min(torch.cuda.device_count(), 16)):
55
+ print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
56
+ PY
57
+ echo
58
+
59
+ echo "[Apex (FusedLayerNorm/RMSNorm)]"
60
+ python3 - <<'PY'
61
+ try:
62
+ from apex.normalization import FusedLayerNorm, FusedRMSNorm
63
+ import importlib; importlib.import_module("fused_layer_norm_cuda")
64
+ print("apex.normalization: OK")
65
+ except Exception as e:
66
+ print("apex.normalization: FAIL ->", e)
67
+ PY
68
+ echo
69
+
70
+ echo "[FlashAttention (CUDA/Triton/RMSNorm)]"
71
+ python3 - <<'PY'
72
+ import importlib
73
+ mods = [
74
+ 'flash_attn', 'flash_attn_2_cuda',
75
+ 'flash_attn.ops.rms_norm', 'flash_attn.ops.layer_norm',
76
+ 'flash_attn.layers.layer_norm'
77
+ ]
78
+ for m in mods:
79
+ try:
80
+ importlib.import_module(m)
81
+ print(f"{m}: OK")
82
+ except Exception as e:
83
+ print(f"{m}: FAIL -> {e}")
84
+ PY
85
+ echo
86
+
87
+ echo "[FlashAttention versão/details]"
88
+ python3 - <<'PY'
89
+ try:
90
+ import flash_attn
91
+ fa_ver = getattr(flash_attn, "__version__", None)
92
+ print(f"flash_attn: {fa_ver}")
93
+ except Exception:
94
+ print("flash_attn: not importable.")
95
+ try:
96
+ import torch
97
+ print(f"torch: {torch.__version__} | cuda: {getattr(torch.version, 'cuda', None)}")
98
+ except Exception:
99
+ pass
100
+ PY
101
+ echo
102
+
103
+ echo "[Triton]"
104
+ python3 - <<'PY'
105
+ try:
106
+ import triton
107
+ print("triton:", triton.__version__)
108
+ try:
109
+ import triton.ops as _; print("triton.ops: OK")
110
+ except Exception:
111
+ print("triton.ops: not present (ok on Triton>=3.x)")
112
+ except Exception as e:
113
+ print("triton: FAIL ->", e)
114
+ PY
115
+ echo
116
+
117
+ echo "[BitsAndBytes (Q8/Q4)]"
118
+ python3 - <<'PY'
119
+ try:
120
+ import bitsandbytes as bnb
121
+ print("bitsandbytes:", bnb.__version__)
122
+ try:
123
+ from bitsandbytes.triton import _custom_ops as _; print("bnb.triton._custom_ops: OK")
124
+ except Exception as e:
125
+ print("bnb.triton: partial ->", e)
126
+ except Exception as e:
127
+ print("bitsandbytes: FAIL ->", e)
128
+ PY
129
+ echo
130
+
131
+ echo "[Transformers / Diffusers / XFormers / EcoML]"
132
+ python3 - <<'PY'
133
+ def _v(m):
134
+ try:
135
+ mod = __import__(m)
136
+ print(f"{m}: {getattr(mod, '__version__', 'unknown')}")
137
+ except Exception as e:
138
+ print(f"{m}: FAIL -> {e}")
139
+ for m in ("transformers", "diffusers", "xformers", "ecuml", "mlx", "ecobase"):
140
+ _v(m)
141
+ PY
142
+ echo
143
+
144
+ echo "[Distribuído / NCCL Env]"
145
+ env | grep -E '^(CUDA_VISIBLE_DEVICES|NCCL_|TORCH_|ENABLE_.*SDP|HF_HUB_.*|CUDA_|NV_.*NCCL.*|PYTORCH_CUDA_ALLOC_CONF)=' | sort
146
+ echo
147
+
148
+ echo "[Output dir/perms]"
149
+ OUT="/app/outputs"
150
+ echo "OUT dir: $OUT"
151
+ mkdir -p "$OUT"
152
+ ls -la "$OUT" || true
153
+
154
+ echo "================= END CAPABILITIES ================="
start.sh ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ tree -L 4 /app
5
+ tree -L 4 /data
6
+
7
+ echo "🚀 Iniciando o script de setup e lançamento do LTX-Video..."
8
+ echo "Usuário atual: $(whoami)"
9
+
10
+ # Define as variáveis de ambiente que o LTXServer irá consumir
11
+ export LTX_REPO_DIR="${LTX_REPO_DIR:-/data/LTX-Video}"
12
+ export HF_HOME="${HF_HOME:-/data/.cache/huggingface}"
13
+ export OUTPUT_ROOT="${OUTPUT_ROOT:-/app/outputs/ltx}"
14
+
15
+ # --- Garante que Diretórios Existam ---
16
+ mkdir -p "$OUTPUT_ROOT"
17
+
18
+
19
+ # 1) Builder (garante Apex/Flash e deps CUDA)
20
+ #echo "🛠️ Iniciando o builder.sh para compilar/instalar dependências CUDA..."
21
+ #if [ -f "/app/builder.sh" ]; then
22
+ # /bin/bash /app/builder.sh
23
+ # echo "✅ Builder finalizado."
24
+ #else
25
+ # echo "⚠️ Aviso: builder.sh não encontrado. Pulando etapa de compilação de dependências."
26
+ #fi
27
+
28
+
29
+
30
+ python3 - <<'PY'
31
+ #import os
32
+ #from services.ltx_server import ltx_server_singleton as server
33
+ #try:
34
+ # server.setup_dependencies()
35
+ #except Exception as e:
36
+ # print("Erro no setup")
37
+
38
+
39
+
40
+
41
+ PY
42
+
43
+ cp -r /data/LTX-Video/ltx_video /app/ltx_video
44
+
45
+ export OUTPUT_ROOT="${OUTPUT_ROOT:-/app/outputs}"
46
+ export INPUT_ROOT="${INPUT_ROOT:-/app/inputs}"
47
+
48
+ mkdir -p "$OUTPUT_ROOT" "$INPUT_ROOT"
49
+ echo "[ltx][start] Verificando ambiente como usuário: $(whoami)"
50
+
51
+ # Env da UI
52
+ export GRADIO_SERVER_NAME="0.0.0.0"
53
+ export GRADIO_SERVER_PORT="${PORT:-7860}"
54
+ export GRADIO_ENABLE_QUEUE="True"
55
+
56
+ tree -L 4 /app
57
+ tree -L 4 /data
58
+
59
+
60
+ echo "[ltx][start] Lançando app_ltx.py..."
61
+ # Executa diretamente o python.
62
+ exec python /app/app.py