[BUG] Duplicate `ATag` error during sharing recovery with parallel GC
まだ誰も着手していません。
評価
調査の方向性
The bug is in Data.Array.Accelerate.Trafo.Sharing (Sharing.hs); start at internalError (line 2243) and buildInitialEnvAcc (line 2623). Read sharing recovery near line 3084 and reproduce with given Main.hs via ghc -O1 -threaded -rtsopts -package accelerate then ./repro +RTS -A64k -RTS. Done when 1000 conversions succeed without duplicate ATag errors under parallel GC.
索引モデルが issue の本文から書いたものです。
説明
Environment
- Accelerate 1.4.0.0
- GHC 9.8.4 / base 4.19.2.0
- Linux x86_64
Reproducing
Main.hs:
module Main where
import Control.Exception (evaluate)
import Control.Monad (forM_, when)
import qualified Data.Array.Accelerate as A
import qualified Data.Array.Accelerate.Trafo.Sharing as Sharing
import GHC.Conc (setNumCapabilities)
stage :: Int -> A.Acc (A.Vector Double) -> A.Acc (A.Vector Double)
stage n input = foldl1 (A.zipWith (+)) [A.map (\x -> x + A.constant (fromIntegral (n + i))) input | i <- [1 .. 8 :: Int]]
program :: Int -> A.Acc (A.Vector Double) -> A.Acc (A.Vector Double)
program n input = foldl (\x f -> f x) input (replicate 40 (stage n A.>-> stage (n + 1)))
main :: IO ()
main = do
setNumCapabilities 8
forM_ [1 .. 1000 :: Int] $ \n -> do
_ <- evaluate (length (show (Sharing.convertAfun (program n))))
when (n `mod` 100 == 0) (print n)
With Accelerate installed and available to GHC:
ghc -O1 -threaded -rtsopts -package accelerate Main.hs -o repro
./repro +RTS -A64k -RTS
Expected behavior
All 1000 graph conversions complete successfully.
Actual behavior
Sharing recovery fails with an internal error:
Encountered duplicate 'ATag's
3116: Atag 1, 3100: Atag 1
CallStack (from HasCallStack):
internalError: Data.Array.Accelerate.Trafo.Sharing:2243:19
buildInitialEnvAcc: Data.Array.Accelerate.Trafo.Sharing:2623:48
scopesAfun1: Data.Array.Accelerate.Trafo.Sharing:2346:62
The failing iteration varies between runs.
Disabling parallel GC for the same executable:
./repro +RTS -A64k -qg -RTS
I tested five runs in each mode using the same executable, alternating between the two modes:
| GC mode | Runs | Duplicate ATag failures | Successful runs |
|---|---|---|---|
| Parallel GC | 5 | 3 | 2 |
Parallel GC disabled (-qg) |
5 | 0 | 5 |
All five runs with -qg completed 1000 conversions each: 5000 conversions with no errors. In the parallel-GC runs, two failures occurred after the progress message 400; another occurred before the first progress message (100).
Suspected cause
Sharing recovery requires physically shared Atag nodes, as described in Sharing.hs.
GHC's parallel copying GC can duplicate immutable constructors through copy_tag_nolock.
This suggests that physical copies of the same tag receive different stable names and
are subsequently rejected as duplicate tags during sharing recovery.
Discussion
Would it be feasible to fix this by identifying bound variables independently of physical sharing,
or by handling duplicated tags during environment construction?
I’d be happy to try working on a fix with some guidance.
I’m not very familiar with de Bruijn indices or the sharing recovery implementation,
and much of the investigation above was carried out with assistance from LLM,
however, I would like to extend my knowledge in this pretty interesting subject,
so I’d appreciate a review of the diagnosis and advice on where to start.
- 主要言語
- Haskell
- スター
- 1k
- フォーク
- 138
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AccelerateHS/accelerate のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
AccelerateHS/accelerate#429 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
AccelerateHS/accelerate#589 ·
-
難易度 4/5 1〜2日 初心者へのやさしさ 42/100
AccelerateHS/accelerate#586 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
AccelerateHS/accelerate#585 ·
-
good first issue
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
AccelerateHS/accelerate#582 ·
AccelerateHS/accelerate の issue をすべて見る
似ている issue
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
enhancement triage
難易度 1/5 1〜3時間 初心者へのやさしさ 66/100
simplex-chat/simplex-chat#8043 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
haskell-servant/servant#1929 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
fmidue/haskell-template-task#77 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
haskell/network-uri#92 ·