You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
PyTorch is dead. Long live JAX.The future of Deep Learning frameworks July 19, 2024 · 24 min read Assumed audience: ML researchers who frequently work with PyTorch, but are interested in trying out JAX or have yet to be convinced. IntroductionUsually, people start these ‘critiques’ with a disclaimer that they are not trying to trash the framework, and talk about how it’s a tradeoff. However, this
ただし、PyTorchさん、あなたはダメです。直接読み込めません👻 今回のサンプルは、Google Colaboratory上でお試しします。 いつの間にか、Colaboratory上でのOpenVINOインストール・実行も簡単になってて、助かります。 個人的には、PaddlePaddleの重みを直接読み込めるのが良い感じです。 ノートブックは以下のリポジトリで公開しています。 試してみたい方は「Open in Colab」からノートブックを開いて、上から順に実行していってください。 以降は処理の簡単な説明です。 パッケージインストール OpenVINOのインストールです。 今回のサンプルを動かすだけであれば、pipインストール1行で済みます。
In theory, Attention is All You Need. In practice, however, we also need optimized attention implementations like FlashAttention. Although these fused attention implementations have substantially improved performance and enabled long contexts, this efficiency has come with a loss of flexibility. You can no longer try out a new attention variant by writing a few PyTorch operators - you often need t
PyTorch 2.4におけるベータ版としては、torch.compile()におけるPython 3.12を使用したモデル最適化への対応や、CPUでAOTInductorを使用する際にフリーズフラグをオンにできるようになり、AOTInductorでInductor CPPバックエンドと同じオペレーションシナリオセットをカバーして、同等のパフォーマンスの実現を可能にする機能が追加されている。 あわせて、Pythonの組み込み演算子のように動作するカスタム演算子を使用して、PyTorchを拡張することが容易になる高レベルPythonカスタム演算子APIの追加や、初期化時間を大幅に短縮してスケーラビリティを向上する、TCPStore用の新たなデフォルトサーババックエンドとなるlibuvの導入が行われた。 プロトタイプ機能としては、dim-0パラメータごとのシャーディングを使用してFSDP1のフ
結論からPyTorchで利用したいCUDAバージョン≦CUDA ToolKitのバージョン≦GPUドライバーの対応CUDAバージョン この条件を満たしていないとPyTorchでCUDAが利用できません。 どうしてもtorch.cuda.is_available()の結果がTrueにならない人を対象に、以下確認すべき項目を詳しく説明します。 1. CUDA有効バージョンのPyTorchをインストールしましたか?単純にpip3 install torchを実行するとCUDA無効(CPU有効)のPyTorchがインストールされます。CUDA有効のPyTorchをインストールするためには、https://pytorch.org/get-started/locally/ こちらからRun this Commandをコピペしてコマンドラインに貼り付けてインストールする必要があります。特にPyCharm
はじめに kaggle等でMLPの実装を探すと,kerasのSequentialにDense層やDropout層をaddしまくるような実装をよく見かけます. torch.nn.Moduleを用いた実装では,Linearと活性化関数を2,3個繰り返す実装が多いように思います. これらはMLPの概念に忠実な実装です. しかしMLPの中間層の数を簡単に自由に変更できれば,より柔軟な実装ができるかもしれません. ここで紹介するアイデアはシンプルで誰でも思いつきそうなものですが,レイヤ数が固定の実装ばかり見ていると考え方が固くなってしまい,筆者にとっては新鮮なものであったので記事にしました. Keras (Sequential) 中間層のサイズを指定して,for文でn_layer-2個のDense層とDropout層を追加すれば,可変個数の層を追加できる. from keras.models imp
in-place処理であることを意味します。 はじめに PyTorch関数名の末尾アンダーバー_ 意味 具体例 おわりに 参考 はじめに PyTorchを触っていると、しばしばアンダーバー_を接尾語とする関数を見かけます。 kaiming_normal_ add_ etc... 初見で意味を知らなかったので備忘録メモです。 PyTorch関数名の末尾アンダーバー_ 意味 PyTorch関数名の末尾アンダーバー_は、in-place処理を意味します。 in-place処理とは、元のデータを直接変更する処理のことです。 In-place operations Operations that have a _ suffix are in-place. For example: x.copy_(y), x.t_(), will change x. Ref. Tensors — PyTorch Tu
要約 Windows上のCUDA環境において、Ryeを用いてPyTorchおよびPyG (PyTorch Geometric) のライブラリをインストールすることができた。pyproject.tomlにソースを設定することが必要となる。 Ryeについて RyeはPythonのバージョン管理とライブラリ管理の両方を1つで行えるツール。Rustで内部実装されている。ここではインストール方法には触れない。インストール済みであるとして進める。 Rye CUDA環境の構築 以下が必要となる。 NVIDIAディスプレイドライバーのインストール NVIDIA CUDA Toolkit のインストール NVIDIA cuDNN のインストール この3つは組み合わせの相性があり、以下のページでサポートされている組み合わせが記載されている。 Support Matrix ここでは、最新のドライバーと CUDA
I am excited to be back at Build with the developer community this year. Over the last year, we have worked on reimagining Windows PCs and yesterday, we introduced the world to a new category of Windows PCs called Copilot+ PCs. Copilot+ PCs are the fastest, most intelligent Windows PCs ever with AI infused at every layer, starting with the world’s most powerful PC Neural Processing Units (NPUs) c
This repository contains an efficient implementation of Kolmogorov-Arnold Network (KAN). The original implementation of KAN is available here. The performance issue of the original implementation is mostly because it needs to expand all intermediate variables to perform the different activation functions. For a layer with in_features input and out_features output, the original implementation needs
PyTorch の社内勉強会の題材にしたいと思い立ち、畳み込みニューラルネットワーク(Convolutional Neural Network, CNN)を用いた自己対戦型強化学習の三目並べ AI を実装したので公開します。見通しの良いシンプルな実装を目指しました。結局、それなりのコード量になってしまいましたが。 動作環境 Google Colaboratory の CPUランタイムにて動作を確認しました。 概略 おおまかな処理フローは次図の通りです。盤面情報を受け取った先攻方策と後攻方策は、○×を書き込む場所を返します。この先攻方策と後攻方策に AI を実装し自己対戦させます。 盤面情報は、空白マスをゼロ、先攻 ○ を+1、後攻 × を-1とした形状 (H,W)=(3,3) の二次元配列とします。 盤面座標は、場合により二次元座標と1次元に展開したフラット座標を使い分けます。 三目並べの
KorniaはバックエンドにPyTorchを使用したコンピュータービジョンライブラリで、古典的なコンピュータービジョンの処理を微分可能にして昨今のディープラーニングモデルに統合するためのPython向けライブラリ。 Korniaは、PyTorch用の微分可能なコンピュータービジョンライブラリです。 Korniaは、コンピュータービジョンの一般的な問題を解決するための一連のルーチンと、微分可能なモジュールで構成されています。このパッケージのコアではメインのバックエンドとしてPyTorchを使用して効率性を高め、複雑な関数の勾配の定義・計算にReverse-Modeの自動微分を利用しています。 概要 このライブラリは既存のパッケージからインスピレーションを得ており、モデルの訓練時にニューラルネットワーク内に挿入できるオペレーター(画像変換、エピポーラ幾何学、深度推定、テンソル上で直接動作するフ
by Team PyTorch We’re pleased to announce the alpha release of torchtune, a PyTorch-native library for easily fine-tuning large language models. Staying true to PyTorch’s design principles, torchtune provides composable and modular building blocks along with easy-to-extend training recipes to fine-tune popular LLMs on a variety of consumer-grade and professional GPUs. torchtune supports the full f
1. はじめに 2012年から始まった深層学習の発展の過程で、さまざまな学習フレームワークが登場しました。中でもPyTorchとTensorflowは最も広く使われており、それぞれのフレームワークが支持されている背景には、柔軟性、拡張性、そして使いやすさがあります。 一方で、これらのフレームワークはその機能を拡張し続けてきた結果として、全体として非常に巨大で複雑なライブラリになっています。そのため、独自に機能拡張を行いたいユーザーにとっては扱いづらく、性能的にもオーバーヘッドを感じさせることがあります。 そこで新たに出てきたのが「JAX」とその関連ライブラリの組み合わせになります。2019年に登場して以降、特に海外の開発者に支持されてきました。近年注目されている大規模言語モデル(LLM)の分野においても、JAXによるモデルが公開されていることは珍しくなくなりつつあります。 PyTorch(
PyTorch v1.12 以降では、macOS において Apple Silicon あるいは AMD の GPU を使ったアクセラレーションが可能になっているらしい。 バックエンドの名称は Metal Performance Shaders (MPS) という。 意外と簡単に使えるようなので、今回は手元の Mac で試してみた。 使った環境は次のとおり。 GPU が 19 コアの Apple M2 Pro を積んだ Mac mini を使用している。 $ sw_vers ProductName: macOS ProductVersion: 14.4.1 BuildVersion: 23E224 $ sysctl machdep.cpu.brand_string machdep.cpu.brand_string: Apple M2 Pro $ pip list | grep -i tor
Quantization is a technique to reduce the computational and memory costs of evaluating Deep Learning Models by representing their weights and activations with low-precision data types like 8-bit integer (int8) instead of the usual 32-bit floating point (float32). Reducing the number of bits means the resulting model requires less memory storage, which is crucial for deploying Large Language Models
Modular社がAI処理を高速化するプラットフォーム「MAX」をプレビュー公開。PyTorchやTensorFlow、ONNXなどのAIモデルと入れ替えるだけで処理が最大5倍高速になる。 Pythonの高速なスーパーセット「Mojo」言語を発表したことで話題となったModular社が、AI処理を高速化するプラットフォーム「MAX」(Modular Accelerated Xecution)のデベロッパーエディションをブレビュー公開しました。 MAX Developer Edition Preview has officially launched! It's a drop-in replacement for running and serving @PyTorch, @tensorflow and @onnxai models much faster and leverages the
dlshogiの学習は、PyTorchを使用して、モデルの訓練処理を独自に実装していた。 マルチGPUによる分散学習に対応させようと考えているが、独自に実装するより、PyTorch lightningに対応させた方が実装が楽になるため、dlshogiをPyTorch Lightningに対応させたいと考えている。 まずは、訓練の基本部分の実装を行った。 PyTorch Lightning CLI ボイラープレートをできるだけ削除するため、PyTorch Lightning CLIを使用して実装する。 PyTorch Lightning CLIを使用すると、コマンド引数のパース処理など含めて自動で行ってくれる。 起動部分の処理は以下のように記述するだけでよい。 def main(): LightningCLI(Model, DataModule) if __name__ == "__main
この投稿はrioyokotalab Advent Calendar 2020 21日目の投稿です。 adventar.org サウンド系の機械学習 PyTorchを使ってなにかするとなると、なぜか多くの人は画像をどうにかしようとしがちな気がします。特にブログとかでやってみた的な記事だとその傾向が強いと思います。確かにインパクトはありますし...。 画像処理はやり尽くされている感はありますが、音声系って意外とやられていない要素が多いように思います。もし、PyTorchで音声に関する機械学習を行いたいのであれば、この記事が参考になればと思います。 サウンド系機械学習のスタンダードな実装 音声というのは波情報です。それをそのまま1次元CNNにかけるというのでもいいのですが、波情報のままだと、情報が冗長すぎます。なので、基本的にはスペクトログラム1と呼ばれる、二次元情報に変換し、それを画像処理ベー
Segmentation Models Pytorch の バックボーン(Backbone) を設定したいように変更する時の方法と注意点 はじめに ディープラーニングのための自動微分をしてくれる PyTroch において、セグメンテーションのタスクのモデルを簡単に提供してくれるのが Segmentation Models Pytorchです。 モデル作成の初学者から Kaggle などのコンペ、業務でも仕様できるくらい便利なライブラリーです。 もう既にバックボーンとなるエンコーダーは自由に選べるほど豊富にあります。 しかしながら、最新のモデルや3Dカスタムなどをする時に簡単にカスタムする方法がわからなかったので備忘録のつもりで例を記載しております。 実装 Python 実装を記載します。 基本のおさらい import segmentation_models_pytorch as smp m
目的 ローカルLLMの推論速度を改善する手法がいくつか報告されています。 今回は実際に報告されている5つの手法を実装して推論速度がどの程度改善するか確認します。 推論処理の高速化手法 1. torch.compile 計算グラフを構築 各演算をCPUやGPUのデバイスに特化した細かい命令に分解 与えられた入力に対して上記の命令を呼び出して演算を効率化 実装 モデルを読み込んだ直後にtorch.compileを追加 model = AutoModelForCausalLM.from_pretrained( model_name, device_map="cuda", trust_remote_code=True, torch_dtype=torch.bfloat16, load_in_8bit=False, load_in_4bit=False, use_cache=False, ).eva
アドベントカレンダー「ほぼ横浜の民」の11日目の記事です。 今年は LLM の高速化実装について書いています。私はLLMの専門家ではないですが前々から興味があったので少し勉強してみました。 この記事を読んでわかること LLMが文章を生成する仕組み torch.compile によって LLM はどのように高速化されるのか? Speculative Decoding とは? 背景 少し前に Accelerating Generative AI with Pytorch II: GPT, Fast という素晴らしいブログ記事を見かけました。この記事は Pytorch チームから出されたもので、素の Pytorch のみを用いて LLM の推論を 10 倍高速化できるというものでした。一体どのように 10 倍もの高速化を実現しているのか気になったので、個人的な勉強も兼ねてこの記事を書いています。
人気ライブラリPyTorchに見つかったサプライチェーン攻撃の詳細 PyTorchは、MetaのAI(人工知能)リサーチグループによって開発されたライブラリで、GPUをサポートしたテンソル演算や深層学習トレーニング、Open Neural Network Exchange(ONNX)へのエクスポート機能、自動微分機能、自動ベクトル化などの特徴を備える。多くの深層学習ソフトウェアがPyTorchをベースに構築されており、さまざまな企業やプロジェクトによって使われている。 スタウィンスキー氏によると、PyTorchの「継続的インテグレーション/継続的デリバリー」(CI/CD)プロセス内の脆弱性と「GitHub」のデプロイシステム「セルフホステッドランナー」を悪用することで、PyTorchリポジトリに対する広範なアクセス権を獲得し、悪意あるコードのアップロードやリポジトリの秘密情報の窃取が可能に
StreamDiffusionってなに?めちゃくちゃ速い画像生成ができるやつです。 いくつか機能が用意されていて、text2img、img2img、画面キャプチャからの画像生成、vid2vidができます。 個人的にvid2vidが激ヤバで感動しました。 リアルタイムAIお絵描き(?)も高fpsでできちゃう・・・ 下のリンクからでも動画が見れるので見てない人は見て欲しい。すごい。 (https://x.com/IMG_5955/status/1731971307732918532?s=20) (https://x.com/cumulo_autumn/status/1732309219041571163?s=20) (https://x.com/cumulo_autumn/status/1728768642052182231?s=20) インストールするよはやく遊びたいのでインストールします。
PyTorchで1枚の画像を複数の小さい画像(パッチ)に切り出す方法を紹介します。TensorFlowだとtf.image.extract_patchesにあたる処理です。 torch.Tensor.unfold torch.Tensor.unfoldという関数を使います。 unfold(dimension, size, step) → Tensor という形式で、順番にパッチを切り出す次元、パッチサイズ、パッチを切り出す間隔ですね。次元は縦と横で取ればいいので画像の4階テンソルなら2,3で取れば良いでしょう。 コード この画像を「cat.jpg」とします。 128px × 128pxのパッチで、64px間隔に取り出すものとします。 import torch import torchvision from PIL import Image import numpy as np # テンソル
Kaggle Advent Calendar 3日目の記事です。 今回はKaggleなどのコンペで Metric Learning を試すときにとりあえず最初に実装するコードをまとめました。 UMAPを使ったembeddingの可視化とか faiss を使った検索とかはこの記事で扱ってないです。 1. Metric Learning って何? 予測値じゃなくて特徴量間の距離に注目して学習する方法 同じクラス内ではなるべく近い距離になるように 違うクラス間ではなるべく遠い距離になるように もっと詳しくしたい人は Qiita 内でもいい記事たくさんあるのでどうぞ。 モダンな深層距離学習 (deep metric learning) 手法: SphereFace, CosFace, ArcFace #DeepLearning - Qiita Softmax関数をベースにした Deep Metri
by Team PyTorch This post is the first part of a multi-series blog focused on how to accelerate generative AI models with pure, native PyTorch. We are excited to share a breadth of newly released PyTorch performance features alongside practical examples of how these features can be combined to see how far we can push PyTorch native performance. As announced during the PyTorch Developer Conference
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く