Modal Runのロゴ

Modal Run

組織人気
ai4s-research
modal-run

Modal(クラウドコンピューティングプラットフォーム)で大規模な処理やGPU処理を実行するようユーザーから依頼された場合に使用します。ワークスペースでModal関数を作成し、ユーザー自身の`modal` CLIとトークンで実行して、結果を戻します。Slurmクラスターを使わずに、ノートPCでは大きすぎるジョブをデータから計算まで処理します。

Add to TypingMind

概要

公開者ai4s-research
リポジトリopen-science
スキル名modal-run
スター
1.7K
フォーク
201
同梱ファイル
1
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 1個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    ai4s-researchがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Modal Run」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/ai4s-research/open-science/tree/master/runtime/skills/core/modal-run
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ai4s-research/open-science.git /tmp/open-science
mkdir -p .claude/skills
cp -r /tmp/open-science/runtime/skills/core/modal-run .claude/skills/modal-run
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでModal Runを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にModal Runを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Modal Runは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Run compute on Modal

Modal runs code in the cloud on demand (CPU/GPU), billed to the user's own Modal account. Like the HPC/Slurm path, the app never handles credentials — you use the user's installed modal CLI and their token. Prefer local execution or Slurm first; reach for Modal when the job needs cloud GPUs or elastic scale and no cluster is available.

1 · Check Modal is ready

Modal must be installed and authenticated (the Settings Cloud compute (Modal) card shows this). Verify before writing code:

bash
modal --version          # installed?
test -f ~/.modal.toml && echo "authenticated" || echo "run: modal token new"

If it is not installed, tell the user to pip install modal; if not authenticated, ask them to run modal token new in their terminal (it opens a browser). Do not attempt to create or store tokens yourself.

2 · Write the Modal function into the workspace

Put the script in the workspace so provenance records it. Pin dependencies in the image so the run is reproducible, and fix any random seed.

python
# compute.py — run with:  modal run compute.py
import modal

app = modal.App("open-science-job")
image = modal.Image.debian_slim().pip_install("numpy==1.26.4", "scipy==1.13.1")

@app.function(image=image, gpu=None, timeout=1800)  # set gpu="A10G" etc. if needed
def run(n: int = 1_000_000):
    import numpy as np
    rng = np.random.default_rng(0)          # fixed seed → reproducible
    x = rng.standard_normal(n)
    return {"n": n, "mean": float(x.mean()), "std": float(x.std())}

@app.local_entrypoint()
def main():
    result = run.remote()
    print(result)                            # printed locally; capture it below

3 · Run it and capture the result

modal run executes remotely and streams logs + the local entrypoint's stdout back. Write the result into a fresh, immutable result directory so it becomes a traceable artifact and does not overwrite a previous run:

bash
RESULT=results/<job-name>/<YYYYmmdd-HHMMSS>
mkdir -p "$RESULT"
modal run compute.py | tee "$RESULT"/modal_result.txt

For large outputs, have the function write to a Modal Volume and download with modal volume get, rather than returning big objects. Download every run into its own RESULT directory; never reuse a recorded output path.

4 · Record the run (reproducibility) — REQUIRED, every time

Modal runs on remote cloud hardware the app can't see, so this call is the ONLY thing that makes the run exist in Runs. Do it after every completed run — including quick re-runs. Skipping it loses the run entirely (it shows in neither the global Runs view nor the session). Record it after it completes (from the workspace root):

Record it completely: --code once per script that ran, and --output once per file you captured or downloaded (the streamed result and any modal volume get files) — not just the summary. Output paths must be under the fresh RESULT directory; the helper refuses to record paths used by earlier runs.

bash
python "$XDG_CONFIG_HOME/opencode/skills/modal-run/record_run.py" \
  --surface modal --command "modal run compute.py" \
  --status <ok|failed> --host "modal:<app-name>" \
  --hardware "<the gpu= from @app.function, e.g. A10G — or 'CPU'>" \
  --code compute.py --output "$RESULT"/modal_result.txt \
  --output "$RESULT"/<each downloaded file> \
  --session-id "$(cat .openscience/session.txt 2>/dev/null)"

--session-id attaches the run to this session (empty-safe if the marker's absent).

The environment is reproduced by the modal.Image definition in compute.py (pinned pip_install + base image — already versioned in the workspace), so record the GPU/hardware string, not a package list, and no --env-file is needed. Use --status failed if the run errored.

Rules

  • User's account only. Never handle, print, or store Modal tokens.
  • Reproducible. Pin image packages and fix seeds; record the script + result in the workspace (provenance captures them).
  • Cost-aware. Modal bills the user — keep timeout bounded, don't request a GPU unless the work needs one, and say what you're about to run before a large job.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Modal Run」では何ができますか?

Modal(クラウドコンピューティングプラットフォーム)で大規模な処理やGPU処理を実行するようユーザーから依頼された場合に使用します。ワークスペースでModal関数を作成し、ユーザー自身の`modal` CLIとトークンで実行して、結果を戻します。Slurmクラスターを使わずに、ノートPCでは大きすぎるジョブをデータから計算まで処理します。

TypingMindでModal Runを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Modal Runはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにModal Runをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/ai4s-research/open-science/tree/master/runtime/skills/core/modal-runを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Modal Runを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Modal Runで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもModal Runを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Modal Run」は無料ですか?

ai4s-researchがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇