Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when building HLG with large language model #132

Open
drawfish opened this issue Nov 26, 2021 · 11 comments
Open

Exception when building HLG with large language model #132

drawfish opened this issue Nov 26, 2021 · 11 comments

Comments

@drawfish
Copy link

It seems that overflow occurs when building HLG on large language model.
The apra language model info:

\data\
ngram 1=136920
ngram 2=30620323
ngram 3=58191282
ngram 4=63623739

After successfully detrminize(compose(L,G)) , an exception occurs when remove_epsilon from LG.
From the exception traceback we can see that something like overflow when cating impl_->byte_offset into int64_t ?

2021-11-25 16:23:09,208 INFO [compile_hlg.py:173] Processing data/lang_phone
2021-11-25 16:23:09,479 INFO [lexicon.py:177] Loading pre-compiled data/lang_phone/Linv.pt
2021-11-25 16:23:09,900 INFO [compile_hlg.py:79] Building ctc_topo. max_token_id: 218
2021-11-25 16:23:09,911 INFO [compile_hlg.py:86] Loading L_disambig.fst.txt
2021-11-25 16:23:12,274 INFO [compile_hlg.py:91] Loading G.fst.txt
2021-11-25 16:34:12,174 INFO [compile_hlg.py:110] Intersecting L and G
2021-11-25 17:04:55,417 INFO [compile_hlg.py:112] LG shape: (552371407, None)
2021-11-25 17:04:55,417 INFO [compile_hlg.py:114] Connecting LG
2021-11-25 17:04:55,417 INFO [compile_hlg.py:116] LG shape after k2.connect: (552371407, None)
2021-11-25 17:04:55,418 INFO [compile_hlg.py:118] <class 'torch.Tensor'>
2021-11-25 17:04:55,418 INFO [compile_hlg.py:119] Determinizing LG
2021-11-25 17:51:51,788 INFO [compile_hlg.py:122] <class '_k2.ragged.RaggedTensor'>
2021-11-25 17:51:51,788 INFO [compile_hlg.py:124] Connecting LG after k2.determinize
2021-11-25 17:51:51,788 INFO [compile_hlg.py:127] Removing disambiguation symbols on LG
[F]/k2/k2/k2/csrc/tensor.cu:159:k2::Tensor::Tensor(k2::Dtype, const k2::Shape&, k2::RegionPtr, int32_t) Check failed: int64_t(impl_->byte_offset) + begin_elem * element_size >= 0 (-156
3030948 vs. 0) impl_->byte_offset: -1563030948, begin_elem: 0, element_size: 4


[ Stack-Trace: ]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2_log.so(k2::internal::GetStackTrace()+0x4f) [0x7f57d74b67af]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::Tensor::Tensor(k2::Dtype, k2::Shape const&, std::share
d_ptr<k2::Region>, int)+0x91a) [0x7f57d7a2f50a]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::Array2<int>::Col(int)+0x13a) [0x7f57d79d9dea]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(+0x29f869) [0x7f57d79cd869]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::Index(k2::RaggedShape&, int, k2::Array1<int> const&, k
2::Array1<int>*)+0x1da) [0x7f57d79cfc2a]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(+0x2e6655) [0x7f57d7a14655]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::ComputeEpsilonClosureOneIter(k2::Ragged<k2::Arc>&, k2:
:Ragged<k2::Arc>*, k2::Ragged<int>*)+0xdc8) [0x7f57d7a19a38]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::ComputeEpsilonClosure(k2::Ragged<k2::Arc>&, k2::Ragged
<k2::Arc>*, k2::Ragged<int>*)+0x109) [0x7f57d7a1aac9]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::RemoveEpsilonDevice(k2::Ragged<k2::Arc>&, k2::Ragged<k
2::Arc>*, k2::Ragged<int>*)+0x269) [0x7f57d7a1c3f9]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/libk2context.so(k2::RemoveEpsilonDevice(k2::Ragged<k2::Arc>&, k2::Ragged<k
2::Arc>*, k2::Ragged<int>*)+0x1949) [0x7f57d7a1dad9]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/_k2.cpython-38-x86_64-linux-gnu.so(+0x76141) [0x7f57d8bb1141]
/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/_k2.cpython-38-x86_64-linux-gnu.so(+0x25273) [0x7f57d8b60273]
python3(PyCFunction_Call+0x54) [0x5585214a2c64]
python3(_PyObject_MakeTpCall+0x31e) [0x5585214ac94e]
python3(_PyEval_EvalFrameDefault+0x540f) [0x55852153cf0f]
python3(_PyFunction_Vectorcall+0x1a6) [0x55852151cc46]
python3(_PyEval_EvalFrameDefault+0x4dd3) [0x55852153c8d3]
python3(_PyEval_EvalCodeWithName+0x2c3) [0x55852151ba33]
python3(_PyFunction_Vectorcall+0x378) [0x55852151ce18]
python3(_PyEval_EvalFrameDefault+0x947) [0x558521538447]
python3(_PyFunction_Vectorcall+0x1a6) [0x55852151cc46]
python3(_PyEval_EvalFrameDefault+0x947) [0x558521538447]
python3(_PyEval_EvalCodeWithName+0x2c3) [0x55852151ba33]
python3(PyEval_EvalCodeEx+0x39) [0x55852151ca99]
python3(PyEval_EvalCode+0x1b) [0x5585215c51db]
python3(+0x24f273) [0x5585215c5273]
python3(+0x26cea3) [0x5585215e2ea3]
python3(+0x272582) [0x5585215e8582]
python3(PyRun_SimpleFileExFlags+0x1b2) [0x5585215e8762]                                                                                                                                            [54/370833]
python3(Py_RunMain+0x36d) [0x5585215e8cdd]
python3(Py_BytesMain+0x39) [0x5585215e8e99]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f58b1835840]
python3(+0x1dcd1d) [0x558521552d1d]

Traceback (most recent call last):
  File "./local/compile_hlg.py", line 187, in <module>
    main()
  File "./local/compile_hlg.py", line 175, in main
    HLG = compile_HLG(lang_dir, lm_dir, args.oov)
  File "./local/compile_hlg.py", line 137, in compile_HLG
    LG = k2.remove_epsilon(LG)
  File "/miniconda3/envs/k2/lib/python3.8/site-packages/k2-1.10.dev20211111+cuda11.0.torch1.7.1-py3.8-linux-x86_64.egg/k2/fsa_algo.py", line 554, in remove_epsilon
    ragged_arc, arc_map = _k2.remove_epsilon(fsa.arcs, fsa.properties)
RuntimeError:
    Some bad things happened. Please read the above error messages and stack
    trace. If you are using Python, the following command may be helpful:

      gdb --args python /path/to/your/code.py

    (You can use `gdb` to debug the code. Please consider compiling
    a debug version of k2.).

    If you are unable to fix it, please open an issue at:

      https://github.com/k2-fsa/k2/issues/new

The code for compile HLG:

def compile_HLG(lang_dir: str,
                lm_dir: str,
                oov: str = "<UNK>") -> k2.Fsa:
    lexicon = Lexicon(lang_dir)
    max_token_id = max(lexicon.tokens)
    logging.info(f"Building ctc_topo. max_token_id: {max_token_id}")
    H = k2.ctc_topo(max_token_id, modified=False)
    
    if Path(lang_dir / "L_disambig.pt").is_file():
        logging.info("Loading L_disambig")
        L = k2.Fsa.from_dict(torch.load(f"{lang_dir}/L_disambig.pt"))
    else:
        logging.info("Loading L_disambig.fst.txt")
        with open(lang_dir / "L_disambig.fst.txt") as f:
            L = k2.Fsa.from_openfst(f.read(), acceptor=False)
            torch.save(L.as_dict(), f"{lang_dir}/L_disambig.pt")

    logging.info("Loading G.fst.txt")
    with open(lm_dir / "G_4gram.kndiscount.fst") as f:
        G = k2.Fsa.from_openfst(f.read(), acceptor=False)

    first_token_disambig_id = lexicon.token_table["#0"]
    first_word_disambig_id = lexicon.word_table["#0"]

    # remove oov word symbol.
    #if isinstance(G.aux_labels, k2.RaggedTensor):
    #    G.aux_labels.values[G.aux_labels.values == lexicon.word_table[oov]] = 0
    #else:
    #    G.aux_labels[G.aux_labels == lexicon.word_table[oov]] = 0
    #G.__dict__["_properties"] = None

    L = k2.arc_sort(L)
    G = k2.arc_sort(G)

    #G = k2.determinize(G)

    logging.info("Intersecting L and G")
    LG = k2.compose(L, G)
    logging.info(f"LG shape: {LG.shape}")

    logging.info("Connecting LG")
    LG = k2.connect(LG)
    logging.info(f"LG shape after k2.connect: {LG.shape}")

    logging.info(type(LG.aux_labels))
    logging.info("Determinizing LG")

    LG = k2.determinize(LG)
    logging.info(type(LG.aux_labels))

    logging.info("Connecting LG after k2.determinize")
    LG = k2.connect(LG)

    logging.info("Removing disambiguation symbols on LG")

    LG.labels[LG.labels >= first_token_disambig_id] = 0
     # See https://github.com/k2-fsa/k2/issues/874
    # for why we need to set LG.properties to None
    LG.__dict__["_properties"] = None

    assert isinstance(LG.aux_labels, k2.RaggedTensor)
    LG.aux_labels.values[LG.aux_labels.values >= first_word_disambig_id] = 0

    LG = k2.remove_epsilon(LG)
    logging.info(f"LG shape after k2.remove_epsilon: {LG.shape}")

    LG = k2.connect(LG)
    LG.aux_labels = LG.aux_labels.remove_values_eq(0)

    logging.info("Arc sorting LG")
    LG = k2.arc_sort(LG)

    logging.info("Composing H and LG")
    # CAUTION: The name of the inner_labels is fixed
    # to `tokens`. If you want to change it, please
    # also change other places in icefall that are using
    # it.

    HLG = k2.compose(H, LG, inner_labels="tokens")

    logging.info("Connecting HLG")
    HLG = k2.connect(HLG)

    logging.info("Arc sorting HLG")
    HLG = k2.arc_sort(HLG)
    logging.info(f"HLG.shape: {HLG.shape}")

    return HLG
@drawfish drawfish changed the title Exception when building HLG on large language model Exception when building HLG with large language model Nov 26, 2021
@danpovey
Copy link
Collaborator

Debugging this will require getting it in gdb and looking at the symbols on the stack. We need to trace back where the negative number came from.
Would you mind doing that?
Compiling a debug version of the code might help, but I'm not sure whether it is necessary.

@drawfish
Copy link
Author

Debugging this will require getting it in gdb and looking at the symbols on the stack. We need to trace back where the negative number came from. Would you mind doing that? Compiling a debug version of the code might help, but I'm not sure whether it is necessary.

OK, I will try.

@drawfish
Copy link
Author

Debugging this will require getting it in gdb and looking at the symbols on the stack. We need to trace back where the negative number came from. Would you mind doing that? Compiling a debug version of the code might help, but I'm not sure whether it is necessary.

Hi Dan,below is the stack info, it seem that the negative part came from the function: ElementSize(), but I don't know how to get the return value of ElementSize() from core dump file.

[Current thread is 1 (Thread 0x7ff1a7b28700 (LWP 19704))]
(gdb) bt 10
#0  0x00007ff1a6a5e438 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ff1a6a6003a in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ff0cc923499 in k2::Tensor::Tensor (this=0x7ffec394d540, type=k2::Dtype::kInt32Dtype, shape=..., region=..., byte_offset=-1163130320) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/tensor.cu:160
#3  0x00007ff0cc8c00f3 in k2::Array2<int>::Col (this=0x7ffec394d6d0, i=782959244) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/array.h:820
#4  0x00007ff0cc8963d6 in k2::IndexAxis0 (src=..., new2old=..., elem_indexes=0x7ffec394dc90) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/ragged_ops.cu:437
#5  0x00007ff0cc8970c5 in k2::Index (src=..., axis=0, indexes=..., elem_indexes=0x7ffec394dc90) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/ragged_ops.cu:565
#6  0x00007ff0cdd4262e in k2::Index<int> (src=..., axis=0, indexes=..., value_indexes_out=0x0) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/ragged_ops.h:1206
#7  0x00007ff0cdd982e2 in k2::Index<int> (src=..., indexes=..., remove_axis=false) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/ragged_ops_inl.h:453
#8  0x00007ff0cdd6985f in k2::RaggedAny::Index (this=0x55f3bffddff0, indexes=...) at /cfs/tmax_sata_01/sge/k2/k2/k2/python/csrc/torch/v2/ragged_any.cu:695
#9  0x00007ff0cdd4709f in pybind11::cpp_function::cpp_function<k2::RaggedAny, k2::RaggedAny, k2::RaggedAny&, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, char const*>(k2::RaggedAny (k2::RaggedAny::*)(k2::RaggedAny&), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, char const* const&)::{lambda(k2::RaggedAny*, k2::RaggedAny&)#1}::operator()(k2::RaggedAny*, k2::RaggedAny&) const () at /cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu2/_deps/pybind11-src/include/pybind11/pybind11.h:84
(More stack frames follow...)
(gdb) f 3
#3  0x00007ff0cc8c00f3 in k2::Array2<int>::Col (this=0x7ffec394d6d0, i=782959244) at /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/array.h:820
820         return Tensor(dtype_, shape, region_, byte_offset_ + (ElementSize() * i));
(gdb) l
815         NVTX_RANGE(K2_FUNC);
816         K2_CHECK_LT(static_cast<uint32_t>(i), static_cast<uint32_t>(dim1_));
817         std::vector<int32_t> dims = {dim0_};
818         std::vector<int32_t> strides = {elem_stride0_};
819         Shape shape(dims, strides);
820         return Tensor(dtype_, shape, region_, byte_offset_ + (ElementSize() * i));
821       }
822
823       // Note: const-ness is w.r.t. the metadata only.
824       T *Data() const {
(gdb) p byte_offset_
$1 = 0
(gdb) p i
$2 = 782959244

@danpovey
Copy link
Collaborator

ElementSize() should return 4, as a size_t. (However check that ElementSize() returns size_t in your code, your line numbers are different from mine). That should make a positive product as the 'int' should be promoted to size_t.
I can't find any plausible way that that number should become the byte_offset concerned, in the Tensor.
Are there any other variables, perhaps class members, that you can print out?

@drawfish
Copy link
Author

drawfish commented Nov 27, 2021

ElementSize() should return 4, as a size_t. (However check that ElementSize() returns size_t in your code, your line numbers are different from mine). That should make a positive product as the 'int' should be promoted to size_t. I can't find any plausible way that that number should become the byte_offset concerned, in the Tensor. Are there any other variables, perhaps class members, that you can print out?

In my code, the return type of ElementSize() is int32_t, just the same as the code in k2 master branch here. Either int32_t or size_t is OK.
I think maybe we have found the cause of the problem.
As you said, ElementSize() return 4. Combined with the gdb debug info 'i=782959244, byte_offset_=0', then 'byte_offset_ + (ElementSize() * i) = 0+4*782959244 = 3131836976'.
But the type of the third parameter of the constructor of Tensor class is int32_t (see Tensor(Dtype type, const Shape &shape, RegionPtr region, int32_t byte_offset)) , which range from [-2147483648, 2147483647]. Casting 3131836976 into int32_t will be out of range.
Therefore, in order to solve this problem, do we need to change the parameter type to int64_t or size_t?
In addition, I'm not sure if there are similar problems elsewhere. More debugging may be required.

@danpovey
Copy link
Collaborator

Ah yes, you are right.
It think this issue has been fixed in most places already, but it seems to have somehow stayed in the codebase at this point.
Is there any chance you could make a pull request to fix this/

@drawfish
Copy link
Author

drawfish commented Nov 29, 2021

OK,I will continue to generate the decode graph after modifying my local code to ensure that no other erros occur. If everything goes well, I will make a pull request.

@drawfish
Copy link
Author

After fixing the code above and then rerun the code, another exception occurs:

[F] /cfs/tmax_sata_01/sge/k2/k2/k2/csrc/array_ops.cu:279:void k2::RowSplitsToRowIds(const k2::Array1<int>&, k2::Array1<int>*) Check failed: num_elems == row_splits[num_rows] (158681235 vs. 492176665)


[ Stack-Trace: ]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/libk2_log.so(k2::internal::GetStackTrace()+0x5b) [0x7ff08ae32a64]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/libk2context.so(k2::internal::Logger::~Logger()+0x44) [0x7ff08b2f8768]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/libk2context.so(k2::RowSplitsToRowIds(k2::Array1<int> const&, k2::Array1<int>*)+0x3ac) [0x7ff08b30783d]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/libk2context.so(+0x4305a2) [0x7ff08b4da5a2]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/libk2context.so(k2::Index(k2::RaggedShape&, int, k2::Array1<int> const&, k2::Array1<int>*)+0x1ce) [0x7ff08b4db081]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x21462e) [0x7ff08c98662e]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x26a2e2) [0x7ff08c9dc2e2]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x23b85f) [0x7ff08c9ad85f]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x21909f) [0x7ff08c98b09f]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x22936f) [0x7ff08c99b36f]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x2241b8) [0x7ff08c9961b8]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x21d5ca) [0x7ff08c98f5ca]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x21d6e7) [0x7ff08c98f6e7]
/cfs/tmax_sata_01/sge/k2/k2/build_debug_gpu/lib/_k2.cpython-38-x86_64-linux-gnu.so(+0x83b8a) [0x7ff08c7f5b8a]
python3(PyCFunction_Call+0x54) [0x5611d8b5bc64]
python3(_PyObject_MakeTpCall+0x31e) [0x5611d8b6594e]
python3(+0x1a7b8b) [0x5611d8bd6b8b]
python3(_PyEval_EvalFrameDefault+0x4dd3) [0x5611d8bf58d3]
python3(_PyEval_EvalCodeWithName+0x2c3) [0x5611d8bd4a33]
python3(_PyFunction_Vectorcall+0x378) [0x5611d8bd5e18]
python3(_PyEval_EvalFrameDefault+0x1824) [0x5611d8bf2324]
python3(_PyFunction_Vectorcall+0x1a6) [0x5611d8bd5c46]
python3(_PyEval_EvalFrameDefault+0x4dd3) [0x5611d8bf58d3]
python3(_PyEval_EvalCodeWithName+0x2c3) [0x5611d8bd4a33]
python3(_PyFunction_Vectorcall+0x378) [0x5611d8bd5e18]
python3(_PyEval_EvalFrameDefault+0x947) [0x5611d8bf1447]
python3(_PyFunction_Vectorcall+0x1a6) [0x5611d8bd5c46]
python3(_PyEval_EvalFrameDefault+0x947) [0x5611d8bf1447]
python3(_PyEval_EvalCodeWithName+0x2c3) [0x5611d8bd4a33]
python3(PyEval_EvalCodeEx+0x39) [0x5611d8bd5a99]
python3(PyEval_EvalCode+0x1b) [0x5611d8c7e1db]
python3(+0x24f273) [0x5611d8c7e273]
python3(+0x26cea3) [0x5611d8c9bea3]
python3(+0x272582) [0x5611d8ca1582]
python3(PyRun_SimpleFileExFlags+0x1b2) [0x5611d8ca1762]
python3(Py_RunMain+0x36d) [0x5611d8ca1cdd]
python3(Py_BytesMain+0x39) [0x5611d8ca1e99]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7ff165690840]
python3(+0x1dcd1d) [0x5611d8c0bd1d]

Traceback (most recent call last):
  File "./local/test_hlg.py", line 193, in <module>
    main()
  File "./local/test_hlg.py", line 181, in main
    HLG = compile_HLG(lang_dir, lm_dir, args.oov)
  File "./local/test_hlg.py", line 143, in compile_HLG
    LG = k2.remove_epsilon(LG)
  File "/cfs/tmax_sata_01/sge/k2/k2/k2/python/k2/fsa_algo.py", line 556, in remove_epsilon
    out_fsa = k2.utils.fsa_from_unary_function_ragged(fsa,
  File "/cfs/tmax_sata_01/sge/k2/k2/k2/python/k2/utils.py", line 540, in fsa_from_unary_function_ragged
    new_value = value.index(arc_map)
RuntimeError:
    Some bad things happened. Please read the above error messages and stack
    trace. If you are using Python, the following command may be helpful:

      gdb --args python /path/to/your/code.py

    (You can use `gdb` to debug the code. Please consider compiling
    a debug version of k2.).

    If you are unable to fix it, please open an issue at:

      https://github.com/k2-fsa/k2/issues/new

@drawfish
Copy link
Author

Ah yes, you are right. It think this issue has been fixed in most places already, but it seems to have somehow stayed in the codebase at this point. Is there any chance you could make a pull request to fix this/
@danpovey
Hi, Dan. I think maybe the code in k2::IndexAxis0 needs to be totally modified. For example, I can be sure that 'Array2<int32_t> old_offsets, new_offsets' and 'Array1<int32_t> tot_sizes_out' also have int32_t out-of-range problems.
But I can't fully understand the code involved in this function. I need some help from your team.

@danpovey
Copy link
Collaborator

danpovey commented Nov 29, 2021 via email

@drawfish
Copy link
Author

Yh, at this stage, rescoring is the only solution.
I have made a PR to k2 repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants