Statistical model checking in approximate computing systems
Abstract
Grado en Estadística
Full text
Facultad de Ciencias Trabajo Fin de Grado Grado en Estadística Statistical Model Checking in Approximate Computing Systems Autor: Sergio Pérez Hernández Tutor: Luis Ángel García Escudero
1 Resumen Este trabajo se centra en la prueba de sistemas computacionales aproximados, comprobando, entre otras cosas, su tasa de acierto y si son ´utiles. Para estas pruebas se utilizar´a UPPAAL SMC, una herramienta de comprobaci´on de modelos estad´ısticos. Abstract This thesis is focused in testing approximate computing systems, checking, among other things, its hit rate and if they are useful. For these tests, UPPAAL SMC, a statistical model checking tool, will be used. Acknowledgements I would like to thank Mr. Josef Strnadel, teacher of the Information Technology Faculty at Brno University of Technology, for his effort and dedication in helping me throughout the proccess of creating my thesis.
2
Contents 1 Introduction 5 2 Background: Statistical Model Checking 7 3 Choice of Implementation Areas and Means 9 3.1 Implementation Areas . . . . . . . . . . . . . . . . . . . . . . . . 9 3.1.1 Approximate logical multiplier . . . . . . . . . . . . . . . 9 3.1.2 DRAMmemory ....................... 11 3.2 Implementation Means . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2.1 UPPAAL4.0 ......................... 12 3.2.2 UPPAAL 4.1 (SMC) . . . . . . . . . . . . . . . . . . . . . 14 4 Evaluation 19 4.1 Tests on multiplier based on gate networks . . . . . . . . . . . . 19 4.2 Tests on multiplier based on truth tables . . . . . . . . . . . . . . 24 4.3 Comparison of the two implementations . . . . . . . . . . . . . . 29 4.4 TestsonDRAMmodel........................ 30 5 Conclusions 33 3
4CONTENTS
Chapter 1 Introduction In the last two or three dacades, information has became the most valuable thing in the world. With it, we can study what has happened, what is happening and what will happen. But have these data is not free. In a lot of cases, it is needed a lot resources to process and store it. This concepts introduce ’Big Data’. By definition, Big Data is a extremely large data sets that may be analysed computationally to reveal patterns, trends, and associations, especially relating to human behaviour and interactions. But sometimes, handle with this huge amount of information is not possible because there isn’t any tool available or it is so expensive. Here is where approximate computing appears. Admitting that some error could occur, we can improve the speed, complexity and size of our problem so we are able to have significative results. Approximate computing is used in a lot of fields, such as machine learning, scientific computing, etc. To observe the behaviour of some systems that use this technology, Statistical Model Checking method will be used. It does simulations of a system in a stochastic way, that is, non-deterministic, with certain conditions. Then, the results will be studied. Quantitative properties of stochastic systems are usually specified in logic that allow one to compare the measure of executions satisfying certain temporal properties with thresholds. The model checking problem for stochastic systems with respect to such logic is typically solved by a numerical approach that iteratively computes (or approximates) the exact measure of paths satisfying relevant subformulas.(3) In this bachelor’s thesis, I will try to prove that approximate computing systems are useful in some specific fields. To do that, I will check the properties of some approximate computing circuits that I’ve design in my Information Technology thesis. The tool that will be used for the implementation will be UPPAAL, on version 4.1. It is an integrated tool environment for modelling, validation and verification of real-time systems modelled as networks of timed automata.(6) 5
6CHAPTER 1. INTRODUCTION
Chapter 2 Background: Statistical Model Checking Model Checking is a recognized approach to guarantee the correctness of a system (4). It is based on algorithms that check whether all executions of a system satisfy some properties stated in specification logic. If this happens, the system is correct. Else, a bug is reported. Model checking can detect all bugs of a system, but it is generally slower. Classical model checking techniques are Boolean, but this view is now obsolete. This has motivated the development of a series of new techniques, based in probability. Statistical Model Checking has recently been proposed as an alternative to avoid an exhaustive exploration of the state-space of the model. The main idea is to conduct some simulations of the system, monitor them, and then use results from statistic area to decide if the system satisfies the property or not with some degree of confidence. SMC is a compromise between testing and classical model checking techniques. Furthermore, it is very simple to implement, it doesn’t require extra modelling or specification effort and it allows to model check properties that cannot be expressed in classical temporal logics. Figure 2.1: Scheme of Statistical Model Checking (4) 7
8CHAPTER 2. BACKGROUND: STATISTICAL MODEL CHECKING
3.2. IMPLEMENTATION MEANS 15 Figure 3.5: Example of a stochastic timed automata (1) A model in UPPAAL SMC consists of a network of interacting stochastic timed automata. It is assumed that these components are input-enabled, deterministic and non-zero. These components communicate via broadcast channels and shared variables to generate networks of stochastic timed automata. The communication is restricted to broadcast synchronizations to keep a clean semantics of only non-blocked components which are racing against each other with their corresponding local distribution. Additional verifying properties Simulation In addition to the standard model checking queries, UPPAL SMC provides a number of new queries related to the stochastic interpretation of timed automata. In particular, it allows the user to visualize the values of expressions along simulated runs (evaluating to integers or clocks), providing insight to the user on the behaviour of the system so more interesting properties can be asked to the model-checker. The concrete syntax applied in UPPAAL SMC is as follows: simulate [<=bound]{E1,...,Ek} where Nis a natural number indicating the number of simulations to be performed, bound is the time bound on the simulations, and E1,...,Ekare the k expressions that are to be monitorized and visualized. Probability estimation The probability estimation algorithm of UPPAAL SMC computes the number of runs needed to produces an aproximation interval [p−ε, p+ε] for p=P r(Ψ)with a confidence 1−α. A frequentist interpretation of this result tells us that if we repeat the interval estimation Ntimes, then the estimated confidence interval (p±ε) contains the true probability at least (1 −α)Nin the long run (N→ ∞)
16 CHAPTER 3. CHOICE OF IMPLEMENTATION AREAS AND MEANS The syntax applied to check probability estimations is: Pr [bound](Expression) Also, UPPAAL gives you some plots, like the probability density distribution plot or the cumulative probability distribution plot. Figure 3.6: Queries about probability estimation and simulation Figure 3.7: Probability density distribution plot Hypothesis testing This approach reduces the qualitative question to test the null-hypothesis H0:p≥p0against the alternative hypothesis H1:p < p0. In UPPAAL SMC, we use the following query: Pr [bound](Expression)>=p0 Probability comparison The algorithm use the Wald test to compare probabilities, with the following query:
3.2. IMPLEMENTATION MEANS 17 Pr[bound1](Expression1) = Pr[bound2](Expression2) Expected values UPPAAL SMC also supports the evaluation of expected values of min or max of an expression that evaluates a clock or an integer value. The syntax is: E[bound;N ](min:Expression) or E[bound;N ](max:Expression)
18 CHAPTER 3. CHOICE OF IMPLEMENTATION AREAS AND MEANS
Chapter 4 Evaluation For the different tests that will be done on the models described before, the verifier tool of UPPAAL SMC will be used. With it, we can obtain various plots, confidence intervals, results of simulations using diagrams, etc. 4.1 Tests on multiplier based on gate networks Verification of the model First of all, it will be checked that the system behaves correctly. To do that, the parameter of the template Main will be set on 1, so only one iteration will be done. The following plot has been obtained with the command: simulate[<=2] {randomV[0], input[0], randomV[1]+2,input[1]+2,randomV[2]+4, input[2]+4, randomV[3]+6, input[3]+6, success+8}. On it, there will be represented, starting from below, the four random values obtained using a normal distribution. With them, if the value is positive, the input will be 1, and if it is negative, the input will stay in 0. At the top, the success variable is shown. These are two possible results: (a) (b) 19
20 CHAPTER 4. EVALUATION In figure 4.1a, we can see that, for the inputs 0, 1 and 3, the random values obtained are negative, and for the input 2 it has been positive, so the corresponding input is 0010. With this combination of inputs, the approximate and the accurate multipliers have the same outputs, so the variable success has increased one unit. In the simulation that is represented in the second plot 4.1b, all random values have been positive, so the inputs of the system were 1111. That is the only possible input which the outputs of the multipliers are different. That means that there has been a failure, so the variable success doesn’t increase. Number of successes In this test, I will see how many successes are obtained depending on the number of iterations that the system does. It is known that, theoretically, there is only 1 chance of 16 that the system fails (0.0625%). For the simulations, the next command has been used: simulate[<=N]{success} where Nrepresents the number of iterations done. These are the results: N Successes Fails 10 10 0 50 46 4 100 94 6 200 183 17 300 278 22 400 376 24 500 471 29 750 710 40 1000 922 88 2000 1871 129 These results seem similar to the theoretical value, but it is needed to check it. To do it, for each number of iterations, I will do a hypothesis test for proportions , testing H0:p= 0.0625. I use R to do it, obtaining a p-value with the function: prop.test(Fails,N,p=0.0625,alternative="two.sided") The results are:
4.1. TESTS ON MULTIPLIER BASED ON GATE NETWORKS 21 N p-value 50 0.8266 100 1 200 0.2426 300 0.5118 400 0.9177 500 0.7465 750 0.3362 1000 0.00109 2000 0.7465 With these results it can be said that it is not possible to reject H0for all N tested except for N=1000. Behaviour of the number of successes With this test, I will check what is the statistical behaviour of the number of successes. To do that, I calculate the expected values of the maximum of the variable success and then check the plots. I’ve used the next command in the verifier tool of UPPAAL: E[<=bound;N](max:success) where bound and Nare numbers big enough to have the significant results, and bound need to be at least as big as the parameter loops of the template Main. For the experiment, I’ve chosen 1000 for both numbers. These are some results: (c) Probability Distribution Plot (d) Cumulative Probability Distribution Plot As numerical results, this simulation has been obtained as mean µ= 937.6 and a confidence interval of 95% [937.129,938.071]. Observing the plots 4.1c and 4.1d, we can see clearly that the variable success follows a normal distribution. Transforming now these values to error rate (doing the operation 1 −(x 1000 )), we obtain that the average error rate is 0.0624, and the confidence interval in 95% is [0.061929,0.062871]. With this interval, we can see that the theoretical value is in it, and the mean is also really proximate to that number.
22 CHAPTER 4. EVALUATION Comparison of the resources used by both multipliers In this test, I will compare the time needed by the system to calculate Noutputs of the accurate and the approximate multiplier separately. This time is given by UPPAAL at the end of the calculation. I’ve used the same command of the first test but varying the bound. These are the results: N Accurate multiplier Approximate multiplier 100 0.032 0.016 1000 0.235 0.125 2000 0.36 0.281 3000 0.594 0.359 4000 0.75 0.563 5000 0.969 0.64 6000 1.093 0.75 7000 1.328 0.86 8000 1.485 1.015 9000 1.703 1.125 10000 1.969 1.344 11000 2.047 1.375 12000 2.266 1.5 15000 2.891 1.828 Table 4.1: Time used by the multipliers in seconds depending on the number of iterations Figure 4.1: Plot of times of both multipliers With this table and this plot, we can see that the time used by the accurate multiplier is higher than the used by the approximate multiplier in every point. But first, I will check the relation between both lines, checking if they are related.
4.1. TESTS ON MULTIPLIER BASED ON GATE NETWORKS 23 For that I will do a paired t-test with H0:µD<0 and H1:µD>0. I’ve used the function: t.test(acc mult,appr mult,alternative="greater",paired=TRUE) obtaining the following results: Figure 4.2: Paired t-test for times in gate network approach The p-value obtained is 0.0006545, so H0can be rejected in favor of H1, showing differences between both models. Now I will do an coincidence test to check if there exists any differences between the two regression lines. I unify all the times in a unique column and I create two new columns: Z, which is 0 in case the observation is from the accurate multiplier and 1 if it is from the approximate one; and W=Z*N to deal with different slopes for the regression lines: N Time Z W 100 0.032 0 0 1000 0.235 0 0 2000 0.36 0 0 ... ... ... ... 100 0.016 1 100 1000 0.125 1 1000 2000 0.281 1 2000 ... ... ... ... I consider two different models: •Model 1: Time=β0+β1N •Model 2: Time=β0+β1N+β2Z+β3W. First, I see if there is any gain adding the information of Wand Ycodifying the categorical one. I use the function anova(Model 1,Model 2): Figure 4.3: Anova test for Model 1 and Model 2
24 CHAPTER 4. EVALUATION The p-value obtained is practically 0, so it can be said that the second model gives more information than he first one. Using summary(Model 2)we can see more information: Figure 4.4: Summary of Model 2 Observing the p-values of the coefficients, it makes sense that the intercept and the Zcan be set on 0, so the can be deleted from the model. The final model is: Time=β1N+β3Z·N So the levels of the Zvariables changes the slope of the fitted regression lines. Since Whas not been rejected, we can say that there are coincidences, so there is not any parallelism between the accurate model and the approximate one. Then, observing that the model of the approximate multiplier has less slope than the accurate one, it has been demonstrated that the approximate multiplier is more efficient than the accurate multiplier in terms of time. 4.2 Tests on multiplier based on truth tables Tests on this model will be similar to the ones done in the previous model, so we can check that the results are correct. Verification of the model The first test will check if the system works correctly. For that, I will use both templates that generate inputs. The two next plots are generated in the verifier tool on UPPAAL with the next command:
4.4. TESTS ON DRAM MODEL 31 In figure 4.10, the voltage exceeds the threshold before the second refresh, so the real value is not equal to the expected value anymore. When a refresh is done, the real value is 0, so it doesn’t recharge again. Therefore, we can conclude that the model works correctly. Error rate depending on the time of refresh With this test, it is wanted to be known what is the error rate of the system varying the time of refresh of the system. Only 1 cell will be used because a writing in several cells at the same time returns the same error rate on all of them. This template simulates a writing on cell 0 on the time unit 50. The command used in UPPAAL verifier is: simulate[<=bound]{cVolt[0][0],eBit[0][0], cBit[0][0],V TRESH,errorRate[0][0]+4} bound should be as big as necessary to see the correct error rate. These are the results: Time of refresh Number of refreshes before a failure Error rate 20 - 0% 40 - 0% 58 1 1.59% 60 1 3.2% 80 1 18.8% 100 1 26.57% 111 0 1.41% 120 0 13.63% 140 0 33.82% 160 0 46.05% 180 0 54.72% 200 0 60.83% (a) Simulation with tRefresh = 80 (b) Error rate depending on the time of refresh
32 CHAPTER 4. EVALUATION In plot 4.11a the writing is correct till the time 140 approximately, where the voltage starts to be lower than the threshold and the expected value is set on 0. There is a refresh on time 80, that can be seen because the voltage value is again the maximum possible. In plot 4.11b we can see that the error rate always increases with the time of refresh, except on one point, on 111. This is because on that point there is a refresh just after the threshold has been reached, so the system updates its real value when very little time has passed since the expected value was updated. In this case, if the system allows committing some failures, then the time of refresh that should be selected is 111 because it is the time which gets a lower error rate and without doing any refreshes. If there would be an error rate even lower but doing one refresh , then the system manager must decide what is the best for him, get less error rate but doing a refresh, which has a cost, or gets a little more error rate and doesn’t do any refreshes. This results will change depending on the experiment done. This is given because the writing has been done on the time unit 50, but if this operation is done at another moment, the optimal time of refresh will change. This is caused because the time of refresh is done all times at the same moment, doesn’t matter when an operation happens.
Chapter 5 Conclusions The aim of this thesis was to prove that approximate computing systems are useful if some errors can be accepted in the results obtained. For that, two types of models have been tested: Two models of accurate and approximate logical multiplier and a model of a dynamic random access memory (DRAM). These tests have been done using UPPAAL SMC. In my opinion, the final results obtained on the different tests performed confirm that the approximate computing systems have a lot of utilities in different fields, such as in image and sound processing, machine learning or artificial intelligence, where some bits can be lost without having serious problems. Some other tests could be done on these systems but are not implemented in this thesis could be amplify the number of inputs and outputs of the multipliers and see if the error rate is still as low as it is with 4 inputs, or check the behaviour of the error rates with more writings on different moments on the DRAM model. 33
34 CHAPTER 5. CONCLUSIONS
Bibliography [1] David, A.; Larsen, K. G.; Legay, A.; et al.: UPPAAL SMC tutorial. 2015. [Online; visited 09.05.2019]. Retrieved from: https://doi.org/10.1007/s10009-014-0361-y [2] Emerging Computing Technology Laboratory at SJTU: Approximate Computing. [Online; visited 09.05.2019]. Retrieved from: http://umji.sjtu.edu.cn/~wkqian/research.html [3] Legay, A.; Delahaye, B.; Bensalem, S.: Statistical Model Checking: An Overview. 2010. [Online; visited 09.05.2019]. Retrieved from: https://arxiv.org/pdf/1005.1327.pdf [4] Plasma Lab: Statistical Model Checking. [Online; visited 09.05.2019]. Retrieved from: https://project.inria.fr/plasma-lab/ statistical-model-checking [5] P´erez, S.: Design and Implementation of Approximate Computing Systems. 2020. [6] UPPAAL: [Online; visited 09.05.2019]. Retrieved from: www.uppaal.org [7] UPPAAL: Locations. [Online; visited 09.05.2019]. Retrieved from: http://www.it.uu.se/research/group/darts/uppaal/ help.php?file=System_Descriptions/Locations.shtml [8] UPPAAL: UPPAAL 4.0: Small Tutorial. 2009. [Online; visited 09.05.2019]. Retrieved from: http://www.it.uu.se/research/group/darts/uppaal/ small_tutorial.pdf [9] Wikipedia: DRAM. [Online; visited 09.05.2019]. Retrieved from: https://es.wikipedia.org/wiki/DRAM [10] Wikipedia: Dynamic Random Access Memory. [Online; visited 09.05.2019]. Retrieved from: https://en.wikipedia.org/wiki/Dynamic_ random-access_memory 35
36 BIBLIOGRAPHY [11] Yoon, A.: Understanding Memory. 2018. [Online; visited 09.05.2019]. Retrieved from: https://semiengineering.com/ whats-really-happening-inside-memory/