Logo di Cuda Streams

Cuda Streams

OrganizzazionePopolare
pytorch
cuda-streams

Manage tensor lifetimes across CUDA streams and decide whether record_stream is avoidable. Use when using a tensor on a stream other than the one it was allocated on, adding or reviewing Tensor.record_stream / CUDACachingAllocator::recordStream, side streams, wait_stream, or CUDA events for cross-stream ordering, or designing APIs that hand side-stream tensors to callers.

Panoramica

Autorepytorch
Repositorypytorch
Nome della skillcuda-streams
Stelle
104.6K
Fork
32.1K
File inclusi
Solo istruzioni
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da pytorch su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Cuda Streams in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/pytorch/pytorch/tree/main/.agents/skills/cuda-streams
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/pytorch/pytorch.git /tmp/pytorch
mkdir -p .claude/skills
cp -r /tmp/pytorch/.agents/skills/cuda-streams .claude/skills/cuda-streams
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Cuda Streams in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Cuda Streams non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Cuda Streams non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

CUDA Streams and record_stream

The caching allocator only reuses a block on the stream that allocated it. If a tensor is used on some other stream, then before it is freed you need either (a) a sync from that stream back to the creation stream (an event, or creation_stream.wait_stream(side_stream)), or (b) record_stream() / CUDACachingAllocator::recordStream(). (a) is deterministic. (b) is not: on later allocations the allocator polls the recorded streams, so whether memory gets reused depends on how far the GPU has gotten, and memory usage can blow up when the CPU runs ahead. Prefer (a) where possible.

When writing or reviewing code that needs one of these, work out which of the following cases applies:

  • Avoidable: the code doing the cross-stream use also controls when the tensor is freed, or can hold a reference until a point it controls. Record an event after the last side-stream use and make the creation stream wait on it before dropping the reference. Don't use record_stream. FSDP2 works this way (see docs/source/distributed.fsdp.fully_shard.md).
  • Unavoidable under the current API: the tensor goes to arbitrary user code, which frees it at an unknown time, and nothing we control runs in between where we could insert the sync. Here record_stream is the correct tool and shouldn't be flagged.
  • But we design the APIs. If the API is new or can still change, ask whether a different shape would give us a point to sync. Examples: return a handle whose wait() does the sync and releases internal references; allocate outputs on the caller's stream and sync the side stream back before returning; keep ownership of buffers internally. c10d shows both sides: collectives keep their tensors alive in the Work object until wait() syncs the streams, with no recordStream, but isend doesn't require wait(), so it falls back to recordStream (see ProcessGroupNCCL.cpp). Weigh the design cost against the determinism benefit, and point out the option rather than insisting on it.
  • Hard to avoid: sometimes avoiding it would take a redesign. For example, the autograd engine moves gradients between nodes whose streams come from the forward pass (torch/csrc/autograd/input_buffer.cpp). The engine has the graph and could delay frees to a point where it syncs, but arbitrary user hooks can see and hold on to gradients, so it doesn't know when the last use happens. Don't treat such cases as settled: say what information is missing for a sync point and what it would take to get it.

When record_stream is the right call, leave a comment explaining why the free point can't be controlled. See also the record_stream docstring in torch/_tensor_docs.py.

Domande frequenti

Cosa fa la skill IA Cuda Streams?

Manage tensor lifetimes across CUDA streams and decide whether record_stream is avoidable. Use when using a tensor on a stream other than the one it was allocated on, adding or reviewing Tensor.record_stream / CUDACachingAllocator::recordStream, side streams, wait_stream, or CUDA events for cross-stream ordering, or designing APIs that hand side-stream tensors to callers.

Perché usare Cuda Streams su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Cuda Streams è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Cuda Streams in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/pytorch/pytorch/tree/main/.agents/skills/cuda-streams. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Cuda Streams?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Cuda Streams?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Cuda Streams: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Cuda Streams è gratuita?

È pubblicata su GitHub da pytorch. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇